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

Side by Side Diff: compiled/String.h

Issue 29685634: Noissue - Allow displaying String in tests (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Jan. 31, 2018, 8:45 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 | « no previous file | meson.build » ('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
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 <algorithm>
21 #include <cstddef> 21 #include <cstddef>
22 #include <cstring> 22 #include <cstring>
23 #include <type_traits> 23 #include <type_traits>
24 #include <iostream>
sergei 2018/02/01 16:10:46 Could you please wrap it by #ifdef INSIDE_TESTS to
hub 2018/02/01 19:16:29 Done.
24 25
25 #include "debug.h" 26 #include "debug.h"
26 #include "library.h" 27 #include "library.h"
27 28
28 inline void String_assert_writable(bool isWritable); 29 inline void String_assert_writable(bool isWritable);
29 30
30 class String 31 class String
31 { 32 {
32 friend class DependentString; 33 friend class DependentString;
33 friend class OwnedString; 34 friend class OwnedString;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (currChar >= u'A' && currChar <= u'Z') 187 if (currChar >= u'A' && currChar <= u'Z')
187 mBuf[i] = currChar + u'a' - u'A'; 188 mBuf[i] = currChar + u'a' - u'A';
188 else if (currChar >= 128) 189 else if (currChar >= 128)
189 { 190 {
190 mBuf[i] = CharToLower(currChar); 191 mBuf[i] = CharToLower(currChar);
191 } 192 }
192 } 193 }
193 } 194 }
194 }; 195 };
195 196
197 #ifdef INSIDE_TESTS
198 inline std::ostream& operator<<(std::ostream& os, const String& str)
199 {
200 for (String::size_type i = 0; i < str.length(); i++)
201 os << static_cast<char>(str[i]);
sergei 2018/02/01 16:10:46 Even for tests I would like to have a helper funct
hub 2018/02/01 19:16:30 Done
202 return os;
203 }
204 #endif
205
196 class DependentString : public String 206 class DependentString : public String
197 { 207 {
198 public: 208 public:
199 explicit DependentString() 209 explicit DependentString()
200 : String(nullptr, 0, INVALID) 210 : String(nullptr, 0, INVALID)
201 { 211 {
202 } 212 }
203 213
204 explicit DependentString(value_type* buf, size_type len) 214 explicit DependentString(value_type* buf, size_type len)
205 : String(buf, len, READ_WRITE) 215 : String(buf, len, READ_WRITE)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 *this = DependentString(str, pos, len); 260 *this = DependentString(str, pos, len);
251 } 261 }
252 262
253 void erase() 263 void erase()
254 { 264 {
255 *this = DependentString(); 265 *this = DependentString();
256 mLen = DELETED; 266 mLen = DELETED;
257 } 267 }
258 }; 268 };
259 269
270 #ifdef INSIDE_TESTS
271 inline std::ostream& operator<<(std::ostream& os, const DependentString& str)
sergei 2018/02/01 16:10:46 It should not be required.
hub 2018/02/01 19:16:30 Without this it operator<< doesn't get called, unl
sergei 2018/02/02 15:03:32 Acknowledged. I think it is worth investigation, b
272 {
273 return os << static_cast<const String&>(str);
274 }
275 #endif
276
260 inline DependentString operator "" _str(const String::value_type* str, 277 inline DependentString operator "" _str(const String::value_type* str,
261 String::size_type len) 278 String::size_type len)
262 { 279 {
263 return DependentString(str, len); 280 return DependentString(str, len);
264 } 281 }
265 282
266 inline void String_assert_writable(bool isWritable) 283 inline void String_assert_writable(bool isWritable)
267 { 284 {
268 assert2(isWritable, u"Writing access to a read-only string"_str); 285 assert2(isWritable, u"Writing access to a read-only string"_str);
269 } 286 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 if (negative) 430 if (negative)
414 mBuf[pos++] = '-'; 431 mBuf[pos++] = '-';
415 432
416 for (int i = size - 1; i >= 0; i--) 433 for (int i = size - 1; i >= 0; i--)
417 { 434 {
418 mBuf[pos + i] = '0' + (num % 10); 435 mBuf[pos + i] = '0' + (num % 10);
419 num /= 10; 436 num /= 10;
420 } 437 }
421 } 438 }
422 }; 439 };
OLDNEW
« no previous file with comments | « no previous file | meson.build » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld