summaryrefslogtreecommitdiff
path: root/src/optparser.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-16 23:54:13 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-16 23:54:13 +0000
commit0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a (patch)
tree5e5933681454276d73ceb4ce18719244c9c76d18 /src/optparser.h
parentafac5804b069e5eb76c799e9edd2eaeff0d99b94 (diff)
downloadlibbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.gz
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.bz2
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.xz
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.zip
Signals is even safer and works even better. Also, OptParser is nearly done.
Now I just have to come up with a way to modify data that you already have, that sure was a nice feature of the old one, even if it was implemented in a silly way.
Diffstat (limited to 'src/optparser.h')
-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 );