Index: compiled/StringScanner.h |
=================================================================== |
--- a/compiled/StringScanner.h |
+++ b/compiled/StringScanner.h |
@@ -12,16 +12,18 @@ |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
#pragma once |
+#include <cwctype> |
+ |
#include "String.h" |
class StringScanner |
{ |
private: |
const DependentString mStr; |
String::size_type mPos; |
String::size_type mEnd; |
@@ -49,16 +51,46 @@ |
String::value_type next() |
{ |
String::value_type result = done() ? mTerminator : mStr[mPos]; |
mPos++; |
return result; |
} |
+ bool skipWhiteSpace() |
+ { |
+ bool skipped = false; |
+ while (!done() && std::iswspace(mStr[mPos])) |
+ { |
+ skipped = true; |
+ mPos++; |
+ } |
+ |
+ return skipped; |
+ } |
+ |
+ bool skipString(const String& str) |
+ { |
+ bool skipped = false; |
+ |
+ if (str.length() > mStr.length() - mPos) |
+ return false; |
+ |
+ if (std::memcmp(str.data(), |
+ mStr.data() + mPos, |
+ sizeof(String::value_type) * str.length()) == 0) |
+ { |
+ mPos += str.length(); |
+ skipped = true; |
+ } |
+ |
+ return skipped; |
+ } |
+ |
bool skipOne(String::value_type ch) |
{ |
if (!done() && mStr[mPos] == ch) |
{ |
mPos++; |
return true; |
} |