diff options
author | dsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 20:21:01 +0000 |
---|---|---|
committer | dsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 20:21:01 +0000 |
commit | 32c147158f76e19aa22efa2a7b14d3f0e1e23a02 (patch) | |
tree | a84b94bc6c2e4e52d009db317ed49a343658634c /base/string_util.cc | |
parent | 600a41fb05efe99eb2890e884a7af0541456c365 (diff) | |
download | chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.zip chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.tar.gz chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.tar.bz2 |
Port DictionaryValue to use string16 instead of wstring.
Review URL: http://codereview.chromium.org/31014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10818 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.cc')
-rw-r--r-- | base/string_util.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/base/string_util.cc b/base/string_util.cc index a13f79f..b845c45 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -1039,6 +1039,10 @@ std::string IntToString(int value) { return IntToStringT<std::string, int, unsigned int, true>:: IntToString(value); } +string16 IntToString16(int value) { + return IntToStringT<string16, int, unsigned int, true>:: + IntToString(value); +} std::wstring IntToWString(int value) { return IntToStringT<std::wstring, int, unsigned int, true>:: IntToString(value); @@ -1047,6 +1051,10 @@ std::string UintToString(unsigned int value) { return IntToStringT<std::string, unsigned int, unsigned int, false>:: IntToString(value); } +string16 UintToString16(unsigned int value) { + return IntToStringT<string16, unsigned int, unsigned int, false>:: + IntToString(value); +} std::wstring UintToWString(unsigned int value) { return IntToStringT<std::wstring, unsigned int, unsigned int, false>:: IntToString(value); @@ -1055,6 +1063,10 @@ std::string Int64ToString(int64 value) { return IntToStringT<std::string, int64, uint64, true>:: IntToString(value); } +string16 Int64ToString16(int64 value) { + return IntToStringT<string16, int64, uint64, true>:: + IntToString(value); +} std::wstring Int64ToWString(int64 value) { return IntToStringT<std::wstring, int64, uint64, true>:: IntToString(value); @@ -1063,6 +1075,10 @@ std::string Uint64ToString(uint64 value) { return IntToStringT<std::string, uint64, uint64, false>:: IntToString(value); } +string16 Uint64ToString16(uint64 value) { + return IntToStringT<string16, uint64, uint64, false>:: + IntToString(value); +} std::wstring Uint64ToWString(uint64 value) { return IntToStringT<std::wstring, uint64, uint64, false>:: IntToString(value); @@ -1075,6 +1091,10 @@ std::string DoubleToString(double value) { return std::string(buffer); } +string16 DoubleToWString16(double value) { + return UTF8ToUTF16(DoubleToString(value)); +} + std::wstring DoubleToWString(double value) { return ASCIIToWide(DoubleToString(value)); } @@ -1580,6 +1600,52 @@ double StringToDouble(const string16& value) { return result; } +#if !defined(WCHAR_T_IS_UTF16) +bool StringToInt(const string16& input, int* output) { + return StringToInt(UTF16ToWideHack(input), output); +} + +bool StringToInt64(const string16& input, int64* output) { + return StringToInt64(UTF16ToWideHack(input), output); +} + +bool HexStringToInt(const string16& input, int* output) { + return HexStringToInt(UTF16ToWideHack(input), output); +} + +int StringToInt(const string16& value) { + int result; + StringToInt(value, &result); + return result; +} + +int64 StringToInt64(const string16& value) { + int64 result; + StringToInt64(value, &result); + return result; +} + +int HexStringToInt(const string16& value) { + int result; + HexStringToInt(value, &result); + return result; +} + +bool StringToDouble(const string16& input, double* output) { + return StringToDouble(UTF16ToWideHack(input), output); +} + +double StringToDouble(const string16& value) { + double result; + StringToDouble(value, &result); + return result; +} + +bool HexStringToBytes(const string16& input, std::vector<uint8>* output) { + return HexStringToBytesT(input, output); +} +#endif // !defined(WCHAR_T_IS_UTF16) + // The following code is compatible with the OpenBSD lcpy interface. See: // http://www.gratisoft.us/todd/papers/strlcpy.html // ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/{wcs,str}lcpy.c |