OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_STRING_UTIL_H_ | 7 #ifndef BASE_STRING_UTIL_H_ |
8 #define BASE_STRING_UTIL_H_ | 8 #define BASE_STRING_UTIL_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 BASE_EXPORT const std::string& EmptyString(); | 166 BASE_EXPORT const std::string& EmptyString(); |
167 BASE_EXPORT const std::wstring& EmptyWString(); | 167 BASE_EXPORT const std::wstring& EmptyWString(); |
168 BASE_EXPORT const string16& EmptyString16(); | 168 BASE_EXPORT const string16& EmptyString16(); |
169 | 169 |
170 BASE_EXPORT extern const wchar_t kWhitespaceWide[]; | 170 BASE_EXPORT extern const wchar_t kWhitespaceWide[]; |
171 BASE_EXPORT extern const char16 kWhitespaceUTF16[]; | 171 BASE_EXPORT extern const char16 kWhitespaceUTF16[]; |
172 BASE_EXPORT extern const char kWhitespaceASCII[]; | 172 BASE_EXPORT extern const char kWhitespaceASCII[]; |
173 | 173 |
174 BASE_EXPORT extern const char kUtf8ByteOrderMark[]; | 174 BASE_EXPORT extern const char kUtf8ByteOrderMark[]; |
175 | 175 |
176 // Removes characters in |remove_chars| from anywhere in input. Returns true if | 176 // Removes characters in |remove_chars| from anywhere in |input|. Returns true |
177 // any characters were removed. |remove_chars| must be null-terminated. | 177 // if any characters were removed. |remove_chars| must be null-terminated. |
178 // NOTE: Safe to use the same variable for both input and output. | 178 // NOTE: Safe to use the same variable for both |input| and |output|. |
179 BASE_EXPORT bool RemoveChars(const string16& input, | 179 BASE_EXPORT bool RemoveChars(const string16& input, |
180 const char16 remove_chars[], | 180 const char16 remove_chars[], |
181 string16* output); | 181 string16* output); |
182 BASE_EXPORT bool RemoveChars(const std::string& input, | 182 BASE_EXPORT bool RemoveChars(const std::string& input, |
183 const char remove_chars[], | 183 const char remove_chars[], |
184 std::string* output); | 184 std::string* output); |
185 | 185 |
186 // Removes characters in |trim_chars| from the beginning and end of input. | 186 // Replaces characters in |replace_chars| from anywhere in |input| with |
| 187 // |replace_with|. Each character in |replace_chars| will be replaced with |
| 188 // the |replace_with| string. Returns true if any characters were replaced. |
| 189 // |replace_chars| must be null-terminated. |
| 190 // NOTE: Safe to use the same variable for both |input| and |output|. |
| 191 BASE_EXPORT bool ReplaceChars(const string16& input, |
| 192 const char16 replace_chars[], |
| 193 const string16& replace_with, |
| 194 string16* output); |
| 195 BASE_EXPORT bool ReplaceChars(const std::string& input, |
| 196 const char replace_chars[], |
| 197 const std::string& replace_with, |
| 198 std::string* output); |
| 199 |
| 200 // Removes characters in |trim_chars| from the beginning and end of |input|. |
187 // |trim_chars| must be null-terminated. | 201 // |trim_chars| must be null-terminated. |
188 // NOTE: Safe to use the same variable for both input and output. | 202 // NOTE: Safe to use the same variable for both |input| and |output|. |
189 BASE_EXPORT bool TrimString(const std::wstring& input, | 203 BASE_EXPORT bool TrimString(const std::wstring& input, |
190 const wchar_t trim_chars[], | 204 const wchar_t trim_chars[], |
191 std::wstring* output); | 205 std::wstring* output); |
192 BASE_EXPORT bool TrimString(const string16& input, | 206 BASE_EXPORT bool TrimString(const string16& input, |
193 const char16 trim_chars[], | 207 const char16 trim_chars[], |
194 string16* output); | 208 string16* output); |
195 BASE_EXPORT bool TrimString(const std::string& input, | 209 BASE_EXPORT bool TrimString(const std::string& input, |
196 const char trim_chars[], | 210 const char trim_chars[], |
197 std::string* output); | 211 std::string* output); |
198 | 212 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 #elif defined(WCHAR_T_IS_UTF32) | 568 #elif defined(WCHAR_T_IS_UTF32) |
555 typedef uint32 Unsigned; | 569 typedef uint32 Unsigned; |
556 #endif | 570 #endif |
557 }; | 571 }; |
558 template<> | 572 template<> |
559 struct ToUnsigned<short> { | 573 struct ToUnsigned<short> { |
560 typedef unsigned short Unsigned; | 574 typedef unsigned short Unsigned; |
561 }; | 575 }; |
562 | 576 |
563 #endif // BASE_STRING_UTIL_H_ | 577 #endif // BASE_STRING_UTIL_H_ |
OLD | NEW |