From 0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 16 Dec 2009 23:54:13 +0000 Subject: Signals is even safer and works even better. Also, OptParser is nearly done. Now I just have to come up with a way to modify data that you already have, that sure was a nice feature of the old one, even if it was implemented in a silly way. --- src/optparser.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/optparser.h') diff --git a/src/optparser.h b/src/optparser.h index 39f048d..ed32e45 100644 --- a/src/optparser.h +++ b/src/optparser.h @@ -4,12 +4,16 @@ #include "bu/fstring.h" #include "bu/list.h" #include "bu/hash.h" +#include "bu/signals.h" +#include "bu/array.h" namespace Bu { + typedef Bu::Array StrArray; class OptParser { public: + typedef Signal1 OptionSignal; class Option { public: @@ -18,22 +22,21 @@ namespace Bu char cOpt; Bu::FString sOpt; - Bu::FString sDesc; + Bu::FString sHelp; + OptionSignal sUsed; + bool bShortHasParams; }; public: OptParser(); virtual ~OptParser(); - void parse( int argc, char *argv[] ); + void parse( int argc, char **argv ); void addOption( const Option &opt ); + void addHelpOption( char c, const Bu::FString &s, const Bu::FString &sHelp ); - template - void callback( c *pObj, int (c::*fnc)( int, char *[] ) ) - { - (pObj->*fnc)( 0, NULL ); - } + int optHelp( StrArray aParams ); private: Bu::FString format( const Bu::FString &sIn, int iWidth, int iIndent ); -- cgit v1.2.3