00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Scheduler_Console_Traits_
00027 #define HH_SENF_Scheduler_Console_Traits_ 1
00028
00029
00030 #include <iostream>
00031 #include <boost/intrusive_ptr.hpp>
00032 #include <boost/type_traits/is_same.hpp>
00033 #include <senf/Utils/intrusive_refcount.hh>
00034 #include "Parse.hh"
00035
00036 #include "Traits.ih"
00037
00038
00039
00040 namespace senf {
00041 namespace console {
00042
00062 template <class Type>
00063 struct ArgumentTraits
00064 {
00065 typedef Type type;
00066
00067 static bool const singleToken =
00068 boost::is_same< typeof(senf_console_parse_argument(
00069 *static_cast<ParseCommandInfo::TokensRange const *>(0),
00070 *static_cast<Type*>(0))),
00071 bool >::value;
00072
00073 static void parse(ParseCommandInfo::TokensRange const & tokens, Type & out);
00075
00083 static std::string description();
00084
00086 static std::string str(Type const & value);
00087
00091 };
00092
00099 template <class Type>
00100 bool senf_console_parse_argument(ParseCommandInfo::TokensRange const & tokens, Type & out);
00101
00102
00115 template <class Type>
00116 struct ReturnValueTraits
00117 {
00118 typedef Type type;
00119
00120 static void format(Type const & value, std::ostream & os);
00122 };
00123
00130 template <class Type>
00131 void senf_console_format_value(Type const & value, std::ostream & os);
00132
00133
00141 template <class Type>
00142 void parse(ParseCommandInfo::TokensRange const & tokens, Type & out);
00143
00150 template <class Type>
00151 std::string str(Type const & value);
00152
00160 template <class Type>
00161 void format(Type const & value, std::ostream & os);
00162
00163
00190 # define SENF_CONSOLE_REGISTER_ENUM(Type, Values) \
00191 SENF_CONSOLE_REGISTER_ENUM_(BOOST_PP_EMPTY(), Type, Values)
00192
00208 # define SENF_CONSOLE_REGISTER_ENUM_MEMBER(Class, Type, Values) \
00209 SENF_CONSOLE_REGISTER_ENUM_(Class::, Type, Values)
00210
00211
00213 void formatTrueFalse(bool value, std::ostream & os);
00214
00216 void formatYesNo(bool value, std::ostream & os);
00217
00219 void formatEnabledDisabled(bool value, std::ostream & os);
00220
00222 void formatOnOff(bool value, std::ostream & os);
00223
00225 void formatOneZero(bool value, std::ostream & os);
00226
00227
00228 #ifndef DOXYGEN
00229
00230
00231 template <>
00232 struct ArgumentTraits<bool>
00233 {
00234 typedef bool type;
00235 static bool const singleToken = true;
00236
00237 static void parse(ParseCommandInfo::TokensRange const & tokens, bool & out);
00238 static std::string description();
00239 static std::string str(bool value);
00240 };
00241
00242 template <>
00243 struct ReturnValueTraits<bool>
00244 {
00245 typedef bool type;
00246
00247 static void format(bool value, std::ostream & os);
00248 };
00249
00250 template <> struct ArgumentTraits<char> : public detail::CharArgumentTraits<char> {};
00251 template <> struct ReturnValueTraits<char> : public detail::CharReturnValueTraits<char> {};
00252 template <> struct ArgumentTraits<signed char> : public detail::CharArgumentTraits<signed char> {};
00253 template <> struct ReturnValueTraits<signed char> : public detail::CharReturnValueTraits<signed char> {};
00254 template <> struct ArgumentTraits<unsigned char> : public detail::CharArgumentTraits<unsigned char> {};
00255 template <> struct ReturnValueTraits<unsigned char> : public detail::CharReturnValueTraits<unsigned char> {};
00256
00257 #endif
00258
00259 }}
00260
00261
00262 #include "Traits.cci"
00263 #include "Traits.ct"
00264 #include "Traits.cti"
00265 #endif
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276