diff options
Diffstat (limited to '')
-rw-r--r-- | src/old/paramproc.h | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/src/old/paramproc.h b/src/old/paramproc.h deleted file mode 100644 index d857193..0000000 --- a/src/old/paramproc.h +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | #ifndef PARAM_PROC_H | ||
2 | #define PARAM_PROC_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | #include <string> | ||
6 | #include <list> | ||
7 | #include "staticstring.h" | ||
8 | |||
9 | class ParamProc | ||
10 | { | ||
11 | public: | ||
12 | class ParamPtr | ||
13 | { | ||
14 | public: | ||
15 | ParamPtr(); | ||
16 | ParamPtr( std::string *str ); | ||
17 | ParamPtr( uint64_t *uint64 ); | ||
18 | ParamPtr( uint32_t *uint32 ); | ||
19 | ParamPtr( uint16_t *uint16 ); | ||
20 | ParamPtr( uint8_t *uint8 ); | ||
21 | ParamPtr( int64_t *int64 ); | ||
22 | ParamPtr( int32_t *int32 ); | ||
23 | ParamPtr( int16_t *int16 ); | ||
24 | ParamPtr( int8_t *int8 ); | ||
25 | ParamPtr( float *float32 ); | ||
26 | ParamPtr( double *float64 ); | ||
27 | ParamPtr( long double *float96 ); | ||
28 | ParamPtr( bool *bln ); | ||
29 | |||
30 | enum | ||
31 | { | ||
32 | vtunset, | ||
33 | vtstr, | ||
34 | vtuint64, | ||
35 | vtuint32, | ||
36 | vtuint16, | ||
37 | vtuint8, | ||
38 | vtint64, | ||
39 | vtint32, | ||
40 | vtint16, | ||
41 | vtint8, | ||
42 | vtfloat32, | ||
43 | vtfloat64, | ||
44 | vtfloat96, | ||
45 | vtbln, | ||
46 | }; | ||
47 | ParamPtr &operator=( ParamPtr &ptr ); | ||
48 | ParamPtr &operator=( const char *str ); | ||
49 | |||
50 | bool isSet(); | ||
51 | |||
52 | private: | ||
53 | int type; | ||
54 | union | ||
55 | { | ||
56 | std::string *str; | ||
57 | uint64_t *uint64; | ||
58 | uint32_t *uint32; | ||
59 | uint16_t *uint16; | ||
60 | uint8_t *uint8; | ||
61 | int64_t *int64; | ||
62 | int32_t *int32; | ||
63 | int16_t *int16; | ||
64 | int8_t *int8; | ||
65 | float *float32; | ||
66 | double *float64; | ||
67 | long double *float96; | ||
68 | bool *bln; | ||
69 | } val; | ||
70 | }; | ||
71 | |||
72 | typedef int (ParamProc::*Proc)( int, char *[] ); | ||
73 | |||
74 | typedef struct ArgSpec | ||
75 | { | ||
76 | uint8_t nFlags; | ||
77 | StaticString sWord; | ||
78 | char cChar; | ||
79 | Proc proc; | ||
80 | ParamProc::ParamPtr val; | ||
81 | StaticString sExtra; | ||
82 | StaticString sDesc; | ||
83 | StaticString sValue; | ||
84 | } ArgSpec; | ||
85 | |||
86 | public: | ||
87 | ParamProc(); | ||
88 | virtual ~ParamProc(); | ||
89 | |||
90 | void addParam( const char *lpWord, char cChar, Proc proc, ParamPtr val, | ||
91 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
92 | const char *lpValue=NULL | ||
93 | ); | ||
94 | void addParam( const char *lpWord, char cChar, Proc proc, | ||
95 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
96 | const char *lpValue=NULL | ||
97 | ); | ||
98 | void addParam( const char *lpWord, char cChar, ParamPtr val, | ||
99 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
100 | const char *lpValue=NULL | ||
101 | ); | ||
102 | |||
103 | void addParam( const char *lpWord, Proc proc, ParamPtr val, | ||
104 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
105 | const char *lpValue=NULL | ||
106 | ); | ||
107 | void addParam( const char *lpWord, Proc proc, | ||
108 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
109 | const char *lpValue=NULL | ||
110 | ); | ||
111 | void addParam( const char *lpWord, ParamPtr val, | ||
112 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
113 | const char *lpValue=NULL | ||
114 | ); | ||
115 | |||
116 | void addParam( char cChar, Proc proc, ParamPtr val, | ||
117 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
118 | const char *lpValue=NULL | ||
119 | ); | ||
120 | void addParam( char cChar, Proc proc, | ||
121 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
122 | const char *lpValue=NULL | ||
123 | ); | ||
124 | void addParam( char cChar, ParamPtr val, | ||
125 | const char *lpDesc=NULL, const char *lpExtra=NULL, | ||
126 | const char *lpValue=NULL | ||
127 | ); | ||
128 | |||
129 | void process( int argc, char *argv[] ); | ||
130 | void addHelpBanner( const char *sHelpBanner ); | ||
131 | |||
132 | private: | ||
133 | ArgSpec *checkWord( const char *arg ); | ||
134 | ArgSpec *checkLetr( const char arg ); | ||
135 | |||
136 | public: | ||
137 | virtual int cmdParam( int argc, char *argv[] ); | ||
138 | virtual int unknownParam( int argc, char *argv[] ); | ||
139 | virtual int help( int argc, char *argv[] ); | ||
140 | |||
141 | private: | ||
142 | typedef struct Banner | ||
143 | { | ||
144 | StaticString sBanner; | ||
145 | ArgSpec *pBefore; | ||
146 | } Banner; | ||
147 | std::list<Banner *> lBan; | ||
148 | std::list<ArgSpec *> lArg; | ||
149 | }; | ||
150 | |||
151 | #define mkproc( cls ) static_cast<int (ParamProc::*)( int, char *[])>(&cls) | ||
152 | |||
153 | #endif | ||