aboutsummaryrefslogtreecommitdiff
path: root/src/optparser.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/optparser.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/optparser.h b/src/optparser.h
index 39f048d..ed32e45 100644
--- a/src/optparser.h
+++ b/src/optparser.h
@@ -4,12 +4,16 @@
4#include "bu/fstring.h" 4#include "bu/fstring.h"
5#include "bu/list.h" 5#include "bu/list.h"
6#include "bu/hash.h" 6#include "bu/hash.h"
7#include "bu/signals.h"
8#include "bu/array.h"
7 9
8namespace Bu 10namespace Bu
9{ 11{
12 typedef Bu::Array<Bu::FString> StrArray;
10 class OptParser 13 class OptParser
11 { 14 {
12 public: 15 public:
16 typedef Signal1<int, StrArray> OptionSignal;
13 class Option 17 class Option
14 { 18 {
15 public: 19 public:
@@ -18,22 +22,21 @@ namespace Bu
18 22
19 char cOpt; 23 char cOpt;
20 Bu::FString sOpt; 24 Bu::FString sOpt;
21 Bu::FString sDesc; 25 Bu::FString sHelp;
26 OptionSignal sUsed;
27 bool bShortHasParams;
22 }; 28 };
23 29
24 public: 30 public:
25 OptParser(); 31 OptParser();
26 virtual ~OptParser(); 32 virtual ~OptParser();
27 33
28 void parse( int argc, char *argv[] ); 34 void parse( int argc, char **argv );
29 35
30 void addOption( const Option &opt ); 36 void addOption( const Option &opt );
37 void addHelpOption( char c, const Bu::FString &s, const Bu::FString &sHelp );
31 38
32 template<typename c> 39 int optHelp( StrArray aParams );
33 void callback( c *pObj, int (c::*fnc)( int, char *[] ) )
34 {
35 (pObj->*fnc)( 0, NULL );
36 }
37 40
38 private: 41 private:
39 Bu::FString format( const Bu::FString &sIn, int iWidth, int iIndent ); 42 Bu::FString format( const Bu::FString &sIn, int iWidth, int iIndent );