| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 9 #pragma once |
| 10 | 10 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 }; | 410 }; |
| 411 | 411 |
| 412 // Return the unit type that is appropriate for displaying the amount of bytes | 412 // Return the unit type that is appropriate for displaying the amount of bytes |
| 413 // passed in. | 413 // passed in. |
| 414 DataUnits GetByteDisplayUnits(int64 bytes); | 414 DataUnits GetByteDisplayUnits(int64 bytes); |
| 415 | 415 |
| 416 // Return a byte string in human-readable format, displayed in units appropriate | 416 // Return a byte string in human-readable format, displayed in units appropriate |
| 417 // specified by 'units', with an optional unit suffix. | 417 // specified by 'units', with an optional unit suffix. |
| 418 // Ex: FormatBytes(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB" | 418 // Ex: FormatBytes(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB" |
| 419 // Ex: FormatBytes(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" | 419 // Ex: FormatBytes(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" |
| 420 std::wstring FormatBytes(int64 bytes, DataUnits units, bool show_units); | 420 string16 FormatBytes(int64 bytes, DataUnits units, bool show_units); |
| 421 | 421 |
| 422 // As above, but with "/s" units. | 422 // As above, but with "/s" units. |
| 423 // Ex: FormatSpeed(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB/s" | 423 // Ex: FormatSpeed(512, DATA_UNITS_KIBIBYTE, true) => "0.5 KB/s" |
| 424 // Ex: FormatSpeed(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" | 424 // Ex: FormatSpeed(10*1024, DATA_UNITS_MEBIBYTE, false) => "0.1" |
| 425 std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units); | 425 string16 FormatSpeed(int64 bytes, DataUnits units, bool show_units); |
| 426 | 426 |
| 427 // Return a number formated with separators in the user's locale way. | 427 // Return a number formated with separators in the user's locale way. |
| 428 // Ex: FormatNumber(1234567) => 1,234,567 | 428 // Ex: FormatNumber(1234567) => 1,234,567 |
| 429 std::wstring FormatNumber(int64 number); | 429 string16 FormatNumber(int64 number); |
| 430 | 430 |
| 431 // Starting at |start_offset| (usually 0), replace the first instance of | 431 // Starting at |start_offset| (usually 0), replace the first instance of |
| 432 // |find_this| with |replace_with|. | 432 // |find_this| with |replace_with|. |
| 433 void ReplaceFirstSubstringAfterOffset(string16* str, | 433 void ReplaceFirstSubstringAfterOffset(string16* str, |
| 434 string16::size_type start_offset, | 434 string16::size_type start_offset, |
| 435 const string16& find_this, | 435 const string16& find_this, |
| 436 const string16& replace_with); | 436 const string16& replace_with); |
| 437 void ReplaceFirstSubstringAfterOffset(std::string* str, | 437 void ReplaceFirstSubstringAfterOffset(std::string* str, |
| 438 std::string::size_type start_offset, | 438 std::string::size_type start_offset, |
| 439 const std::string& find_this, | 439 const std::string& find_this, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 #elif defined(WCHAR_T_IS_UTF32) | 625 #elif defined(WCHAR_T_IS_UTF32) |
| 626 typedef uint32 Unsigned; | 626 typedef uint32 Unsigned; |
| 627 #endif | 627 #endif |
| 628 }; | 628 }; |
| 629 template<> | 629 template<> |
| 630 struct ToUnsigned<short> { | 630 struct ToUnsigned<short> { |
| 631 typedef unsigned short Unsigned; | 631 typedef unsigned short Unsigned; |
| 632 }; | 632 }; |
| 633 | 633 |
| 634 #endif // BASE_STRING_UTIL_H_ | 634 #endif // BASE_STRING_UTIL_H_ |
| OLD | NEW |