From f72c6e4b97afeb69d9ea4d743c0c302d647ea424 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 16 Dec 2009 20:10:58 +0000 Subject: The new signal/slots system is in place, and works from 0-5 parameters right now, I'll probably add more later on... I've also started on the replacement for ParamProc, OptParser. It should do everything that ParamProc did, only with less code, and much better. --- src/optparser.cpp | 39 ++++ src/optparser.h | 51 +++++ src/signals.h | 592 ++++++++++++++++++++++++++++++++++++++++++++++++ src/tests/optparser.cpp | 27 +++ src/tests/signals.cpp | 87 +++++++ src/tests/socket.cpp | 66 ++++++ 6 files changed, 862 insertions(+) create mode 100644 src/optparser.cpp create mode 100644 src/optparser.h create mode 100644 src/signals.h create mode 100644 src/tests/optparser.cpp create mode 100644 src/tests/signals.cpp create mode 100644 src/tests/socket.cpp (limited to 'src') diff --git a/src/optparser.cpp b/src/optparser.cpp new file mode 100644 index 0000000..2046792 --- /dev/null +++ b/src/optparser.cpp @@ -0,0 +1,39 @@ +#include "bu/optparser.h" + +Bu::OptParser::OptParser() +{ +} + +Bu::OptParser::~OptParser() +{ +} + +void Bu::OptParser::addOption( const Option &opt ) +{ + lOption.append( opt ); + if( opt.cOpt != '\0' ) + hsOption.insert( opt.cOpt, &lOption.last() ); + if( opt.sOpt ) + hlOption.insert( opt.sOpt, &lOption.last() ); + +} + +Bu::FString Bu::OptParser::format( const Bu::FString &sIn, int iWidth, + int iIndent ) +{ + +} + + +// +// Code for Bu::OptParser::Option +// + +Bu::OptParser::Option::Option() +{ +} + +Bu::OptParser::Option::~Option() +{ +} + diff --git a/src/optparser.h b/src/optparser.h new file mode 100644 index 0000000..39f048d --- /dev/null +++ b/src/optparser.h @@ -0,0 +1,51 @@ +#ifndef BU_OPT_PARSER_H +#define BU_OPT_PARSER_H + +#include "bu/fstring.h" +#include "bu/list.h" +#include "bu/hash.h" + +namespace Bu +{ + class OptParser + { + public: + class Option + { + public: + Option(); + virtual ~Option(); + + char cOpt; + Bu::FString sOpt; + Bu::FString sDesc; + }; + + public: + OptParser(); + virtual ~OptParser(); + + void parse( int argc, char *argv[] ); + + void addOption( const Option &opt ); + + template + void callback( c *pObj, int (c::*fnc)( int, char *[] ) ) + { + (pObj->*fnc)( 0, NULL ); + } + + private: + Bu::FString format( const Bu::FString &sIn, int iWidth, int iIndent ); + + typedef Bu::List