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); | |
397 | 384 |
398 // Determines the type of ASCII character, independent of locale (the C | 385 // Determines the type of ASCII character, independent of locale (the C |
399 // library versions will change based on locale). | 386 // library versions will change based on locale). |
400 template <typename Char> | 387 template <typename Char> |
401 inline bool IsAsciiWhitespace(Char c) { | 388 inline bool IsAsciiWhitespace(Char c) { |
402 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; | 389 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; |
403 } | 390 } |
404 template <typename Char> | 391 template <typename Char> |
405 inline bool IsAsciiAlpha(Char c) { | 392 inline bool IsAsciiAlpha(Char c) { |
406 return ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')); | 393 return ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 507 |
521 #if defined(OS_WIN) | 508 #if defined(OS_WIN) |
522 #include "base/strings/string_util_win.h" | 509 #include "base/strings/string_util_win.h" |
523 #elif defined(OS_POSIX) | 510 #elif defined(OS_POSIX) |
524 #include "base/strings/string_util_posix.h" | 511 #include "base/strings/string_util_posix.h" |
525 #else | 512 #else |
526 #error Define string operations appropriately for your platform | 513 #error Define string operations appropriately for your platform |
527 #endif | 514 #endif |
528 | 515 |
529 #endif // BASE_STRINGS_STRING_UTIL_H_ | 516 #endif // BASE_STRINGS_STRING_UTIL_H_ |
OLD | NEW |