Index: compiled/StringScanner.h |
=================================================================== |
--- a/compiled/StringScanner.h |
+++ b/compiled/StringScanner.h |
@@ -12,17 +12,20 @@ |
* 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 "base.h" |
+ |
#include "String.h" |
ABP_NS_BEGIN |
class StringScanner |
{ |
private: |
const DependentString mStr; |
@@ -52,16 +55,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; |
} |
@@ -71,9 +104,9 @@ |
bool skip(String::value_type ch) |
{ |
bool skipped = false; |
while ((skipped = skipOne(ch))); |
return skipped; |
} |
}; |
-ABP_NS_END |
+ABP_NS_END |