Last change
on this file since 8965 was
8316,
checked in by bensch, 18 years ago
|
trunk: fixed most -Wall warnings… but there are still many missing :/
|
File size:
1.1 KB
|
Rev | Line | |
---|
[7241] | 1 | /*! |
---|
| 2 | * @file cmdline_parser.h |
---|
| 3 | * @brief Definition of ... |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _CMD_LINE_PARSER_H |
---|
| 7 | #define _CMD_LINE_PARSER_H |
---|
| 8 | |
---|
| 9 | #include <list> |
---|
| 10 | #include <string> |
---|
| 11 | #include <vector> |
---|
| 12 | |
---|
| 13 | #include "src/defs/debug.h" |
---|
[7243] | 14 | #include "src/lib/util/multi_type.h" |
---|
[7241] | 15 | |
---|
| 16 | |
---|
| 17 | struct ArgTableEntry |
---|
| 18 | { |
---|
[8316] | 19 | unsigned int id; |
---|
| 20 | std::string longOption; |
---|
| 21 | char shortOption; |
---|
| 22 | unsigned int numArgs; |
---|
| 23 | std::string argNames; |
---|
| 24 | std::string help; |
---|
[7241] | 25 | }; |
---|
| 26 | |
---|
| 27 | typedef std::list<ArgTableEntry> ArgTable; |
---|
| 28 | |
---|
[7243] | 29 | typedef bool (*ArgParserCallback)( ArgTableEntry, void*, const std::string &, const std::vector<MultiType> & ); |
---|
[7241] | 30 | |
---|
| 31 | |
---|
| 32 | //! A class for parsing command line arguments |
---|
| 33 | class CmdLineParser { |
---|
| 34 | |
---|
| 35 | public: |
---|
| 36 | CmdLineParser(); |
---|
| 37 | virtual ~CmdLineParser(); |
---|
[8316] | 38 | |
---|
[7250] | 39 | bool add( int id, const std::string& longOption, char shortOption, int numArgs, const std::string & argNames, const std::string& help, bool back=false ); |
---|
[7241] | 40 | |
---|
| 41 | bool parse( ArgParserCallback cb, void* data, int argc, char** argv ); |
---|
[8316] | 42 | |
---|
[7250] | 43 | void showHelp(); |
---|
[8316] | 44 | |
---|
[7241] | 45 | private: |
---|
| 46 | ArgTable argTable; |
---|
[7250] | 47 | std::string exeName; |
---|
[8316] | 48 | |
---|
[7241] | 49 | inline bool matches( ArgTableEntry entry, std::string arg, bool & finish ); |
---|
| 50 | |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | #endif /* _CMD_LINE_PARSER_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.