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: Created Dec. 5, 2017, 9:19 a.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,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;
}
« 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