foobar2000 SDK  2015-01-14
Public Member Functions | Private Attributes
pfc::format_file_size_short

#include <string_base.h>

+ Inheritance diagram for pfc::format_file_size_short:

Public Member Functions

 format_file_size_short (t_uint64 size)
 
t_uint64 get_used_scale () const
 
- Public Member Functions inherited from pfc::string8_t< t_alloc >
 string8_t ()
 
 string8_t (const char *p_string)
 
 string8_t (const char *p_string, t_size p_length)
 
 string8_t (const t_self &p_string)
 
 string8_t (const string_base &p_string)
 
 string8_t (string_part_ref ref)
 
void add_string (const char *p_string, t_size p_length=~0)
 
void add_string (string_part_ref ref)
 
void add_string_ (const char *str)
 
void add_string_nc (const char *ptr, t_size len)
 
void fix_filename_chars (char def= '_', char leave=0)
 
void force_reset ()
 
t_size get_length () const throw ()
 
const char * get_ptr () const throw ()
 
void insert_chars (t_size first, const char *src, t_size count)
 
void insert_chars (t_size first, const char *src)
 
char * lock_buffer (t_size n)
 
 operator const char * () const throw ()
 
const t_selfoperator+= (const char *src)
 
const t_selfoperator+= (const string_base &src)
 
const t_selfoperator+= (const t_self &src)
 
const t_selfoperator+= (string_part_ref src)
 
const t_selfoperator= (const char *src)
 
const t_selfoperator= (const string_base &src)
 
const t_selfoperator= (const t_self &src)
 
const t_selfoperator= (string_part_ref src)
 
void prealloc (t_size p_size)
 
void remove_chars (t_size first, t_size count)
 
t_size replace_byte (char c1, char c2, t_size start=0)
 
t_size replace_char (unsigned c1, unsigned c2, t_size start=0)
 
t_size replace_nontext_chars (char p_replace= '_')
 
void set_char (unsigned offset, char c)
 
void set_string (const char *p_string, t_size p_length=~0)
 
void set_string (string_part_ref ref)
 
void set_string_ (const char *str)
 
void set_string_nc (const char *ptr, t_size len)
 
void truncate (t_size len)
 
void unlock_buffer ()
 
- Public Member Functions inherited from pfc::string_base
string_base_formatter () const
 
void add_filename (const char *fn)
 
void convert_to_lower_ascii (const char *src, char replace= '?')
 
void delimit (const char *c)
 
void end_with (char c)
 
void end_with_slash ()
 
bool ends_with (char c) const
 
t_size find_first (char p_char, t_size p_start=0) const
 
t_size find_first (const char *p_string, t_size p_start=0) const
 
t_size find_last (char p_char, t_size p_start=~0) const
 
t_size find_last (const char *p_string, t_size p_start=~0) const
 
void fix_dir_separator (char c= '\\')
 
bool fix_eol (const char *append=" (...)", t_size start=0)
 
bool has_prefix (const char *prefix) const
 
bool has_prefix_i (const char *prefix) const
 
bool has_suffix (const char *suffix) const
 
bool has_suffix_i (const char *suffix) const
 
bool is_empty () const
 
bool is_valid_utf8 () const
 
char last_char () const
 
t_size length () const
 
bool limit_length (t_size length_in_chars, const char *append=" (...)")
 
 operator const char * () const
 
bool operator!= (const string_base &p_other) const
 
const string_baseoperator+= (const char *src)
 
const string_baseoperator+= (const string_base &src)
 
bool operator< (const string_base &p_other) const
 
bool operator<= (const string_base &p_other) const
 
const string_baseoperator= (const char *src)
 
const string_baseoperator= (const string_base &src)
 
bool operator== (const string_base &p_other) const
 
bool operator> (const string_base &p_other) const
 
bool operator>= (const string_base &p_other) const
 
t_size replace_string (const char *replace, const char *replaceWith, t_size start=0)
 
void reset ()
 
t_size scan_filename () const
 
void set_string_ (const char *str)
 
void skip_trailing_char (unsigned c= ' ')
 
const char * toString () const
 
bool truncate_eol (t_size start=0)
 
void truncate_filename ()
 
void truncate_last_char ()
 
void truncate_number_suffix ()
 
void truncate_to_parent_path ()
 
- Public Member Functions inherited from pfc::string_receiver
void add_byte (char c)
 
void add_char (t_uint32 c)
 
void add_chars (t_uint32 p_char, t_size p_count)
 
void add_string_ (const char *str)
 

Private Attributes

t_uint64 m_scale
 

Additional Inherited Members

- Static Public Member Functions inherited from pfc::string8_t< t_alloc >
static void g_swap (t_self &p_item1, t_self &p_item2)
 
- Protected Member Functions inherited from pfc::string8_t< t_alloc >
const char * _get_ptr () const throw ()
 
void makespace (t_size s)
 
- Protected Member Functions inherited from pfc::string_base
 string_base ()
 
 ~string_base ()
 
- Protected Member Functions inherited from pfc::string_receiver
 string_receiver ()
 
 ~string_receiver ()
 
- Protected Attributes inherited from pfc::string8_t< t_alloc >
pfc::array_t< char, t_alloc > m_data
 
t_size used
 

Detailed Description

Definition at line 713 of file string_base.h.

Constructor & Destructor Documentation

pfc::format_file_size_short::format_file_size_short ( t_uint64  size)

Definition at line 947 of file string_base.cpp.

947  {
948  t_uint64 scale = 1;
949  const char * unit = "B";
950  const char * const unitTable[] = {"B","KB","MB","GB","TB"};
951  for(t_size walk = 1; walk < PFC_TABSIZE(unitTable); ++walk) {
952  t_uint64 next = scale * 1024;
953  if (size < next) break;
954  scale = next; unit = unitTable[walk];
955  }
956  *this << ( size / scale );
957 
958  if (scale > 1 && length() < 3) {
959  t_size digits = 3 - length();
960  const t_uint64 mask = pow_int(10,digits);
961  t_uint64 remaining = ( (size * mask / scale) % mask );
962  while(digits > 0 && (remaining % 10) == 0) {
963  remaining /= 10; --digits;
964  }
965  if (digits > 0) {
966  *this << "." << format_uint(remaining, (t_uint32)digits);
967  }
968  }
969  *this << " " << unit;
970  m_scale = scale;
971 }
t_uint64 pow_int(t_uint64 base, t_uint64 exp)
Definition: other.cpp:128
uint64_t t_uint64
Definition: int_types.h:3
size_t t_size
Definition: int_types.h:48
void SHARED_EXPORT scale(const audio_sample *p_source, t_size p_count, audio_sample *p_output, audio_sample p_scale)
p_source/p_output can point to same buffer
Definition: audio_math.cpp:63
uint32_t t_uint32
Definition: int_types.h:5
t_size length() const
For compatibility with old conventions.
Definition: string_base.h:208

Member Function Documentation

t_uint64 pfc::format_file_size_short::get_used_scale ( ) const
inline

Definition at line 716 of file string_base.h.

716 {return m_scale;}

Field Documentation

t_uint64 pfc::format_file_size_short::m_scale
private

Definition at line 718 of file string_base.h.


The documentation for this class was generated from the following files: