Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: webrtc/rtc_base/stringutils.h

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/rtc_base/stringize_macros_unittest.cc ('k') | webrtc/rtc_base/stringutils.cc » ('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 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_STRINGUTILS_H__ 11 #ifndef WEBRTC_RTC_BASE_STRINGUTILS_H_
12 #define WEBRTC_BASE_STRINGUTILS_H__ 12 #define WEBRTC_RTC_BASE_STRINGUTILS_H_
13 13
14 #include <ctype.h> 14 #include <ctype.h>
15 #include <stdarg.h> 15 #include <stdarg.h>
16 #include <stdio.h> 16 #include <stdio.h>
17 #include <string.h> 17 #include <string.h>
18 18
19 #if defined(WEBRTC_WIN) 19 #if defined(WEBRTC_WIN)
20 #include <malloc.h> 20 #include <malloc.h>
21 #include <wchar.h> 21 #include <wchar.h>
22 #define alloca _alloca 22 #define alloca _alloca
23 #endif // WEBRTC_WIN 23 #endif // WEBRTC_WIN
24 24
25 #if defined(WEBRTC_POSIX) 25 #if defined(WEBRTC_POSIX)
26 #ifdef BSD 26 #ifdef BSD
27 #include <stdlib.h> 27 #include <stdlib.h>
28 #else // BSD 28 #else // BSD
29 #include <alloca.h> 29 #include <alloca.h>
30 #endif // !BSD 30 #endif // !BSD
31 #endif // WEBRTC_POSIX 31 #endif // WEBRTC_POSIX
32 32
33 #include <string> 33 #include <string>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return _vsnwprintf(buf, n, fmt, args); 96 return _vsnwprintf(buf, n, fmt, args);
97 } 97 }
98 #endif // !vsnprintf 98 #endif // !vsnprintf
99 inline unsigned long strtoul(const wchar_t* snum, wchar_t** end, int base) { 99 inline unsigned long strtoul(const wchar_t* snum, wchar_t** end, int base) {
100 return wcstoul(snum, end, base); 100 return wcstoul(snum, end, base);
101 } 101 }
102 inline wchar_t tolowercase(wchar_t c) { 102 inline wchar_t tolowercase(wchar_t c) {
103 return static_cast<wchar_t>(towlower(c)); 103 return static_cast<wchar_t>(towlower(c));
104 } 104 }
105 105
106 #endif // WEBRTC_WIN 106 #endif // WEBRTC_WIN
107 107
108 #if defined(WEBRTC_POSIX) 108 #if defined(WEBRTC_POSIX)
109 109
110 inline int _stricmp(const char* s1, const char* s2) { 110 inline int _stricmp(const char* s1, const char* s2) {
111 return strcasecmp(s1, s2); 111 return strcasecmp(s1, s2);
112 } 112 }
113 inline int _strnicmp(const char* s1, const char* s2, size_t n) { 113 inline int _strnicmp(const char* s1, const char* s2, size_t n) {
114 return strncasecmp(s1, s2, n); 114 return strncasecmp(s1, s2, n);
115 } 115 }
116 116
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 262 }
263 inline int ascncmp(const wchar_t* s1, const char* s2, size_t n) { 263 inline int ascncmp(const wchar_t* s1, const char* s2, size_t n) {
264 return ascii_string_compare(s1, s2, n, identity); 264 return ascii_string_compare(s1, s2, n, identity);
265 } 265 }
266 inline int ascnicmp(const wchar_t* s1, const char* s2, size_t n) { 266 inline int ascnicmp(const wchar_t* s1, const char* s2, size_t n) {
267 return ascii_string_compare(s1, s2, n, tolowercase); 267 return ascii_string_compare(s1, s2, n, tolowercase);
268 } 268 }
269 size_t asccpyn(wchar_t* buffer, size_t buflen, 269 size_t asccpyn(wchar_t* buffer, size_t buflen,
270 const char* source, size_t srclen = SIZE_UNKNOWN); 270 const char* source, size_t srclen = SIZE_UNKNOWN);
271 271
272 #endif // WEBRTC_WIN 272 #endif // WEBRTC_WIN
273 273
274 /////////////////////////////////////////////////////////////////////////////// 274 ///////////////////////////////////////////////////////////////////////////////
275 // Traits<char> specializations 275 // Traits<char> specializations
276 /////////////////////////////////////////////////////////////////////////////// 276 ///////////////////////////////////////////////////////////////////////////////
277 277
278 template<> 278 template<>
279 struct Traits<char> { 279 struct Traits<char> {
280 typedef std::string string; 280 typedef std::string string;
281 inline static const char* empty_str() { return ""; } 281 inline static const char* empty_str() { return ""; }
282 }; 282 };
283 283
284 /////////////////////////////////////////////////////////////////////////////// 284 ///////////////////////////////////////////////////////////////////////////////
285 // Traits<wchar_t> specializations (Windows only, currently) 285 // Traits<wchar_t> specializations (Windows only, currently)
286 /////////////////////////////////////////////////////////////////////////////// 286 ///////////////////////////////////////////////////////////////////////////////
287 287
288 #if defined(WEBRTC_WIN) 288 #if defined(WEBRTC_WIN)
289 289
290 template<> 290 template<>
291 struct Traits<wchar_t> { 291 struct Traits<wchar_t> {
292 typedef std::wstring string; 292 typedef std::wstring string;
293 inline static const wchar_t* empty_str() { return L""; } 293 inline static const wchar_t* empty_str() { return L""; }
294 }; 294 };
295 295
296 #endif // WEBRTC_WIN 296 #endif // WEBRTC_WIN
297 297
298 // Replaces all occurrences of "search" with "replace". 298 // Replaces all occurrences of "search" with "replace".
299 void replace_substrs(const char *search, 299 void replace_substrs(const char *search,
300 size_t search_len, 300 size_t search_len,
301 const char *replace, 301 const char *replace,
302 size_t replace_len, 302 size_t replace_len,
303 std::string *s); 303 std::string *s);
304 304
305 // True iff s1 starts with s2. 305 // True iff s1 starts with s2.
306 bool starts_with(const char *s1, const char *s2); 306 bool starts_with(const char *s1, const char *s2);
307 307
308 // True iff s1 ends with s2. 308 // True iff s1 ends with s2.
309 bool ends_with(const char *s1, const char *s2); 309 bool ends_with(const char *s1, const char *s2);
310 310
311 // Remove leading and trailing whitespaces. 311 // Remove leading and trailing whitespaces.
312 std::string string_trim(const std::string& s); 312 std::string string_trim(const std::string& s);
313 313
314 } // namespace rtc 314 } // namespace rtc
315 315
316 #endif // WEBRTC_BASE_STRINGUTILS_H__ 316 #endif // WEBRTC_RTC_BASE_STRINGUTILS_H_
OLDNEW
« no previous file with comments | « webrtc/rtc_base/stringize_macros_unittest.cc ('k') | webrtc/rtc_base/stringutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698