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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 BASE_EXPORT bool StartsWith(StringPiece16 str, | 365 BASE_EXPORT bool StartsWith(StringPiece16 str, |
366 StringPiece16 search_for, | 366 StringPiece16 search_for, |
367 CompareCase case_sensitivity); | 367 CompareCase case_sensitivity); |
368 BASE_EXPORT bool EndsWith(StringPiece str, | 368 BASE_EXPORT bool EndsWith(StringPiece str, |
369 StringPiece search_for, | 369 StringPiece search_for, |
370 CompareCase case_sensitivity); | 370 CompareCase case_sensitivity); |
371 BASE_EXPORT bool EndsWith(StringPiece16 str, | 371 BASE_EXPORT bool EndsWith(StringPiece16 str, |
372 StringPiece16 search_for, | 372 StringPiece16 search_for, |
373 CompareCase case_sensitivity); | 373 CompareCase case_sensitivity); |
374 | 374 |
375 // DEPRECATED. Returns true if str starts/ends with search, or false otherwise. | |
376 // TODO(brettw) remove in favor of the "enum" versions above. | |
377 inline bool StartsWithASCII(const std::string& str, | |
378 const std::string& search, | |
379 bool case_sensitive) { | |
380 return StartsWith(StringPiece(str), StringPiece(search), | |
381 case_sensitive ? CompareCase::SENSITIVE | |
382 : CompareCase::INSENSITIVE_ASCII); | |
383 } | |
384 | |
385 // Determines the type of ASCII character, independent of locale (the C | 375 // Determines the type of ASCII character, independent of locale (the C |
386 // library versions will change based on locale). | 376 // library versions will change based on locale). |
387 template <typename Char> | 377 template <typename Char> |
388 inline bool IsAsciiWhitespace(Char c) { | 378 inline bool IsAsciiWhitespace(Char c) { |
389 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; | 379 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; |
390 } | 380 } |
391 template <typename Char> | 381 template <typename Char> |
392 inline bool IsAsciiAlpha(Char c) { | 382 inline bool IsAsciiAlpha(Char c) { |
393 return ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')); | 383 return ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')); |
394 } | 384 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 497 |
508 #if defined(OS_WIN) | 498 #if defined(OS_WIN) |
509 #include "base/strings/string_util_win.h" | 499 #include "base/strings/string_util_win.h" |
510 #elif defined(OS_POSIX) | 500 #elif defined(OS_POSIX) |
511 #include "base/strings/string_util_posix.h" | 501 #include "base/strings/string_util_posix.h" |
512 #else | 502 #else |
513 #error Define string operations appropriately for your platform | 503 #error Define string operations appropriately for your platform |
514 #endif | 504 #endif |
515 | 505 |
516 #endif // BASE_STRINGS_STRING_UTIL_H_ | 506 #endif // BASE_STRINGS_STRING_UTIL_H_ |
OLD | NEW |