| 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 |  | 
|---|
| 9 | #include "debug.h" | 
|---|
| 10 |  | 
|---|
| 11 | #include "src/lib/parser/cmdline_parser/cmdline_parser.h" | 
|---|
| 12 |  | 
|---|
| 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 |  | 
|---|
| 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 |  | 
|---|
| 39 | enum | 
|---|
| 40 | { | 
|---|
| 41 |   ID_SET_INI = 1, | 
|---|
| 42 |   ID_HELP, | 
|---|
| 43 |   ID_PREFS | 
|---|
| 44 | }; | 
|---|
| 45 |  | 
|---|
| 46 | #define REGISTER_ARG_FLAG(shortOption,longOption,section,key,description,value) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,"",value) | 
|---|
| 47 |  | 
|---|
| 48 | #define REGISTER_ARG_ARG(shortOption,longOption,section,key,description,argname) bool _ARGVAR_##shortOption##_##longOption = CmdLinePrefsReader::registerArgument(#shortOption[0],#longOption,section,key,description,argname) | 
|---|
| 49 |  | 
|---|
| 50 | //! A class for reading commandline arguments into Preferences | 
|---|
| 51 | class CmdLinePrefsReader | 
|---|
| 52 | { | 
|---|
| 53 |  | 
|---|
| 54 |  public: | 
|---|
| 55 |    CmdLinePrefsReader(); | 
|---|
| 56 |    virtual ~CmdLinePrefsReader(); | 
|---|
| 57 |  | 
|---|
| 58 |     bool parse(int argc, char** argv); | 
|---|
| 59 |  | 
|---|
| 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%" ); | 
|---|
| 61 |  | 
|---|
| 62 |     static bool asdf; | 
|---|
| 63 |  | 
|---|
| 64 |   private: | 
|---|
| 65 |     static bool callBack( ArgTableEntry entry, void* data, const std::string & arg, const std::vector<MultiType> & argArgs ); | 
|---|
| 66 |  | 
|---|
| 67 |     static RegistredArgs regArgs; | 
|---|
| 68 |  | 
|---|
| 69 | }; | 
|---|
| 70 |  | 
|---|
| 71 | #endif /* _PROTO_CLASS_H */ | 
|---|