Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/StringScanner.h

Issue 29630576: Issue 5146 - Part 2: Process http response in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebased Created Aug. 14, 2018, 12:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiled/bindings/main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | compiled/bindings/main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld