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

Unified Diff: compiled/String.h

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Simplify the logic of Process() Created Dec. 4, 2017, 10:04 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 | « compiled/Md5.cpp ('k') | compiled/StringScanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/String.h
===================================================================
--- a/compiled/String.h
+++ b/compiled/String.h
@@ -186,16 +186,34 @@
if (currChar >= u'A' && currChar <= u'Z')
mBuf[i] = currChar + u'a' - u'A';
else if (currChar >= 128)
{
mBuf[i] = CharToLower(currChar);
}
}
}
+
+ template<typename T>
+ T toInt() const
+ {
+ size_type count = 0;
+ T value = 0;
+ for (size_type i = 0; i < length(); i++)
+ {
+ if (mBuf[i] < u'0' || mBuf[i] > u'9' ||
+ count > std::numeric_limits<T>::digits10)
+ return 0;
+
+ value *= 10;
+ value += mBuf[i] - u'0';
+ count++;
+ }
+ return value;
+ }
};
class DependentString : public String
{
public:
explicit DependentString()
: String(nullptr, 0, INVALID)
{
« no previous file with comments | « compiled/Md5.cpp ('k') | compiled/StringScanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld