Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: base/string_util.h

Issue 31014: Port DictionaryValue to use string16 instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/json_writer_unittest.cc ('k') | base/string_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_STRING_UTIL_H_ 7 #ifndef BASE_STRING_UTIL_H_
8 #define BASE_STRING_UTIL_H_ 8 #define BASE_STRING_UTIL_H_
9 9
10 #include <stdarg.h> // va_list 10 #include <stdarg.h> // va_list
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 bool UTF8ToUTF16(const char* src, size_t src_len, string16* output); 182 bool UTF8ToUTF16(const char* src, size_t src_len, string16* output);
183 string16 UTF8ToUTF16(const std::string& utf8); 183 string16 UTF8ToUTF16(const std::string& utf8);
184 bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output); 184 bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output);
185 std::string UTF16ToUTF8(const string16& utf16); 185 std::string UTF16ToUTF8(const string16& utf16);
186 186
187 // We are trying to get rid of wstring as much as possible, but it's too big 187 // We are trying to get rid of wstring as much as possible, but it's too big
188 // a mess to do it all at once. These conversions should be used when we 188 // a mess to do it all at once. These conversions should be used when we
189 // really should just be passing a string16 around, but we haven't finished 189 // really should just be passing a string16 around, but we haven't finished
190 // porting whatever module uses wstring and the conversion is being used as a 190 // porting whatever module uses wstring and the conversion is being used as a
191 // stopcock. This makes it easy to grep for the ones that should be removed. 191 // stopcock. This makes it easy to grep for the ones that should be removed.
192 #if defined(OS_WIN) 192 #if defined(WCHAR_T_IS_UTF16)
193 # define WideToUTF16Hack 193 # define WideToUTF16Hack
194 # define UTF16ToWideHack 194 # define UTF16ToWideHack
195 #else 195 #else
196 # define WideToUTF16Hack WideToUTF16 196 # define WideToUTF16Hack WideToUTF16
197 # define UTF16ToWideHack UTF16ToWide 197 # define UTF16ToWideHack UTF16ToWide
198 #endif 198 #endif
199 199
200 // Defines the error handling modes of WideToCodepage and CodepageToWide. 200 // Defines the error handling modes of WideToCodepage and CodepageToWide.
201 class OnStringUtilConversionError { 201 class OnStringUtilConversionError {
202 public: 202 public:
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 string16::size_type start_offset, 378 string16::size_type start_offset,
379 const string16& find_this, 379 const string16& find_this,
380 const string16& replace_with); 380 const string16& replace_with);
381 void ReplaceSubstringsAfterOffset(std::string* str, 381 void ReplaceSubstringsAfterOffset(std::string* str,
382 std::string::size_type start_offset, 382 std::string::size_type start_offset,
383 const std::string& find_this, 383 const std::string& find_this,
384 const std::string& replace_with); 384 const std::string& replace_with);
385 385
386 // Specialized string-conversion functions. 386 // Specialized string-conversion functions.
387 std::string IntToString(int value); 387 std::string IntToString(int value);
388 string16 IntToString16(int value);
388 std::wstring IntToWString(int value); 389 std::wstring IntToWString(int value);
389 std::string UintToString(unsigned int value); 390 std::string UintToString(unsigned int value);
391 string16 UintToString16(unsigned int value);
390 std::wstring UintToWString(unsigned int value); 392 std::wstring UintToWString(unsigned int value);
391 std::string Int64ToString(int64 value); 393 std::string Int64ToString(int64 value);
394 string16 Int64ToString16(int64 value);
392 std::wstring Int64ToWString(int64 value); 395 std::wstring Int64ToWString(int64 value);
393 std::string Uint64ToString(uint64 value); 396 std::string Uint64ToString(uint64 value);
397 string16 Uint64ToString16(uint64 value);
394 std::wstring Uint64ToWString(uint64 value); 398 std::wstring Uint64ToWString(uint64 value);
395 // The DoubleToString methods convert the double to a string format that 399 // The DoubleToString methods convert the double to a string format that
396 // ignores the locale. If you want to use locale specific formatting, use ICU. 400 // ignores the locale. If you want to use locale specific formatting, use ICU.
397 std::string DoubleToString(double value); 401 std::string DoubleToString(double value);
402 string16 DoubleToString16(double value);
398 std::wstring DoubleToWString(double value); 403 std::wstring DoubleToWString(double value);
399 404
400 // Perform a best-effort conversion of the input string to a numeric type, 405 // Perform a best-effort conversion of the input string to a numeric type,
401 // setting |*output| to the result of the conversion. Returns true for 406 // setting |*output| to the result of the conversion. Returns true for
402 // "perfect" conversions; returns false in the following cases: 407 // "perfect" conversions; returns false in the following cases:
403 // - Overflow/underflow. |*output| will be set to the maximum value supported 408 // - Overflow/underflow. |*output| will be set to the maximum value supported
404 // by the data type. 409 // by the data type.
405 // - Trailing characters in the string after parsing the number. |*output| 410 // - Trailing characters in the string after parsing the number. |*output|
406 // will be set to the value of the number that was parsed. 411 // will be set to the value of the number that was parsed.
407 // - No characters parseable as a number at the beginning of the string. 412 // - No characters parseable as a number at the beginning of the string.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 // Returns a hex string representation of a binary buffer. 595 // Returns a hex string representation of a binary buffer.
591 // The returned hex string will be in upper case. 596 // The returned hex string will be in upper case.
592 // This function does not check if |size| is within reasonable limits since 597 // This function does not check if |size| is within reasonable limits since
593 // it's written with trusted data in mind. 598 // it's written with trusted data in mind.
594 // If you suspect that the data you want to format might be large, 599 // If you suspect that the data you want to format might be large,
595 // the absolute max size for |size| should be is 600 // the absolute max size for |size| should be is
596 // std::numeric_limits<size_t>::max() / 2 601 // std::numeric_limits<size_t>::max() / 2
597 std::string HexEncode(const void* bytes, size_t size); 602 std::string HexEncode(const void* bytes, size_t size);
598 603
599 #endif // BASE_STRING_UTIL_H_ 604 #endif // BASE_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « base/json_writer_unittest.cc ('k') | base/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698