TTMath  0.9.4
 C++ bignum library
Static Public Member Functions
ttmath::Misc Class Reference

#include <ttmathmisc.h>

Static Public Member Functions

static void AssignString (std::string &result, const char *str)
 
static void AssignString (std::wstring &result, const char *str)
 
static void AssignString (std::wstring &result, const std::string &str)
 
static void AssignString (std::string &result, const wchar_t *str)
 
static void AssignString (std::string &result, const std::wstring &str)
 
static void AddString (std::string &result, const char *str)
 
static void AddString (std::wstring &result, const char *str)
 
template<class char_type >
static void SkipWhiteCharacters (const char_type *&c)
 
static uint CharToDigit (uint c)
 
static sint CharToDigit (uint c, uint base)
 
static uint DigitToChar (uint digit)
 

Detailed Description

some helpful functions

Definition at line 57 of file ttmathmisc.h.

Member Function Documentation

§ AddString() [1/2]

static void ttmath::Misc::AddString ( std::string &  result,
const char *  str 
)
static

result += str

Definition at line 135 of file ttmathmisc.h.

136 {
137  result += str;
138 }

§ AddString() [2/2]

static void ttmath::Misc::AddString ( std::wstring &  result,
const char *  str 
)
static

result += str

Definition at line 146 of file ttmathmisc.h.

147 {
148  for( ; *str ; ++str )
149  result += *str;
150 }

§ AssignString() [1/5]

static void ttmath::Misc::AssignString ( std::string &  result,
const char *  str 
)
static

§ AssignString() [2/5]

static void ttmath::Misc::AssignString ( std::wstring &  result,
const char *  str 
)
static

result = str

Definition at line 83 of file ttmathmisc.h.

84 {
85  result.clear();
86 
87  for( ; *str ; ++str )
88  result += *str;
89 }

§ AssignString() [3/5]

static void ttmath::Misc::AssignString ( std::wstring &  result,
const std::string &  str 
)
static

result = str

Definition at line 95 of file ttmathmisc.h.

References AssignString().

96 {
97  return AssignString(result, str.c_str());
98 }
static void AssignString(std::string &result, const char *str)
Definition: ttmathmisc.h:72

§ AssignString() [4/5]

static void ttmath::Misc::AssignString ( std::string &  result,
const wchar_t *  str 
)
static

result = str

Definition at line 104 of file ttmathmisc.h.

105 {
106  result.clear();
107 
108  for( ; *str ; ++str )
109  result += static_cast<char>(*str);
110 }

§ AssignString() [5/5]

static void ttmath::Misc::AssignString ( std::string &  result,
const std::wstring &  str 
)
static

result = str

Definition at line 116 of file ttmathmisc.h.

References AssignString().

117 {
118  return AssignString(result, str.c_str());
119 }
static void AssignString(std::string &result, const char *str)
Definition: ttmathmisc.h:72

§ CharToDigit() [1/2]

static uint ttmath::Misc::CharToDigit ( uint  c)
static

this static method converts one character into its value

for example:

  • 1 -> 1
  • 8 -> 8
  • A -> 10
  • f -> 15

this method don't check whether c is correct or not

Definition at line 181 of file ttmathmisc.h.

Referenced by ttmath::Big< exp, man >::FromString(), ttmath::Parser< ValueType >::GetValueOfVariable(), and ttmath::UInt< man >::ToString().

182 {
183  if(c>='0' && c<='9')
184  return c-'0';
185 
186  if(c>='a' && c<='z')
187  return c-'a'+10;
188 
189 return c-'A'+10;
190 }

§ CharToDigit() [2/2]

static sint ttmath::Misc::CharToDigit ( uint  c,
uint  base 
)
static

this method changes a character 'c' into its value (if there can't be a correct value it returns -1)

for example:

  • c=2, base=10 -> function returns 2
  • c=A, base=10 -> function returns -1
  • c=A, base=16 -> function returns 10

Definition at line 202 of file ttmathmisc.h.

203 {
204  if( c>='0' && c<='9' )
205  c=c-'0';
206  else
207  if( c>='a' && c<='z' )
208  c=c-'a'+10;
209  else
210  if( c>='A' && c<='Z' )
211  c=c-'A'+10;
212  else
213  return -1;
214 
215 
216  if( c >= base )
217  return -1;
218 
219 
220 return sint(c);
221 }
signed long sint
Definition: ttmathtypes.h:243

§ DigitToChar()

static uint ttmath::Misc::DigitToChar ( uint  digit)
static

this method converts a digit into a char digit should be from <0,F> (we don't have to get a base)

for example:

  • 1 -> 1
  • 8 -> 8
  • 10 -> A
  • 15 -> F

Definition at line 236 of file ttmathmisc.h.

Referenced by ttmath::UInt< man >::ToStringBase().

237 {
238  if( digit < 10 )
239  return digit + '0';
240 
241 return digit - 10 + 'A';
242 }

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