blob: ed32e45d3f1e6d9a64c88d64e54663b1043ba0df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef BU_OPT_PARSER_H
#define BU_OPT_PARSER_H
#include "bu/fstring.h"
#include "bu/list.h"
#include "bu/hash.h"
#include "bu/signals.h"
#include "bu/array.h"
namespace Bu
{
typedef Bu::Array<Bu::FString> StrArray;
class OptParser
{
public:
typedef Signal1<int, StrArray> OptionSignal;
class Option
{
public:
Option();
virtual ~Option();
char cOpt;
Bu::FString sOpt;
Bu::FString sHelp;
OptionSignal sUsed;
bool bShortHasParams;
};
public:
OptParser();
virtual ~OptParser();
void parse( int argc, char **argv );
void addOption( const Option &opt );
void addHelpOption( char c, const Bu::FString &s, const Bu::FString &sHelp );
int optHelp( StrArray aParams );
private:
Bu::FString format( const Bu::FString &sIn, int iWidth, int iIndent );
typedef Bu::List<Option> OptionList;
typedef Bu::Hash<char, Option *> ShortOptionHash;
typedef Bu::Hash<Bu::FString, Option *> LongOptionHash;
OptionList lOption;
ShortOptionHash hsOption;
LongOptionHash hlOption;
};
};
#endif
|