#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" #include "bu/membuf.h" #include "bu/formatter.h" namespace Bu { typedef Bu::Array StrArray; class OptParser { private: class _ValueProxy { public: _ValueProxy(); virtual ~_ValueProxy(); virtual void setValue( const Bu::FString & )=0; virtual _ValueProxy *clone()=0; }; template class ValueProxy : public _ValueProxy { public: ValueProxy( ptype &v ) : v( v ) { } virtual ~ValueProxy() { } virtual void setValue( const Bu::FString &sVal ) { Bu::MemBuf mb( sVal ); Bu::Formatter f( mb ); f >> v; } virtual _ValueProxy *clone() { return new ValueProxy( v ); } private: ptype &v; }; public: typedef Signal1 OptionSignal; class Option { public: Option(); Option( const Option &rSrc ); virtual ~Option(); char cOpt; Bu::FString sOpt; Bu::FString sHelp; OptionSignal sUsed; bool bShortHasParams; _ValueProxy *pProxy; Bu::FString sOverride; }; private: typedef Bu::List