2011-10-02 10:05:45 +00:00
|
|
|
#ifdef NALL_STRING_INTERNAL_HPP
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
template<unsigned Limit, bool Insensitive, bool Quoted> lstring& lstring::usplit(rstring key, rstring base) {
|
2010-08-09 13:28:56 +00:00
|
|
|
reset();
|
2013-05-05 09:21:30 +00:00
|
|
|
if(key.size() == 0) return *this;
|
2011-08-06 14:03:52 +00:00
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
const char* b = base;
|
2013-05-02 11:25:45 +00:00
|
|
|
const char* p = base;
|
2011-08-06 14:03:52 +00:00
|
|
|
|
|
|
|
while(*p) {
|
2011-10-16 09:44:48 +00:00
|
|
|
if(Limit) if(size() >= Limit) break;
|
2011-08-06 14:03:52 +00:00
|
|
|
if(quoteskip<Quoted>(p)) continue;
|
|
|
|
for(unsigned n = 0;; n++) {
|
|
|
|
if(key[n] == 0) {
|
2013-05-05 09:21:30 +00:00
|
|
|
append(substr(b, 0, p - b));
|
2011-08-06 14:03:52 +00:00
|
|
|
p += n;
|
2013-05-05 09:21:30 +00:00
|
|
|
b = p;
|
2011-08-06 14:03:52 +00:00
|
|
|
break;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
2011-08-06 14:03:52 +00:00
|
|
|
if(!chrequal<Insensitive>(key[n], p[n])) { p++; break; }
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
append(b);
|
2011-08-06 14:03:52 +00:00
|
|
|
return *this;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
template<unsigned Limit> lstring& lstring::split(rstring key, rstring src) { return usplit<Limit, false, false>(key, src); }
|
|
|
|
template<unsigned Limit> lstring& lstring::isplit(rstring key, rstring src) { return usplit<Limit, true, false>(key, src); }
|
|
|
|
template<unsigned Limit> lstring& lstring::qsplit(rstring key, rstring src) { return usplit<Limit, false, true>(key, src); }
|
|
|
|
template<unsigned Limit> lstring& lstring::iqsplit(rstring key, rstring src) { return usplit<Limit, true, true>(key, src); }
|
2011-08-06 14:03:52 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|