| LEFT | RIGHT | 
|---|
| 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-2017 eyeo GmbH | 3  * Copyright (C) 2006-2017 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 | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 12  * GNU General Public License for more details. | 12  * GNU General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU General Public License | 14  * You should have received a copy of the GNU General Public License | 
| 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 16  */ | 16  */ | 
| 17 | 17 | 
| 18 #pragma once | 18 #pragma once | 
| 19 | 19 | 
|  | 20 #include <algorithm> | 
| 20 #include <cstddef> | 21 #include <cstddef> | 
| 21 #include <cstring> | 22 #include <cstring> | 
| 22 #include <algorithm> | 23 #include <type_traits> | 
| 23 | 24 | 
| 24 #include <emscripten.h> | 25 #include <emscripten.h> | 
| 25 | 26 | 
| 26 #include "debug.h" | 27 #include "debug.h" | 
| 27 | 28 | 
| 28 inline void String_assert_readonly(bool readOnly); | 29 inline void String_assert_readonly(bool readOnly); | 
| 29 | 30 | 
| 30 class String | 31 class String | 
| 31 { | 32 { | 
| 32   friend class DependentString; | 33   friend class DependentString; | 
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 323   } | 324   } | 
| 324 | 325 | 
| 325   ~OwnedString() | 326   ~OwnedString() | 
| 326   { | 327   { | 
| 327     if (mBuf) | 328     if (mBuf) | 
| 328       delete[] mBuf; | 329       delete[] mBuf; | 
| 329   } | 330   } | 
| 330 | 331 | 
| 331   OwnedString& operator=(const String& str) | 332   OwnedString& operator=(const String& str) | 
| 332   { | 333   { | 
| 333     *this = std::move(OwnedString(str)); | 334     *this = OwnedString(str); | 
| 334     return *this; | 335     return *this; | 
| 335   } | 336   } | 
| 336 | 337 | 
| 337   OwnedString& operator=(const OwnedString& str) | 338   OwnedString& operator=(const OwnedString& str) | 
| 338   { | 339   { | 
| 339     *this = std::move(OwnedString(str)); | 340     *this = OwnedString(str); | 
| 340     return *this; | 341     return *this; | 
| 341   } | 342   } | 
| 342 | 343 | 
| 343   OwnedString& operator=(OwnedString&& str) | 344   OwnedString& operator=(OwnedString&& str) | 
| 344   { | 345   { | 
| 345     std::swap(mBuf, str.mBuf); | 346     std::swap(mBuf, str.mBuf); | 
| 346     std::swap(mLen, str.mLen); | 347     std::swap(mLen, str.mLen); | 
| 347     return *this; | 348     return *this; | 
| 348   } | 349   } | 
| 349 | 350 | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 372 | 373 | 
| 373   void append(const String& str) | 374   void append(const String& str) | 
| 374   { | 375   { | 
| 375     append(str.mBuf, str.length()); | 376     append(str.mBuf, str.length()); | 
| 376   } | 377   } | 
| 377 | 378 | 
| 378   void append(value_type c) | 379   void append(value_type c) | 
| 379   { | 380   { | 
| 380     append(&c, 1); | 381     append(&c, 1); | 
| 381   } | 382   } | 
|  | 383 | 
|  | 384   template<typename T, | 
|  | 385       typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> | 
|  | 386   void append(T num) | 
|  | 387   { | 
|  | 388     bool negative = false; | 
|  | 389     if (num < 0) | 
|  | 390     { | 
|  | 391       negative = true; | 
|  | 392       num = -num; | 
|  | 393     } | 
|  | 394 | 
|  | 395     size_type size = 0; | 
|  | 396     for (T i = num; i; i /= 10) | 
|  | 397       size++; | 
|  | 398     size = (size ? size : 1); | 
|  | 399 | 
|  | 400     size_type pos = length(); | 
|  | 401     grow((negative ? 1 : 0) + size); | 
|  | 402 | 
|  | 403     if (negative) | 
|  | 404       mBuf[pos++] = '-'; | 
|  | 405 | 
|  | 406     for (int i = size - 1; i >= 0; i--) | 
|  | 407     { | 
|  | 408       mBuf[pos + i] = '0' + (num % 10); | 
|  | 409       num /= 10; | 
|  | 410     } | 
|  | 411   } | 
| 382 }; | 412 }; | 
| LEFT | RIGHT | 
|---|