17 #ifndef HH_SENF_Utils_Console_Traits_ 18 #define HH_SENF_Utils_Console_Traits_ 1 22 #include <boost/type_traits/is_same.hpp> 23 #include <boost/typeof/typeof.hpp> 58 *static_cast<ParseCommandInfo::TokensRange const *>(0),
59 *static_cast<Type*>(0))),
75 static std::string
str(Type
const & value);
104 template <
class Type>
109 static void format(Type
const & value, std::ostream & os);
119 template <
class Type>
130 template <
class Type>
139 template <
class Type>
140 std::string
str(Type
const & value);
149 template <
class Type>
150 void format(Type
const & value, std::ostream & os);
179 # define SENF_CONSOLE_REGISTER_ENUM(Type, Values) \ 180 SENF_CONSOLE_REGISTER_ENUM_(BOOST_PP_EMPTY(), BOOST_PP_EMPTY(), Type, Values) 182 # define SENF_CONSOLE_REGISTER_STRONG_ENUM(Type, Values) \ 183 SENF_CONSOLE_REGISTER_ENUM_(BOOST_PP_EMPTY(), Type::, Type, Values) 200 # define SENF_CONSOLE_REGISTER_ENUM_MEMBER(Class, Type, Values) \ 201 SENF_CONSOLE_REGISTER_ENUM_(Class::, BOOST_PP_EMPTY(), Type, Values) 203 # define SENF_CONSOLE_REGISTER_STRONG_ENUM_MEMBER(Class, Type, Values) \ 204 SENF_CONSOLE_REGISTER_ENUM_(Class::, Type::, Type, Values) 223 # define SENF_CONSOLE_PARSE_AS_TUPLE( Type, Members ) \ 224 SENF_CONSOLE_PARSE_AS_TUPLE_(Type, Members) 226 # define SENF_CONSOLE_FORMAT_AS_TUPLE( Type, Members ) \ 227 SENF_CONSOLE_FORMAT_AS_TUPLE_(Type, Members) 229 # define SENF_CONSOLE_PARSE_AND_FORMAT_AS_TUPLE( Type, Members ) \ 230 SENF_CONSOLE_PARSE_AS_TUPLE_(Type, Members); \ 231 SENF_CONSOLE_FORMAT_AS_TUPLE_(Type, Members); 233 # define SENF_CONSOLE_PARSE_AS_MAP( Type, KeyMemberTuples ) \ 234 SENF_CONSOLE_PARSE_AS_MAP_(Type, KeyMemberTuples) 236 # define SENF_CONSOLE_FORMAT_AS_MAP( Type, KeyMemberTuples ) \ 237 SENF_CONSOLE_FORMAT_AS_MAP_(Type, KeyMemberTuples) 239 # define SENF_CONSOLE_PARSE_AND_FORMAT_AS_MAP( Type, KeyMemberTuples ) \ 240 SENF_CONSOLE_PARSE_AS_MAP_(Type, KeyMemberTuples); \ 241 SENF_CONSOLE_FORMAT_AS_MAP_(Type, KeyMemberTuples); 247 struct ArgumentTraits<bool>
250 static bool const singleToken =
true;
254 static std::string
str(
bool value);
258 struct ReturnValueTraits<bool>
262 static void format(
bool value, std::ostream & os);
265 template <>
struct ArgumentTraits<char> :
public detail::CharArgumentTraits<char> {};
266 template <>
struct ReturnValueTraits<char> :
public detail::CharReturnValueTraits<char> {};
267 template <>
struct ArgumentTraits<signed char> :
public detail::CharArgumentTraits<signed char> {};
268 template <>
struct ReturnValueTraits<signed char> :
public detail::CharReturnValueTraits<signed char> {};
269 template <>
struct ArgumentTraits<unsigned char> :
public detail::CharArgumentTraits<unsigned char> {};
270 template <>
struct ReturnValueTraits<unsigned char> :
public detail::CharReturnValueTraits<unsigned char> {};
void senf_console_format_value(DirectoryNode::ptr value, std::ostream &os)
bool senf_console_parse_argument(ParseCommandInfo::TokensRange const &tokens, Type &out)
Argument parser.
void formatTrueFalse(bool value, std::ostream &os)
Format boolean value as true / false.
Customize return value formating.
static std::string str(Type const &value)
Stringify value.
void formatOnOff(bool value, std::ostream &os)
Format boolean value as on / off.
static void parse(ParseCommandInfo::TokensRange const &tokens, Type &out)
Parse token range into value.
static std::string description()
String description of type.
boost::iterator_range< token_iterator > TokensRange
static bool const singleToken
void formatOneZero(bool value, std::ostream &os)
Format boolean value as 1 / 0.
void formatEnabledDisabled(bool value, std::ostream &os)
Format boolean value as enabled / disabled.
void formatYesNo(bool value, std::ostream &os)
Format boolean value as yes / no.
void format(Type const &value, std::ostream &os)
Format return value.