aboutsummaryrefslogtreecommitdiff
path: root/src/optparser.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/optparser.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/optparser.h b/src/optparser.h
index 2936a4b..7ec69e5 100644
--- a/src/optparser.h
+++ b/src/optparser.h
@@ -15,6 +15,7 @@
15#include "bu/array.h" 15#include "bu/array.h"
16#include "bu/membuf.h" 16#include "bu/membuf.h"
17#include "bu/formatter.h" 17#include "bu/formatter.h"
18#include "bu/variant.h"
18 19
19namespace Bu 20namespace Bu
20{ 21{
@@ -40,7 +41,8 @@ namespace Bu
40 _ValueProxy(); 41 _ValueProxy();
41 virtual ~_ValueProxy(); 42 virtual ~_ValueProxy();
42 43
43 virtual void setValue( const Bu::FString & )=0; 44 virtual void setValueFromStr( const Bu::FString & )=0;
45 virtual void setValue( const Bu::Variant &vVar )=0;
44 virtual _ValueProxy *clone()=0; 46 virtual _ValueProxy *clone()=0;
45 }; 47 };
46 48
@@ -57,12 +59,28 @@ namespace Bu
57 { 59 {
58 } 60 }
59 61
60 virtual void setValue( const Bu::FString &sVal ) 62 virtual void setValueFromStr( const Bu::FString &sVal )
61 { 63 {
62 Bu::MemBuf mb( sVal ); 64 Bu::MemBuf mb( sVal );
63 Bu::Formatter f( mb ); 65 Bu::Formatter f( mb );
64 f >> v; 66 f >> v;
65 } 67 }
68
69 virtual void setValue( const Bu::Variant &vVar )
70 {
71 if( vVar.getType() == typeid(ptype) )
72 {
73 v = vVar.get<ptype>();
74 }
75 else if( vVar.getType() == typeid(Bu::FString) )
76 {
77 setValueFromStr( vVar.get<Bu::FString>() );
78 }
79 else
80 {
81 setValueFromStr( vVar.toString() );
82 }
83 }
66 84
67 virtual _ValueProxy *clone() 85 virtual _ValueProxy *clone()
68 { 86 {
@@ -87,7 +105,7 @@ namespace Bu
87 Bu::FString sHelp; 105 Bu::FString sHelp;
88 OptionSignal sUsed; 106 OptionSignal sUsed;
89 _ValueProxy *pProxy; 107 _ValueProxy *pProxy;
90 Bu::FString sOverride; 108 Bu::Variant sOverride;
91 Bu::FString sHelpDefault; 109 Bu::FString sHelpDefault;
92 }; 110 };
93 111
@@ -162,9 +180,9 @@ namespace Bu
162 addOption( sUsed, cOpt, "", sHelp ); 180 addOption( sUsed, cOpt, "", sHelp );
163 } 181 }
164 182
165 void setOverride( char cOpt, const Bu::FString &sOverride ); 183 void setOverride( char cOpt, const Bu::Variant &sOverride );
166 void setOverride( const Bu::FString &sOpt, 184 void setOverride( const Bu::FString &sOpt,
167 const Bu::FString &sOverride ); 185 const Bu::Variant &sOverride );
168 186
169 void setHelpDefault( const Bu::FString &sOpt, const Bu::FString &sTxt ); 187 void setHelpDefault( const Bu::FString &sOpt, const Bu::FString &sTxt );
170 188