foobar2000 SDK  2015-08-03
Public Member Functions | Private Attributes
pfc::format_uint

#include <string_base.h>

Public Member Functions

 format_uint (t_uint64 p_val, unsigned p_width=0, unsigned p_base=10)
 
 format_uint (const format_uint &p_source)
 
const char * get_ptr () const
 
 operator const char * () const
 
const char * toString () const
 

Private Attributes

char m_buffer [64]
 

Detailed Description

Definition at line 576 of file string_base.h.

Constructor & Destructor Documentation

pfc::format_uint::format_uint ( t_uint64  p_val,
unsigned  p_width = 0,
unsigned  p_base = 10 
)

Definition at line 569 of file string_base.cpp.

570 {
571 
572  enum {max_width = PFC_TABSIZE(m_buffer) - 1};
573 
574  if (p_width > max_width) p_width = max_width;
575  else if (p_width == 0) p_width = 1;
576 
577  char temp[max_width];
578 
579  unsigned n;
580  for(n=0;n<max_width;n++)
581  {
582  temp[max_width-1-n] = format_hex_char((unsigned)(val % p_base));
583  val /= p_base;
584  }
585 
586  for(n=0;n<max_width && temp[n] == '0';n++) {}
587 
588  if (n > max_width - p_width) n = max_width - p_width;
589 
590  char * out = m_buffer;
591 
592  for(;n<max_width;n++)
593  *(out++) = temp[n];
594  *out = 0;
595 }
char m_buffer[64]
Definition: string_base.h:584
char format_hex_char(unsigned p_val)
pfc::format_uint::format_uint ( const format_uint p_source)
inline

Definition at line 579 of file string_base.h.

579 {*this = p_source;}

Member Function Documentation

const char* pfc::format_uint::get_ptr ( ) const
inline

Definition at line 580 of file string_base.h.

580 {return m_buffer;}
char m_buffer[64]
Definition: string_base.h:584
pfc::format_uint::operator const char * ( ) const
inline

Definition at line 582 of file string_base.h.

582 {return m_buffer;}
char m_buffer[64]
Definition: string_base.h:584
const char* pfc::format_uint::toString ( ) const
inline

Definition at line 581 of file string_base.h.

581 {return m_buffer;}
char m_buffer[64]
Definition: string_base.h:584

Field Documentation

char pfc::format_uint::m_buffer[64]
private

Definition at line 584 of file string_base.h.


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