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

Side by Side Diff: compiled/String.h

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Added md5 checksum. Reorganized some code. Created Nov. 28, 2017, 10:46 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/Md5.cpp ('k') | compiled/StringScanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // This should be more efficient with a lookup table but I couldn't measur e 184 // This should be more efficient with a lookup table but I couldn't measur e
185 // any performance difference. 185 // any performance difference.
186 if (currChar >= u'A' && currChar <= u'Z') 186 if (currChar >= u'A' && currChar <= u'Z')
187 mBuf[i] = currChar + u'a' - u'A'; 187 mBuf[i] = currChar + u'a' - u'A';
188 else if (currChar >= 128) 188 else if (currChar >= 128)
189 { 189 {
190 mBuf[i] = CharToLower(currChar); 190 mBuf[i] = CharToLower(currChar);
191 } 191 }
192 } 192 }
193 } 193 }
194
195 int toInt() const
196 {
197 size_type count = 0;
198 int value = 0;
199 for (size_type i = 0; i < length(); i++)
200 {
201 if (mBuf[i] < u'0' || mBuf[i] > u'9')
202 return 0;
203 value *= 10;
204 value += mBuf[i] - u'0';
205 count++;
206 if (count > 8)
207 return 0;
208 }
209 return value;
210 }
194 }; 211 };
195 212
196 class DependentString : public String 213 class DependentString : public String
197 { 214 {
198 public: 215 public:
199 explicit DependentString() 216 explicit DependentString()
200 : String(nullptr, 0, INVALID) 217 : String(nullptr, 0, INVALID)
201 { 218 {
202 } 219 }
203 220
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (negative) 420 if (negative)
404 mBuf[pos++] = '-'; 421 mBuf[pos++] = '-';
405 422
406 for (int i = size - 1; i >= 0; i--) 423 for (int i = size - 1; i >= 0; i--)
407 { 424 {
408 mBuf[pos + i] = '0' + (num % 10); 425 mBuf[pos + i] = '0' + (num % 10);
409 num /= 10; 426 num /= 10;
410 } 427 }
411 } 428 }
412 }; 429 };
OLDNEW
« 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