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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 374 |
375 // DEPRECATED. Returns true if str starts/ends with search, or false otherwise. | 375 // DEPRECATED. Returns true if str starts/ends with search, or false otherwise. |
376 // TODO(brettw) remove in favor of the "enum" versions above. | 376 // TODO(brettw) remove in favor of the "enum" versions above. |
377 inline bool StartsWithASCII(const std::string& str, | 377 inline bool StartsWithASCII(const std::string& str, |
378 const std::string& search, | 378 const std::string& search, |
379 bool case_sensitive) { | 379 bool case_sensitive) { |
380 return StartsWith(StringPiece(str), StringPiece(search), | 380 return StartsWith(StringPiece(str), StringPiece(search), |
381 case_sensitive ? CompareCase::SENSITIVE | 381 case_sensitive ? CompareCase::SENSITIVE |
382 : CompareCase::INSENSITIVE_ASCII); | 382 : CompareCase::INSENSITIVE_ASCII); |
383 } | 383 } |
| 384 BASE_EXPORT bool StartsWith(const string16& str, |
| 385 const string16& search, |
| 386 bool case_sensitive); |
| 387 inline bool EndsWith(const std::string& str, |
| 388 const std::string& search, |
| 389 bool case_sensitive) { |
| 390 return EndsWith(StringPiece(str), StringPiece(search), |
| 391 case_sensitive ? CompareCase::SENSITIVE |
| 392 : CompareCase::INSENSITIVE_ASCII); |
| 393 } |
| 394 BASE_EXPORT bool EndsWith(const string16& str, |
| 395 const string16& search, |
| 396 bool case_sensitive); |
384 | 397 |
385 // Determines the type of ASCII character, independent of locale (the C | 398 // Determines the type of ASCII character, independent of locale (the C |
386 // library versions will change based on locale). | 399 // library versions will change based on locale). |
387 template <typename Char> | 400 template <typename Char> |
388 inline bool IsAsciiWhitespace(Char c) { | 401 inline bool IsAsciiWhitespace(Char c) { |
389 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; | 402 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; |
390 } | 403 } |
391 template <typename Char> | 404 template <typename Char> |
392 inline bool IsAsciiAlpha(Char c) { | 405 inline bool IsAsciiAlpha(Char c) { |
393 return ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')); | 406 return ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 520 |
508 #if defined(OS_WIN) | 521 #if defined(OS_WIN) |
509 #include "base/strings/string_util_win.h" | 522 #include "base/strings/string_util_win.h" |
510 #elif defined(OS_POSIX) | 523 #elif defined(OS_POSIX) |
511 #include "base/strings/string_util_posix.h" | 524 #include "base/strings/string_util_posix.h" |
512 #else | 525 #else |
513 #error Define string operations appropriately for your platform | 526 #error Define string operations appropriately for your platform |
514 #endif | 527 #endif |
515 | 528 |
516 #endif // BASE_STRINGS_STRING_UTIL_H_ | 529 #endif // BASE_STRINGS_STRING_UTIL_H_ |
OLD | NEW |