#ifdef NALL_STRING_INTERNAL_HPP namespace nall { template string& string::ureplace(rstring key, rstring token) { if(key.size() == 0) return *this; enum : unsigned { limit = Limit ? Limit : ~0u }; const char* p = data(); unsigned counter = 0; while(*p) { if(quoteskip(p)) continue; for(unsigned n = 0;; n++) { if(key[n] == 0) { counter++; p += n; break; } if(!chrequal(key[n], p[n])) { p++; break; } } } if(counter == 0) return *this; if(Limit) counter = min(counter, Limit); char* t = data(); char* base = nullptr; signed displacement = token.size() - key.size(); signed displacementSize = displacement * counter; if(token.size() > key.size()) { t = base = strduplicate(data()); reserve((unsigned)(p - data()) + displacementSize); } char* o = data(); while(*t && counter) { if(quotecopy(o, t)) continue; for(unsigned n = 0;; n++) { if(key[n] == 0) { counter--; memcpy(o, token, token.size()); t += key.size(); o += token.size(); break; } if(!chrequal(key[n], t[n])) { *o++ = *t++; break; } } } do *o++ = *t; while(*t++); if(base) free(base); resize(_size + displacementSize); return *this; } template string& string::replace(rstring key, rstring token) { return ureplace(key, token); } template string& string::ireplace(rstring key, rstring token) { return ureplace(key, token); } template string& string::qreplace(rstring key, rstring token) { return ureplace(key, token); } template string& string::iqreplace(rstring key, rstring token) { return ureplace(key, token); } }; #endif