summaryrefslogtreecommitdiff
path: root/src/old/paramproc.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-06-07 19:56:20 +0000
committerMike Buland <eichlan@xagasoft.com>2007-06-07 19:56:20 +0000
commit9e8a4944e50fab432012878c66e1bdac20649f76 (patch)
tree412b0d49ae4086bb330045f9956513397b866807 /src/old/paramproc.h
parentc2e3879b965d297604804f03271ac71c8c5c81f3 (diff)
downloadlibbu++-9e8a4944e50fab432012878c66e1bdac20649f76.tar.gz
libbu++-9e8a4944e50fab432012878c66e1bdac20649f76.tar.bz2
libbu++-9e8a4944e50fab432012878c66e1bdac20649f76.tar.xz
libbu++-9e8a4944e50fab432012878c66e1bdac20649f76.zip
The Stream Filter archetecture is finished, it's actually much cooler than I
had anticipated, and much cleaner. I'll have to add some documentation to it, because it's not really obvious how any of it fits together from the outset, although I have to say that the bzip2 test program is the easiest general bzip2 compression program I've ever made...it just goes :) Decompression in Bu::BZip2 isn't finished yet, but that's ok, it's coming soon.
Diffstat (limited to 'src/old/paramproc.h')
-rw-r--r--src/old/paramproc.h153
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
9class ParamProc
10{
11public:
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
86public:
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
132private:
133 ArgSpec *checkWord( const char *arg );
134 ArgSpec *checkLetr( const char arg );
135
136public:
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
141private:
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