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