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