ONE - On-device Neural Engine
Loading...
Searching...
No Matches
arser::internal Namespace Reference

Functions

template<typename T >
lexical_cast (const std::string &str)
 
template<>
std::string lexical_cast (const std::string &str)
 
template<>
bool lexical_cast (const std::string &str)
 
template<typename T >
std::string to_string (const T value)
 
template<>
std::string to_string (const char *value)
 
template<>
std::string to_string (const bool value)
 
std::string remove_dash (const std::string &str)
 Returns the string with the leading dash removed.
 
std::string make_comma_concatenated (const std::vector< std::string > &vec)
 Returns the string that created by concatenating the elements of a vector with commas.
 
template<>
std::string lexical_cast (const std::string &str)
 
template<>
bool lexical_cast (const std::string &str)
 
template<>
std::string to_string (const char *value)
 
template<>
std::string to_string (const bool value)
 

Function Documentation

◆ lexical_cast() [1/5]

template<typename T >
T arser::internal::lexical_cast ( const std::string &  str)

Definition at line 43 of file arser.h.

44{
45 std::istringstream ss;
46 ss.str(str);
47 T data;
48 ss >> data;
49 return data;
50}

◆ lexical_cast() [2/5]

template<>
std::string arser::internal::lexical_cast ( const std::string &  str)
inline

Definition at line 52 of file arser.h.

52{ return str; }

◆ lexical_cast() [3/5]

template<>
bool arser::internal::lexical_cast ( const std::string &  str)
inline

Definition at line 54 of file arser.h.

55{
56 bool data = true;
57 if (str == "false" || str == "False" || str == "FALSE" || str == "0")
58 data = false;
59 return data;
60}

◆ lexical_cast() [4/5]

template<>
std::string arser::internal::lexical_cast ( const std::string &  str)
inline

Definition at line 52 of file arser.h.

52{ return str; }

◆ lexical_cast() [5/5]

template<>
bool arser::internal::lexical_cast ( const std::string &  str)
inline

Definition at line 54 of file arser.h.

55{
56 bool data = true;
57 if (str == "false" || str == "False" || str == "FALSE" || str == "0")
58 data = false;
59 return data;
60}

◆ make_comma_concatenated()

std::string arser::internal::make_comma_concatenated ( const std::vector< std::string > &  vec)
inline

Returns the string that created by concatenating the elements of a vector with commas.

Definition at line 85 of file arser.h.

86{
87 std::ostringstream oss;
88 std::copy(vec.begin(), std::prev(vec.end()), std::ostream_iterator<std::string>(oss, ", "));
89 oss << vec.back();
90 return oss.str();
91}

◆ remove_dash()

std::string arser::internal::remove_dash ( const std::string &  str)
inline

Returns the string with the leading dash removed.

If there is no dash, it returns as it is.

Definition at line 73 of file arser.h.

74{
75 std::string ret{str};
76 auto pos = ret.find_first_not_of('-');
77 if (pos == std::string::npos)
78 return ret;
79 return ret.substr(pos);
80}

◆ to_string() [1/5]

template<>
std::string arser::internal::to_string ( const bool  value)
inline

Definition at line 66 of file arser.h.

66{ return value ? "true" : "false"; }

◆ to_string() [2/5]

template<>
std::string arser::internal::to_string ( const bool  value)
inline

Definition at line 66 of file arser.h.

66{ return value ? "true" : "false"; }

◆ to_string() [3/5]

template<>
std::string arser::internal::to_string ( const char *  value)
inline

Definition at line 64 of file arser.h.

64{ return std::string(value); }

◆ to_string() [4/5]

template<>
std::string arser::internal::to_string ( const char *  value)
inline

Definition at line 64 of file arser.h.

64{ return std::string(value); }

◆ to_string() [5/5]

template<typename T >
std::string arser::internal::to_string ( const T  value)
inline

Definition at line 62 of file arser.h.

62{ return std::to_string(value); }

Referenced by arser::Argument::default_value(), and arser::Argument::default_value().