Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00034 #ifndef KEYVALUE_LEXICAL_TOOL_KIT_H_
00035 #define KEYVALUE_LEXICAL_TOOL_KIT_H_
00036
00037 #include <boost/utility.hpp>
00038
00039 #include "keyvalue/extern/String.h"
00040 #include "keyvalue/extern/Ptime.h"
00041 #include "keyvalue/sys/exception/Exception.h"
00042 #include "keyvalue/util/Lexical.h"
00043
00044 namespace keyvalue {
00045 namespace frontend {
00046
00077 class LexicalToolKit : private ::boost::noncopyable {
00078
00079 public:
00080
00086 LexicalToolKit();
00087
00093 enum IO { none = 0x0, input = 0x1, output = 0x2, both = 0x3};
00094
00108 template <typename From, typename To>
00109 struct Helper {
00110
00111
00112 typedef To (*Type_)(const From&);
00113
00114
00115
00116 static Type_ LexicalToolKit::* converter_;
00117
00118
00119
00120 static IO LexicalToolKit::* io_;
00121 };
00122
00143 template <typename From, typename To>
00144 void
00145 set(IO io, typename Helper<From, To>::Type_ converter = util::Lexical);
00146
00162 template <typename From, typename To>
00163 bool
00164 isEnabled(IO io) const;
00165
00172 class Failure : public RuntimeError {
00173 };
00174
00198 template <typename To, typename From>
00199 To
00200 convert(From input) const;
00201
00202 private:
00203
00212 #define KV_LEXICAL_TOOL_KIT_PAIR(From, To) \
00213 Helper<From, To>::Type_ From##2##To##_; \
00214 IO From##2##To##_io_;
00215
00216 #include "keyvalue/frontend/LexicalToolKitPairs.h"
00217
00225 char endInitList;
00226
00227 };
00228
00229 }
00230 }
00231
00232 #endif // KEYVALUE_LEXICAL_TOOL_KIT_H_