| 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> |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 BASE_EXPORT bool IsStringUTF8(const StringPiece& str); | 296 BASE_EXPORT bool IsStringUTF8(const StringPiece& str); |
| 297 BASE_EXPORT bool IsStringASCII(const StringPiece& str); | 297 BASE_EXPORT bool IsStringASCII(const StringPiece& str); |
| 298 BASE_EXPORT bool IsStringASCII(const StringPiece16& str); | 298 BASE_EXPORT bool IsStringASCII(const StringPiece16& str); |
| 299 // A convenience adaptor for WebStrings, as they don't convert into | 299 // A convenience adaptor for WebStrings, as they don't convert into |
| 300 // StringPieces directly. | 300 // StringPieces directly. |
| 301 BASE_EXPORT bool IsStringASCII(const string16& str); | 301 BASE_EXPORT bool IsStringASCII(const string16& str); |
| 302 #if defined(WCHAR_T_IS_UTF32) | 302 #if defined(WCHAR_T_IS_UTF32) |
| 303 BASE_EXPORT bool IsStringASCII(const std::wstring& str); | 303 BASE_EXPORT bool IsStringASCII(const std::wstring& str); |
| 304 #endif | 304 #endif |
| 305 | 305 |
| 306 // Converts the elements of the given string. This version uses a pointer to | |
| 307 // clearly differentiate it from the non-pointer variant. | |
| 308 // TODO(brettw) remove this. Callers should use base::ToLowerASCII above. | |
| 309 template <class str> inline void StringToLowerASCII(str* s) { | |
| 310 for (typename str::iterator i = s->begin(); i != s->end(); ++i) | |
| 311 *i = ToLowerASCII(*i); | |
| 312 } | |
| 313 | |
| 314 // TODO(brettw) remove this. Callers should use base::ToLowerASCII above. | |
| 315 template <class str> inline str StringToLowerASCII(const str& s) { | |
| 316 // for std::string and std::wstring | |
| 317 str output(s); | |
| 318 StringToLowerASCII(&output); | |
| 319 return output; | |
| 320 } | |
| 321 | |
| 322 // Compare the lower-case form of the given string against the given | 306 // Compare the lower-case form of the given string against the given |
| 323 // previously-lower-cased ASCII string (typically a constant). | 307 // previously-lower-cased ASCII string (typically a constant). |
| 324 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece str, | 308 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece str, |
| 325 StringPiece lowecase_ascii); | 309 StringPiece lowecase_ascii); |
| 326 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece16 str, | 310 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece16 str, |
| 327 StringPiece lowecase_ascii); | 311 StringPiece lowecase_ascii); |
| 328 | 312 |
| 329 // Performs a case-sensitive string compare of the given 16-bit string against | 313 // Performs a case-sensitive string compare of the given 16-bit string against |
| 330 // the given 8-bit ASCII string (typically a constant). The behavior is | 314 // the given 8-bit ASCII string (typically a constant). The behavior is |
| 331 // undefined if the |ascii| string is not ASCII. | 315 // undefined if the |ascii| string is not ASCII. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 466 |
| 483 #if defined(OS_WIN) | 467 #if defined(OS_WIN) |
| 484 #include "base/strings/string_util_win.h" | 468 #include "base/strings/string_util_win.h" |
| 485 #elif defined(OS_POSIX) | 469 #elif defined(OS_POSIX) |
| 486 #include "base/strings/string_util_posix.h" | 470 #include "base/strings/string_util_posix.h" |
| 487 #else | 471 #else |
| 488 #error Define string operations appropriately for your platform | 472 #error Define string operations appropriately for your platform |
| 489 #endif | 473 #endif |
| 490 | 474 |
| 491 #endif // BASE_STRINGS_STRING_UTIL_H_ | 475 #endif // BASE_STRINGS_STRING_UTIL_H_ |
| OLD | NEW |