aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/param.cpp40
-rw-r--r--src/test/param.h21
-rw-r--r--src/test/params.cpp33
3 files changed, 61 insertions, 33 deletions
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 @@
1#include "param.h"
2#include <stdio.h>
3
4Param::Param()
5{
6 addParam( "name", 's', mkproc( Param::printStuff ), &str );
7 //addParam( "name", &str );
8 addParam( "job", 'U', mkproc( Param::printStuff ) );
9
10 // --name=Bobo
11 // --job hello
12}
13
14Param::~Param()
15{
16}
17
18int Param::printStuff( int argc, char *argv[] )
19{
20 printf("------------%02d-------------\n", argc );
21 for( int j = 0; j < argc; j++ )
22 {
23 printf("%d: %s\n", j, argv[j] );
24 }
25 printf("---------------------------\n" );
26 printf("SETVAR===\"%s\"\n", str.c_str() );
27
28 return 1;
29}
30
31int main( int argc, char *argv[] )
32{
33 printf("Starting...\n");
34 Param p;
35 p.process( argc, argv );
36
37 //printf("Calling by hand...\n");
38 //p.printStuff();
39}
40
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 @@
1#ifndef PARAM_H
2#define PARAM_H
3
4#include <stdint.h>
5
6#include "paramproc.h"
7
8class Param : public ParamProc
9{
10public:
11 Param();
12 virtual ~Param();
13
14private:
15 int printStuff( int argc, char *argv[] );
16
17 std::string str;
18 uint32_t uint32;
19};
20
21#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 @@
1#include <stdio.h>
2#include "pproc.h"
3
4int main( int argc, char *argv[] )
5{
6 bool bOn = false;
7 bool bOff = true;
8 bool bTog = false;
9 char cChar = '?';
10 PPROC table[] = {
11 { "boolon", 'n', PPROC_BOOL_TRUE, NULL, &bOn,
12 "Set the bool on." },
13 { "booloff", 'f', PPROC_BOOL_FALSE, NULL, &bOff,
14 "Set the bool off." },
15 { "booltog", 't', PPROC_BOOL_TOGGLE, NULL, &bTog,
16 "Set the bool off." },
17 { "char", 'c', PPROC_CHAR, NULL, &cChar,
18 "Set the char." },
19 { NULL, '\0',0, NULL, NULL,
20 NULL }
21 };
22
23 processParams( argc, argv, table );
24
25 printf("Final results:\n");
26 printf("\tbOn = %s\n", (bOn ? "true" : "false") );
27 printf("\tbOff = %s\n", (bOff ? "true" : "false") );
28 printf("\tbTog = %s\n", (bTog ? "true" : "false") );
29 printf("\tcChar = '%c'\n", cChar );
30
31 return 0;
32}
33