mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 15:12:23 +01:00
byuu says: New update. Most of the work today went into eliminating hiro::Image from all objects in all ports, replacing with nall::image. That took an eternity. Changelog: - fixed crashing bug when loading games [thanks endrift!!] - toggling "show status bar" option adjusts window geometry (not supposed to recenter the window, though) - button sizes improved; icon-only button icons no longer being cut off
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#pragma once
|
|
|
|
namespace nall {
|
|
|
|
template<bool Insensitive, bool Quoted>
|
|
auto lstring::_split(rstring source, rstring find, long limit) -> lstring& {
|
|
reset();
|
|
if(limit <= 0 || find.size() == 0) return *this;
|
|
|
|
const char* p = source.data();
|
|
signed size = source.size();
|
|
signed base = 0;
|
|
signed matches = 0;
|
|
|
|
for(signed n = 0, quoted = 0; n <= size - (signed)find.size();) {
|
|
if(Quoted) { if(p[n] == '\"') { quoted ^= 1; n++; continue; } if(quoted) { n++; continue; } }
|
|
if(string::_compare<Insensitive>(p + n, size - n, find.data(), find.size())) { n++; continue; }
|
|
if(matches >= limit) break;
|
|
|
|
string& s = operator()(matches);
|
|
s.resize(n - base);
|
|
memory::copy(s.get(), p + base, n - base);
|
|
|
|
n += find.size();
|
|
base = n;
|
|
matches++;
|
|
}
|
|
|
|
string& s = operator()(matches);
|
|
s.resize(size - base);
|
|
memory::copy(s.get(), p + base, size - base);
|
|
|
|
return *this;
|
|
}
|
|
|
|
auto string::split(rstring on, long limit) const -> lstring { return lstring()._split<0, 0>(*this, on, limit); }
|
|
auto string::isplit(rstring on, long limit) const -> lstring { return lstring()._split<1, 0>(*this, on, limit); }
|
|
auto string::qsplit(rstring on, long limit) const -> lstring { return lstring()._split<0, 1>(*this, on, limit); }
|
|
auto string::iqsplit(rstring on, long limit) const -> lstring { return lstring()._split<1, 1>(*this, on, limit); }
|
|
|
|
}
|