aboutsummaryrefslogtreecommitdiff
path: root/src/optparser.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-16 20:10:58 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-16 20:10:58 +0000
commitf72c6e4b97afeb69d9ea4d743c0c302d647ea424 (patch)
tree48d9d94db520455324e902759e887c0d98de976a /src/optparser.h
parent5eba456f0147b12a6247cd7aa41e55d121962358 (diff)
downloadlibbu++-f72c6e4b97afeb69d9ea4d743c0c302d647ea424.tar.gz
libbu++-f72c6e4b97afeb69d9ea4d743c0c302d647ea424.tar.bz2
libbu++-f72c6e4b97afeb69d9ea4d743c0c302d647ea424.tar.xz
libbu++-f72c6e4b97afeb69d9ea4d743c0c302d647ea424.zip
The new signal/slots system is in place, and works from 0-5 parameters right
now, I'll probably add more later on... I've also started on the replacement for ParamProc, OptParser. It should do everything that ParamProc did, only with less code, and much better.
Diffstat (limited to '')
-rw-r--r--src/optparser.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/optparser.h b/src/optparser.h
new file mode 100644
index 0000000..39f048d
--- /dev/null
+++ b/src/optparser.h
@@ -0,0 +1,51 @@
1#ifndef BU_OPT_PARSER_H
2#define BU_OPT_PARSER_H
3
4#include "bu/fstring.h"
5#include "bu/list.h"
6#include "bu/hash.h"
7
8namespace Bu
9{
10 class OptParser
11 {
12 public:
13 class Option
14 {
15 public:
16 Option();
17 virtual ~Option();
18
19 char cOpt;
20 Bu::FString sOpt;
21 Bu::FString sDesc;
22 };
23
24 public:
25 OptParser();
26 virtual ~OptParser();
27
28 void parse( int argc, char *argv[] );
29
30 void addOption( const Option &opt );
31
32 template<typename c>
33 void callback( c *pObj, int (c::*fnc)( int, char *[] ) )
34 {
35 (pObj->*fnc)( 0, NULL );
36 }
37
38 private:
39 Bu::FString format( const Bu::FString &sIn, int iWidth, int iIndent );
40
41 typedef Bu::List<Option> OptionList;
42 typedef Bu::Hash<char, Option *> ShortOptionHash;
43 typedef Bu::Hash<Bu::FString, Option *> LongOptionHash;
44
45 OptionList lOption;
46 ShortOptionHash hsOption;
47 LongOptionHash hlOption;
48 };
49};
50
51#endif