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

Side by Side Diff: base/string_util.h

Issue 3107021: Convert FormatBytes to string16. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | base/string_util.cc » ('j') | chrome/browser/download/download_item_model.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | base/string_util.cc » ('j') | chrome/browser/download/download_item_model.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698