1 #ifndef UTIL_CLI_CMDOPTIONVALUE_H
2 #define UTIL_CLI_CMDOPTIONVALUE_H
21 #include <type_traits>
29 template <
typename Tt>
34 inline std::string
operator()(
const std::string &s)
const {
return s; }
39 inline char operator()(
const std::string &s)
const {
return s.empty() ? 0 : s[0]; }
44 inline unsigned char operator()(
const std::string &s)
const {
45 return static_cast<unsigned char>(s.empty() ? 0 : s[0]);
51 inline int16_t
operator()(
const std::string &s)
const {
return util::string::to_int<int16_t>(s.c_str()); }
56 inline uint16_t
operator()(
const std::string &s)
const {
return util::string::to_int<uint16_t>(s.c_str()); }
61 inline int32_t
operator()(
const std::string &s)
const {
return util::string::to_int<int32_t>(s.c_str()); }
66 inline uint32_t
operator()(
const std::string &s)
const {
return util::string::to_int<uint32_t>(s.c_str()); }
71 inline int64_t
operator()(
const std::string &s)
const {
return util::string::to_int<int64_t>(s.c_str()); }
76 inline uint64_t
operator()(
const std::string &s)
const {
return util::string::to_int<uint64_t>(s.c_str()); }
81 inline bool operator()(
const std::string &s)
const {
return !s.empty() &&
"0" != s; }
84 template <
typename Tt>
104 template <
typename Tr>
106 typedef typename ::std::remove_cv<Tr>::type cv_type;
160 void split(
char delim, std::vector<cmd_option_value> &out);
unsigned short to_ushort() const
void split(char delim, std::vector< cmd_option_value > &out)
cmd_option_value(const char *str_data)
uint16_t to_uint16() const
long long to_longlong() const
bool to_logic_bool() const
uint32_t to_uint32() const
unsigned char to_uchar() const
uint64_t to_uint64() const
unsigned int to_uint() const
unsigned long long to_ulonglong() const
const char * to_string() const
unsigned long to_ulong() const
const std::string & to_cpp_string() const
字符串相关操作 Licensed under the MIT licenses.
bool operator()(const std::string &s) const
char operator()(const std::string &s) const
int16_t operator()(const std::string &s) const
int32_t operator()(const std::string &s) const
int64_t operator()(const std::string &s) const
std::string operator()(const std::string &s) const
uint16_t operator()(const std::string &s) const
uint32_t operator()(const std::string &s) const
uint64_t operator()(const std::string &s) const
unsigned char operator()(const std::string &s) const
Tt operator()(const std::string &s) const