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

Functions

template<typename T >
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.
 

Function Documentation

◆ lexical_cast() [1/2]

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/2]

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

Definition at line 52 of file arser.h.

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

◆ 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 83 of file arser.h.

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

◆ 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 71 of file arser.h.

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

◆ to_string() [1/3]

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

Definition at line 64 of file arser.h.

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

◆ to_string() [2/3]

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

Definition at line 62 of file arser.h.

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

◆ to_string() [3/3]

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

Definition at line 60 of file arser.h.

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

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