From 5e386890b41fe043e2639b25b613831ef8362e7b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 29 Jun 2006 02:50:56 +0000 Subject: Completely removed the old, crappy pproc and replaced it with the new, shiny ParamProc class...it's soooo much better it makes me wanna' throw things... --- src/test/param.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/test/param.h | 21 +++++++++++++++++++++ src/test/params.cpp | 33 --------------------------------- 3 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 src/test/param.cpp create mode 100644 src/test/param.h delete mode 100644 src/test/params.cpp (limited to 'src/test') diff --git a/src/test/param.cpp b/src/test/param.cpp new file mode 100644 index 0000000..0641f90 --- /dev/null +++ b/src/test/param.cpp @@ -0,0 +1,40 @@ +#include "param.h" +#include + +Param::Param() +{ + addParam( "name", 's', mkproc( Param::printStuff ), &str ); + //addParam( "name", &str ); + addParam( "job", 'U', mkproc( Param::printStuff ) ); + + // --name=Bobo + // --job hello +} + +Param::~Param() +{ +} + +int Param::printStuff( int argc, char *argv[] ) +{ + printf("------------%02d-------------\n", argc ); + for( int j = 0; j < argc; j++ ) + { + printf("%d: %s\n", j, argv[j] ); + } + printf("---------------------------\n" ); + printf("SETVAR===\"%s\"\n", str.c_str() ); + + return 1; +} + +int main( int argc, char *argv[] ) +{ + printf("Starting...\n"); + Param p; + p.process( argc, argv ); + + //printf("Calling by hand...\n"); + //p.printStuff(); +} + diff --git a/src/test/param.h b/src/test/param.h new file mode 100644 index 0000000..2756b69 --- /dev/null +++ b/src/test/param.h @@ -0,0 +1,21 @@ +#ifndef PARAM_H +#define PARAM_H + +#include + +#include "paramproc.h" + +class Param : public ParamProc +{ +public: + Param(); + virtual ~Param(); + +private: + int printStuff( int argc, char *argv[] ); + + std::string str; + uint32_t uint32; +}; + +#endif diff --git a/src/test/params.cpp b/src/test/params.cpp deleted file mode 100644 index bb62047..0000000 --- a/src/test/params.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include "pproc.h" - -int main( int argc, char *argv[] ) -{ - bool bOn = false; - bool bOff = true; - bool bTog = false; - char cChar = '?'; - PPROC table[] = { - { "boolon", 'n', PPROC_BOOL_TRUE, NULL, &bOn, - "Set the bool on." }, - { "booloff", 'f', PPROC_BOOL_FALSE, NULL, &bOff, - "Set the bool off." }, - { "booltog", 't', PPROC_BOOL_TOGGLE, NULL, &bTog, - "Set the bool off." }, - { "char", 'c', PPROC_CHAR, NULL, &cChar, - "Set the char." }, - { NULL, '\0',0, NULL, NULL, - NULL } - }; - - processParams( argc, argv, table ); - - printf("Final results:\n"); - printf("\tbOn = %s\n", (bOn ? "true" : "false") ); - printf("\tbOff = %s\n", (bOff ? "true" : "false") ); - printf("\tbTog = %s\n", (bTog ? "true" : "false") ); - printf("\tcChar = '%c'\n", cChar ); - - return 0; -} - -- cgit v1.2.3