| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 363 |
| 363 void append(const String& str) | 364 void append(const String& str) |
| 364 { | 365 { |
| 365 append(str.mBuf, str.length()); | 366 append(str.mBuf, str.length()); |
| 366 } | 367 } |
| 367 | 368 |
| 368 void append(value_type c) | 369 void append(value_type c) |
| 369 { | 370 { |
| 370 append(&c, 1); | 371 append(&c, 1); |
| 371 } | 372 } |
| 373 |
| 374 template<typename T, |
| 375 typename std::enable_if<std::is_integral<T>::value>::type* = nullptr> |
| 376 void append(T num) |
| 377 { |
| 378 bool negative = false; |
| 379 if (num < 0) |
| 380 { |
| 381 negative = true; |
| 382 num = -num; |
| 383 } |
| 384 |
| 385 size_type size = 0; |
| 386 for (T i = num; i; i /= 10) |
| 387 size++; |
| 388 size = (size ? size : 1); |
| 389 |
| 390 size_type pos = length(); |
| 391 grow((negative ? 1 : 0) + size); |
| 392 |
| 393 if (negative) |
| 394 mBuf[pos++] = '-'; |
| 395 |
| 396 for (int i = size - 1; i >= 0; i--) |
| 397 { |
| 398 mBuf[pos + i] = '0' + (num % 10); |
| 399 num /= 10; |
| 400 } |
| 401 } |
| 372 }; | 402 }; |
| LEFT | RIGHT |