STTNet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Static Public Member Functions | List of all members
stt::data::NumberStringConvertUtil Class Reference

Responsible for conversion between strings and numbers. More...

#include <sttnet_English.h>

Static Public Member Functions

static int & toInt (const std::string_view &ori_str, int &result, const int &i=-1)
 Convert string to int type. More...
 
static int & str16toInt (const std::string_view &ori_str, int &result, const int &i=-1)
 Convert a hexadecimal number's string representation to a decimal int type number. More...
 
static long & toLong (const std::string_view &ori_str, long &result, const long &i=-1)
 Convert string to long type. More...
 
static float & toFloat (const std::string &ori_str, float &result, const float &i=-1)
 Convert string to float type. More...
 
static double & toDouble (const std::string &ori_str, double &result, const double &i=-1)
 Convert string to double type. More...
 
static bool & toBool (const std::string_view &ori_str, bool &result)
 Convert string to bool type. More...
 
static std::string & strto16 (const std::string &ori_str, std::string &result)
 Convert a normal string to its corresponding hexadecimal representation string (hex string). More...
 

Detailed Description

Responsible for conversion between strings and numbers.

Member Function Documentation

static int& stt::data::NumberStringConvertUtil::str16toInt ( const std::string_view &  ori_str,
int &  result,
const int &  i = -1 
)
static

Convert a hexadecimal number's string representation to a decimal int type number.

Parameters
ori_strString representation of a hexadecimal number
resultInt container to save the conversion result
Returns
Reference to result
static std::string& stt::data::NumberStringConvertUtil::strto16 ( const std::string &  ori_str,
std::string &  result 
)
static

Convert a normal string to its corresponding hexadecimal representation string (hex string).

For example, input "ABC" will be converted to "414243", and each character is converted to the hexadecimal form of its ASCII.

Parameters
ori_strInput original string (can contain any characters, including invisible characters).
resultReference to the string storing the conversion result.
Returns
Reference to the converted hexadecimal string result.
Bug:
There is a bug to be fixed
static bool& stt::data::NumberStringConvertUtil::toBool ( const std::string_view &  ori_str,
bool &  result 
)
static

Convert string to bool type.

Note
Does not throw exceptions, true or True, TRUE return true, otherwise return false
Parameters
ori_strOriginal string type data
resultBool container to store the result
Returns
Reference to result
static double& stt::data::NumberStringConvertUtil::toDouble ( const std::string &  ori_str,
double &  result,
const double &  i = -1 
)
static

Convert string to double type.

Note
Does not throw exceptions
Parameters
ori_strOriginal string type data
resultDouble container to store the result
iIf the conversion fails, assign result to i (default is -1)
Returns
Reference to result
static float& stt::data::NumberStringConvertUtil::toFloat ( const std::string &  ori_str,
float &  result,
const float &  i = -1 
)
static

Convert string to float type.

Note
Does not throw exceptions
Parameters
ori_strOriginal string type data
resultFloat container to store the result
iIf the conversion fails, assign result to i (default is -1)
Returns
Reference to result
static int& stt::data::NumberStringConvertUtil::toInt ( const std::string_view &  ori_str,
int &  result,
const int &  i = -1 
)
static

Convert string to int type.

Note
Does not throw exceptions
Parameters
ori_strOriginal string type data
resultInt container to store the result
iIf the conversion fails, assign result to i (default is -1)
Returns
Reference to result
static long& stt::data::NumberStringConvertUtil::toLong ( const std::string_view &  ori_str,
long &  result,
const long &  i = -1 
)
static

Convert string to long type.

Note
Does not throw exceptions
Parameters
ori_strOriginal string type data
resultLong container to store the result
iIf the conversion fails, assign result to i (default is -1)
Returns
Reference to result

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