23         memset(static_cast<void*>(&
value), 0, 
sizeof(
value));
 
  106         bool negative = 
false;
 
  108         uint64 fractional_part;
 
  120         if (fraction < 0.0) {
 
  122                 fraction = -fraction;
 
  130         rounded = 
static_cast<uint64
>(fraction * multiplier);
 
  131         fractional_part = rounded % multiplier;
 
  132         whole_part = rounded / multiplier;
 
  134         if ((fractional_part % 
m_base) + (m_base/2) >= m_base) {
 
  135                 fractional_part += m_base/2;
 
  136                 if (fractional_part > (fractional_part % multiplier)) {
 
  139                 fractional_part %= multiplier;
 
  142         if (whole_part == 0) {
 
  146                 while (whole_part > 0) {
 
  147                         digit = whole_part % 
m_base;
 
  154         fractional_part /= 
m_base;
 
  155         if (fractional_part == 0) {
 
  159                 while (fractional_part > 0) {
 
  160                         digit = fractional_part % 
m_base;
 
  163                         fractional_part /= 
m_base;
 
  167                 a_fs.erase(m_precision);
 
  199         value_type::const_iterator stri;
 
  202         T overflow_check_1 = 0;
 
  203         T overflow_check_2 = 0;
 
  207         const static size_t buffer_len = 256;
 
  208         char buffer[buffer_len] = { 0 };
 
  215         for (stri = a_str.begin(), index = 0;
 
  220                 idx = alphabet.find(*stri);
 
  222                         snprintf(buffer, buffer_len, 
"%u", index);
 
  232                         if (idx == value_type::npos) {
 
  236                                 TRY_nomem(es += 
", invalid base or invalid string");
 
  242                 digit = 
static_cast<unsigned int>(idx);
 
  245                 overflow_check_1 *= 
m_base;
 
  246                 overflow_check_1 += 1;
 
  247                 if (overflow_check_1 == overflow_check_2) {
 
  248                         snprintf(buffer, buffer_len, 
"%u", index);
 
  250                         TRY_nomem(es = 
"Overflow error at index ");
 
  260                 overflow_check_2 = overflow_check_1;
 
  282         bool negative = 
false;
 
  284         if ((value_type::size() > 0) && (this->at(0) == 
'-')) {
 
  320         bool negative = 
false;;
 
  321         uint64 whole_part_converter = 0;
 
  322         uint64 fractional_part_converter = 0;
 
  323         uint64 fractional_check = 0;
 
  325         T fractional_part = 0;
 
  327         unsigned int divisor = 0;
 
  333         if ((value_type::size() > 0) && (this->at(0) == 
'-')) {
 
  342         if (idx != value_type::npos) {
 
  343                 TRY_nomem(whole_string = tmp.substr(0,idx));
 
  344                 TRY_nomem(fractional_string = tmp.substr(idx+1));
 
  351         TRY_nomem(es = 
"Could not convert whole part of estring \"");
 
  356         TRY_nomem(es = 
"Could not convert fractional part of estring \"");
 
  362         for (c = 0; c < fractional_string.size(); c++)
 
  365         whole_part = 
static_cast<T
>(whole_part_converter);
 
  366         if (static_cast<uint64>(whole_part) != whole_part_converter) {
 
  367                 TRY_nomem(es = 
"Overflow error converting whole part of estring \"");
 
  372         fractional_part = 
static_cast<T
>(fractional_part_converter)/divisor;
 
  373         fractional_check = 
static_cast<uint64
>(fractional_part*divisor);
 
  374         if (fractional_check != fractional_part_converter) {
 
  375                 TRY_nomem(es = 
"Underflow error converting fractional part of estring \"");
 
  381         value = whole_part + fractional_part;
 
  542         unsigned int old = 
m_base;
 
  544         char str[255] = { 0 };
 
  547                 sprintf(str, 
"%u", a_base);
 
  553                 sprintf(str, 
"%u", a_base);
 
  693         std::string::size_type c = 0;
 
  694         std::string::size_type c_max = 0;
 
  695         std::string::size_type offset = 0;
 
  696         std::string::size_type length = 0;
 
  697         std::string::size_type l_offset = 0;
 
  698         std::string::size_type r_offset = 0;
 
  705         if (std::string::size() > 
m_width) {
 
  711                         TRY_nomem(str = std::string::substr(0,length) + 
"...");
 
  720                         offset = std::string::size()-length;
 
  721                         TRY_nomem(str = 
"..." + std::string::substr(offset,length));
 
  731                         r_offset = std::string::size()-1;
 
  732                         for (c = 0; c < c_max; c++) {
 
  737                                         TRY_nomem(rstr = (*
this)[r_offset--] + rstr);
 
  750         c_max = 
m_width - std::string::size();
 
  751         for (c = 0; c < c_max; c++) {
 
  787         const char a_left_fill,
 
  788         const char a_right_fill
 
  893         std::string::iterator si;
 
  895         for (si = (*this).begin(); si != (*this).end(); ++si) {
 
  896                 (*si) = tolower((*si));
 
  910         std::string::iterator si;
 
  912         for (si = (*this).begin(); si != (*this).end(); ++si) {
 
  913                 (*si) = toupper((*si));
 
 1001         TRY_nomem(std::string::assign(a_string));
 
 1059                 "Could not convert unsigned int to string");
 
 1079 estring::operator 
unsigned int()
 const 
 1081         unsigned int value = 0;
 
 1083         TRY(T_string_to_integral((*
this),value),
 
 1084                 "Cannot convert string to unsigned int");
 
 1100                 TRY(
assign(static_cast<unsigned int>(-a_int)),
 
 1101                         "Coud not convert signed int to string");
 
 1105                 TRY(
assign(static_cast<unsigned int>(a_int)),
 
 1106                         "Could not convert signed int to string");
 
 1122 estring::operator int()
 const 
 1126         TRY(T_string_to_signed_integral((*
this),value),
 
 1127                 "Cannot convert string to signed int");
 
 1145                 "Could not convert unsigned short to string");
 
 1161 estring::operator 
unsigned short()
 const 
 1163         unsigned short value = 0;
 
 1165         TRY(T_string_to_integral((*
this),value),
 
 1166                 "Cannot convert string to unsigned short");
 
 1182                 TRY(
assign(static_cast<unsigned short>(-a_short)),
 
 1183                         "Could not convert signed short to string");
 
 1187                 TRY(
assign(static_cast<unsigned short>(a_short)),
 
 1188                         "Could not convert signed short to string");
 
 1204 estring::operator short()
 const 
 1208         TRY(T_string_to_signed_integral((*
this),value),
 
 1209                 "Cannot convert string to signed short");
 
 1227                 "Could not convert unsigned long to string");
 
 1243 estring::operator 
unsigned long()
 const 
 1245         unsigned long value = 0;
 
 1247         TRY(T_string_to_integral((*
this),value),
 
 1248                 "Cannot convert string to unsigned long");
 
 1264                 TRY(
assign(static_cast<unsigned long>(-a_long)),
 
 1265                         "Could not convert signed long to string");
 
 1269                 TRY(
assign(static_cast<unsigned long>(a_long)),
 
 1270                         "Could not convert signed long to string");
 
 1286 estring::operator long()
 const 
 1290         TRY(T_string_to_signed_integral((*
this),value),
 
 1291                 "Cannot convert string to signed long");
 
 1309                 "Could not convert unsigned long long to string");
 
 1325 estring::operator 
unsigned long long()
 const 
 1327         unsigned long long value = 0;
 
 1329         TRY(T_string_to_integral((*
this),value),
 
 1330                 "Cannot convert string to unsigned long long");
 
 1346                 TRY(
assign(static_cast<unsigned long long>(-a_long)),
 
 1347                         "Could not convert unsigned long long to string");
 
 1351                 TRY(
assign(static_cast<unsigned long long>(a_long)),
 
 1352                         "Could not convert unsigned long long to string");
 
 1368 estring::operator 
long long()
 const 
 1370         long long value = 0;
 
 1372         TRY(T_string_to_signed_integral((*
this),value),
 
 1373                 "Cannot convert string to signed long long");
 
 1406 estring::operator 
char const *()
const 
 1408         char const * value = 0;
 
 1410         if ((m_type != type_char_ptr) && (m_type != type_void_ptr)) {
 
 1411                 throw(
ERROR(0,
"Value type is not a pointer"));
 
 1414         value = m_value.value.char_ptr;
 
 1429         static const size_t buffer_len = 32;
 
 1430         char buffer[buffer_len] = { 0 };
 
 1432         snprintf(buffer, buffer_len, 
"%p", a_ptr);
 
 1448 estring::operator 
void*()
const 
 1452         if ((m_type != type_void_ptr) && (m_type != type_char_ptr)) {
 
 1453                 throw(
ERROR(0,
"Value type is not a pointer"));
 
 1456         value = m_value.value.void_ptr;
 
 1476                 "Cannot convert float to string");
 
 1478         if (fs.size() > 0) {
 
 1498         unsigned int a_base)
 
 1501         assign(a_float, a_precision, a_base);
 
 1505         unsigned int a_base)
 
 1518 estring::operator float()
 const 
 1522         TRY(T_string_to_fractional((*
this), value),
 
 1523                 "Cannot convert string to float");
 
 1543                 "Cannot convert double to string");
 
 1545         if (fs.size() > 0) {
 
 1565         unsigned int a_base)
 
 1568         assign(a_double, a_precision, a_base);
 
 1572         unsigned int a_base)
 
 1585 estring::operator double()
 const 
 1589         TRY(T_string_to_fractional((*
this), value),
 
 1590                 "Cannot convert string to double");
 
static const size_t m_alphabet_len
The length of the alphabet. 
set_from_type m_type
The current value type. 
void clear(void)
Erase the string value. 
Basic types definitions and templates. 
An extended string class. 
void reset(void)
Erase and reinitialize. 
void T_string_to_integral(const value_type &a_str, T &a_t) const 
Helper member template function to convert a string to an integral type. 
const set_from_type & get_from_type(void) const 
Retrieve the type of value being held by this estring. 
estring & assign(const estring &a_estr)
Assignment for estring objects. 
estring_value & operator=(const estring_value &a_estring_value)
char m_left_fillchar
The current left-hand fill character. 
char m_right_fillchar
The current right-hand fill character. 
void T_integral_to_string(const T &a_t, value_type &a_str)
Helper member template function to convert an integral type to an estring. 
alignment align(void) const 
Retrieve the set alignment for formatted strings. 
static const char * m_alphabet
The alphabet used for any base from 2 to 36. 
alignment m_alignment
The current formatting alignment. 
size_type width(void) const 
Retrieve the set width for formatted strings. 
void init(void)
Initialize the estring object. 
size_type m_precision
The current fractional number precision. 
value_type fmt_str(void)
Generate a formatted string. 
char left_fillchar(void) const 
Retrieve the fill character used to padd the left side of a formatted string. 
estring & operator=(const estring &a_estr)
Assignment operator for estring objects. 
void fillchar(const char a_char)
Set the fill character used for padding both the left and right side of a formatted string...
void T_string_to_fractional(const value_type &a_str, T &a_t) const 
Helper member template function to convert a string to a fractional. 
const estring_value & get_from_value(void) const 
Retrieve the typeless_value being held by this estring. 
alignment
Alignment values for formatted strings. 
set_from_type
The type last assigned. 
estring & lower(void)
Convert all characters to lowercase. 
void T_fraction_to_strings(const T &a_t, value_type &a_ws, value_type &a_fs)
Helper member template function to convert a fractional type to an estring. 
std::string value_type
The type from which estring inherits, std::string. 
size_type precision(void) const 
Retrieve the set precision used in fractional conversions. 
value_type::size_type size_type
The size type. 
estring()
Default constructor. 
void T_string_to_signed_integral(const value_type &a_str, T &a_t) const 
Helper member template function to convert a string to a signed integral. 
estring & upper(void)
Convert all characters to uppercase. 
estring_value m_value
The current value. 
size_type m_width
The current formatting width. 
char right_fillchar(void) const 
Retrieve the fill character used to padd the right side of a formatted string. 
const unsigned int base(void) const 
Retrieve the base used in numeric conversions. 
unsigned int m_base
The current numerical base.