[6383] | 1 | /*! |
---|
| 2 | * @file proto_class.h |
---|
| 3 | * @brief Definition of CmdLinePrefsReader |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _CMD_LINE_PREFS_READER_H |
---|
| 7 | #define _CMD_LINE_PREFS_READER_H |
---|
| 8 | |
---|
[6392] | 9 | #include "debug.h" |
---|
| 10 | |
---|
[7241] | 11 | #include "src/lib/parser/cmdline_parser/cmdline_parser.h" |
---|
| 12 | |
---|
[7250] | 13 | struct IniEntry |
---|
| 14 | { |
---|
| 15 | std::string section; |
---|
| 16 | std::string key; |
---|
| 17 | std::string value; |
---|
| 18 | }; |
---|
| 19 | |
---|
| 20 | struct CallbackData |
---|
| 21 | { |
---|
| 22 | std::list<IniEntry> iniEntries; |
---|
| 23 | CmdLineParser * parser; |
---|
| 24 | }; |
---|
| 25 | |
---|
[7251] | 26 | struct RegistredArgument |
---|
| 27 | { |
---|
| 28 | char shortOption; |
---|
| 29 | std::string longOption; |
---|
| 30 | std::string value; |
---|
| 31 | std::string help; |
---|
| 32 | std::string argName; |
---|
| 33 | std::string section; |
---|
| 34 | std::string key; |
---|
| 35 | }; |
---|
| 36 | |
---|
| 37 | typedef std::vector<RegistredArgument> RegistredArgs; |
---|
| 38 | |
---|
[7243] | 39 | enum |
---|
| 40 | { |
---|
[7250] | 41 | ID_SET_INI = 1, |
---|
[7251] | 42 | ID_HELP, |
---|
[7254] | 43 | ID_PREFS |
---|
[7243] | 44 | }; |
---|
| 45 | |
---|
[9869] | 46 | #define REGISTER_ARG_FLAG(shortOption,longOption,section,key,description,value) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,"",value) |
---|
[7251] | 47 | |
---|
[9869] | 48 | #define REGISTER_ARG_ARG(shortOption,longOption,section,key,description,argname) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,argname) |
---|
[7251] | 49 | |
---|
[6383] | 50 | //! A class for reading commandline arguments into Preferences |
---|
[9869] | 51 | class CmdLinePrefsReader |
---|
[7241] | 52 | { |
---|
[6383] | 53 | |
---|
| 54 | public: |
---|
[7241] | 55 | CmdLinePrefsReader(); |
---|
[6383] | 56 | virtual ~CmdLinePrefsReader(); |
---|
| 57 | |
---|
[7241] | 58 | bool parse(int argc, char** argv); |
---|
[9869] | 59 | |
---|
[7251] | 60 | static bool registerArgument( const char shortOption, const std::string & longOption, const std::string & section, const std::string & key, const std::string & help, const std::string & argName = "", const std::string & value = "%arg%" ); |
---|
[9869] | 61 | |
---|
[7251] | 62 | static bool asdf; |
---|
[9869] | 63 | |
---|
[7241] | 64 | private: |
---|
[7243] | 65 | static bool callBack( ArgTableEntry entry, void* data, const std::string & arg, const std::vector<MultiType> & argArgs ); |
---|
[9869] | 66 | |
---|
[7251] | 67 | static RegistredArgs regArgs; |
---|
[6392] | 68 | |
---|
[6383] | 69 | }; |
---|
| 70 | |
---|
| 71 | #endif /* _PROTO_CLASS_H */ |
---|