OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file defines utility functions for working with strings. | 5 // This file defines utility functions for working with strings. |
6 | 6 |
7 #ifndef BASE_STRINGS_STRING_UTIL_H_ | 7 #ifndef BASE_STRINGS_STRING_UTIL_H_ |
8 #define BASE_STRINGS_STRING_UTIL_H_ | 8 #define BASE_STRINGS_STRING_UTIL_H_ |
9 | 9 |
10 #include <ctype.h> | 10 #include <ctype.h> |
11 #include <stdarg.h> // va_list | 11 #include <stdarg.h> // va_list |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/base_export.h" | 16 #include "base/base_export.h" |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/string16.h" | 19 #include "base/strings/string16.h" |
20 #include "base/strings/string_piece.h" // For implicit conversions. | 20 #include "base/strings/string_piece.h" // For implicit conversions. |
21 | 21 |
22 // Safe standard library wrappers for all platforms. | 22 // Safe standard library wrappers for all platforms. |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 | 25 |
26 // C standard-library functions like "strncasecmp" and "snprintf" that aren't | 26 // C standard-library functions like "strncasecmp" and "snprintf" that aren't |
27 // cross-platform are provided as "base::strncasecmp", and their prototypes | 27 // cross-platform are provided as "base::strncasecmp", and their prototypes |
28 // are listed below. These functions are then implemented as inline calls | 28 // are listed below. These functions are then implemented as inline calls |
29 // to the platform-specific equivalents in the platform-specific headers. | 29 // to the platform-specific equivalents in the platform-specific headers. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 template<typename Char> struct CaseInsensitiveCompareASCII { | 139 template<typename Char> struct CaseInsensitiveCompareASCII { |
140 public: | 140 public: |
141 bool operator()(Char x, Char y) const { | 141 bool operator()(Char x, Char y) const { |
142 return ToLowerASCII(x) == ToLowerASCII(y); | 142 return ToLowerASCII(x) == ToLowerASCII(y); |
143 } | 143 } |
144 }; | 144 }; |
145 | 145 |
146 } // namespace base | 146 } // namespace base |
147 | 147 |
148 #if defined(OS_WIN) | 148 #if defined(OS_WIN) |
149 #include "base/string_util_win.h" | 149 #include "base/strings/string_util_win.h" |
150 #elif defined(OS_POSIX) | 150 #elif defined(OS_POSIX) |
151 #include "base/string_util_posix.h" | 151 #include "base/strings/string_util_posix.h" |
152 #else | 152 #else |
153 #error Define string operations appropriately for your platform | 153 #error Define string operations appropriately for your platform |
154 #endif | 154 #endif |
155 | 155 |
156 // These threadsafe functions return references to globally unique empty | 156 // These threadsafe functions return references to globally unique empty |
157 // strings. | 157 // strings. |
158 // | 158 // |
159 // DO NOT USE THESE AS A GENERAL-PURPOSE SUBSTITUTE FOR DEFAULT CONSTRUCTORS. | 159 // DO NOT USE THESE AS A GENERAL-PURPOSE SUBSTITUTE FOR DEFAULT CONSTRUCTORS. |
160 // There is only one case where you should use these: functions which need to | 160 // There is only one case where you should use these: functions which need to |
161 // return a string by reference (e.g. as a class member accessor), and don't | 161 // return a string by reference (e.g. as a class member accessor), and don't |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 #elif defined(WCHAR_T_IS_UTF32) | 567 #elif defined(WCHAR_T_IS_UTF32) |
568 typedef uint32 Unsigned; | 568 typedef uint32 Unsigned; |
569 #endif | 569 #endif |
570 }; | 570 }; |
571 template<> | 571 template<> |
572 struct ToUnsigned<short> { | 572 struct ToUnsigned<short> { |
573 typedef unsigned short Unsigned; | 573 typedef unsigned short Unsigned; |
574 }; | 574 }; |
575 | 575 |
576 #endif // BASE_STRINGS_STRING_UTIL_H_ | 576 #endif // BASE_STRINGS_STRING_UTIL_H_ |
OLD | NEW |