diff options
Diffstat (limited to 'base/strings/string_util.h')
-rw-r--r-- | base/strings/string_util.h | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/base/strings/string_util.h b/base/strings/string_util.h index 2b6316b..a6ee815 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -123,34 +123,41 @@ template<typename Char> struct CaseInsensitiveCompareASCII { } }; -} // namespace base - -#if defined(OS_WIN) -#include "base/strings/string_util_win.h" -#elif defined(OS_POSIX) -#include "base/strings/string_util_posix.h" -#else -#error Define string operations appropriately for your platform -#endif - // These threadsafe functions return references to globally unique empty // strings. // -// DO NOT USE THESE AS A GENERAL-PURPOSE SUBSTITUTE FOR DEFAULT CONSTRUCTORS. -// There is only one case where you should use these: functions which need to -// return a string by reference (e.g. as a class member accessor), and don't -// have an empty string to use (e.g. in an error case). These should not be -// used as initializers, function arguments, or return values for functions -// which return by value or outparam. +// It is likely faster to construct a new empty string object (just a few +// instructions to set the length to 0) than to get the empty string singleton +// returned by these functions (which requires threadsafe singleton access). +// +// Therefore, DO NOT USE THESE AS A GENERAL-PURPOSE SUBSTITUTE FOR DEFAULT +// CONSTRUCTORS. There is only one case where you should use these: functions +// which need to return a string by reference (e.g. as a class member +// accessor), and don't have an empty string to use (e.g. in an error case). +// These should not be used as initializers, function arguments, or return +// values for functions which return by value or outparam. BASE_EXPORT const std::string& EmptyString(); BASE_EXPORT const string16& EmptyString16(); +// Contains the set of characters representing whitespace in the corresponding +// encoding. Null-terminated. BASE_EXPORT extern const wchar_t kWhitespaceWide[]; BASE_EXPORT extern const char16 kWhitespaceUTF16[]; BASE_EXPORT extern const char kWhitespaceASCII[]; +// Null-terminated string representing the UTF-8 byte order mark. BASE_EXPORT extern const char kUtf8ByteOrderMark[]; +} // namespace base + +#if defined(OS_WIN) +#include "base/strings/string_util_win.h" +#elif defined(OS_POSIX) +#include "base/strings/string_util_posix.h" +#else +#error Define string operations appropriately for your platform +#endif + // Removes characters in |remove_chars| from anywhere in |input|. Returns true // if any characters were removed. |remove_chars| must be null-terminated. // NOTE: Safe to use the same variable for both |input| and |output|. @@ -370,7 +377,7 @@ inline Char HexDigitToInt(Char c) { // Returns true if it's a whitespace character. inline bool IsWhitespace(wchar_t c) { - return wcschr(kWhitespaceWide, c) != NULL; + return wcschr(base::kWhitespaceWide, c) != NULL; } // Return a byte string in human-readable format with a unit suffix. Not |