bsnes-libretro/nall/string/find.hpp
Tim Allen 0b923489dd Update to 20160106 OS X Preview for Developers release.
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
2016-01-07 19:17:15 +11:00

27 lines
1.1 KiB
C++

#pragma once
namespace nall {
template<bool Insensitive, bool Quoted> auto string::_find(int offset, rstring source) const -> maybe<uint> {
if(source.size() == 0) return nothing;
auto p = data();
for(uint n = offset, quoted = 0; n < size();) {
if(Quoted) { if(p[n] == '\"') { quoted ^= 1; n++; continue; } if(quoted) { n++; continue; } }
if(_compare<Insensitive>(p + n, size() - n, source.data(), source.size())) { n++; continue; }
return n - offset;
}
return nothing;
}
auto string::find(rstring source) const -> maybe<uint> { return _find<0, 0>(0, source); }
auto string::ifind(rstring source) const -> maybe<uint> { return _find<1, 0>(0, source); }
auto string::qfind(rstring source) const -> maybe<uint> { return _find<0, 1>(0, source); }
auto string::iqfind(rstring source) const -> maybe<uint> { return _find<1, 1>(0, source); }
auto string::findFrom(int offset, rstring source) const -> maybe<uint> { return _find<0, 0>(offset, source); }
auto string::ifindFrom(int offset, rstring source) const -> maybe<uint> { return _find<1, 0>(offset, source); }
}