| 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> |
| 11 #include <stdarg.h> // va_list | 11 #include <stdarg.h> // va_list |
| 12 #include <stddef.h> |
| 13 #include <stdint.h> |
| 12 | 14 |
| 13 #include <string> | 15 #include <string> |
| 14 #include <vector> | 16 #include <vector> |
| 15 | 17 |
| 16 #include "base/base_export.h" | 18 #include "base/base_export.h" |
| 17 #include "base/basictypes.h" | |
| 18 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
| 19 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 20 #include "base/strings/string_piece.h" // For implicit conversions. | 21 #include "base/strings/string_piece.h" // For implicit conversions. |
| 22 #include "build/build_config.h" |
| 21 | 23 |
| 22 namespace base { | 24 namespace base { |
| 23 | 25 |
| 24 // C standard-library functions that aren't cross-platform are provided as | 26 // C standard-library functions that aren't cross-platform are provided as |
| 25 // "base::...", and their prototypes are listed below. These functions are | 27 // "base::...", and their prototypes are listed below. These functions are |
| 26 // then implemented as inline calls to the platform-specific equivalents in the | 28 // then implemented as inline calls to the platform-specific equivalents in the |
| 27 // platform-specific headers. | 29 // platform-specific headers. |
| 28 | 30 |
| 29 // Wrapper for vsnprintf that always null-terminates and always returns the | 31 // Wrapper for vsnprintf that always null-terminates and always returns the |
| 30 // number of characters that would be in an untruncated formatted | 32 // number of characters that would be in an untruncated formatted |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 // Assumes the input is a valid hex character. DCHECKs in debug builds if not. | 358 // Assumes the input is a valid hex character. DCHECKs in debug builds if not. |
| 357 BASE_EXPORT char HexDigitToInt(wchar_t c); | 359 BASE_EXPORT char HexDigitToInt(wchar_t c); |
| 358 | 360 |
| 359 // Returns true if it's a Unicode whitespace character. | 361 // Returns true if it's a Unicode whitespace character. |
| 360 BASE_EXPORT bool IsUnicodeWhitespace(wchar_t c); | 362 BASE_EXPORT bool IsUnicodeWhitespace(wchar_t c); |
| 361 | 363 |
| 362 // Return a byte string in human-readable format with a unit suffix. Not | 364 // Return a byte string in human-readable format with a unit suffix. Not |
| 363 // appropriate for use in any UI; use of FormatBytes and friends in ui/base is | 365 // appropriate for use in any UI; use of FormatBytes and friends in ui/base is |
| 364 // highly recommended instead. TODO(avi): Figure out how to get callers to use | 366 // highly recommended instead. TODO(avi): Figure out how to get callers to use |
| 365 // FormatBytes instead; remove this. | 367 // FormatBytes instead; remove this. |
| 366 BASE_EXPORT string16 FormatBytesUnlocalized(int64 bytes); | 368 BASE_EXPORT string16 FormatBytesUnlocalized(int64_t bytes); |
| 367 | 369 |
| 368 // Starting at |start_offset| (usually 0), replace the first instance of | 370 // Starting at |start_offset| (usually 0), replace the first instance of |
| 369 // |find_this| with |replace_with|. | 371 // |find_this| with |replace_with|. |
| 370 BASE_EXPORT void ReplaceFirstSubstringAfterOffset( | 372 BASE_EXPORT void ReplaceFirstSubstringAfterOffset( |
| 371 base::string16* str, | 373 base::string16* str, |
| 372 size_t start_offset, | 374 size_t start_offset, |
| 373 StringPiece16 find_this, | 375 StringPiece16 find_this, |
| 374 StringPiece16 replace_with); | 376 StringPiece16 replace_with); |
| 375 BASE_EXPORT void ReplaceFirstSubstringAfterOffset( | 377 BASE_EXPORT void ReplaceFirstSubstringAfterOffset( |
| 376 std::string* str, | 378 std::string* str, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 452 |
| 451 #if defined(OS_WIN) | 453 #if defined(OS_WIN) |
| 452 #include "base/strings/string_util_win.h" | 454 #include "base/strings/string_util_win.h" |
| 453 #elif defined(OS_POSIX) | 455 #elif defined(OS_POSIX) |
| 454 #include "base/strings/string_util_posix.h" | 456 #include "base/strings/string_util_posix.h" |
| 455 #else | 457 #else |
| 456 #error Define string operations appropriately for your platform | 458 #error Define string operations appropriately for your platform |
| 457 #endif | 459 #endif |
| 458 | 460 |
| 459 #endif // BASE_STRINGS_STRING_UTIL_H_ | 461 #endif // BASE_STRINGS_STRING_UTIL_H_ |
| OLD | NEW |