diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/tests/optparser.cpp | |
parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip |
Converted tabs to spaces with tabconv.
Diffstat (limited to '')
-rw-r--r-- | src/tests/optparser.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/src/tests/optparser.cpp b/src/tests/optparser.cpp index 772cebc..05e5168 100644 --- a/src/tests/optparser.cpp +++ b/src/tests/optparser.cpp | |||
@@ -12,82 +12,82 @@ using namespace Bu; | |||
12 | class Opts : public Bu::OptParser | 12 | class Opts : public Bu::OptParser |
13 | { | 13 | { |
14 | public: | 14 | public: |
15 | Opts() : | 15 | Opts() : |
16 | iBob( 542 ), | 16 | iBob( 542 ), |
17 | bVal( false ) | 17 | bVal( false ) |
18 | { | 18 | { |
19 | addHelpBanner("optparser - Test some option things..."); | 19 | addHelpBanner("optparser - Test some option things..."); |
20 | 20 | ||
21 | addHelpBanner("\nThis section represents options that actually have " | 21 | addHelpBanner("\nThis section represents options that actually have " |
22 | "callbacks, or in the case of the new system, signals/slots. They " | 22 | "callbacks, or in the case of the new system, signals/slots. They " |
23 | "all take parameters, but if they return 0 then it will be as " | 23 | "all take parameters, but if they return 0 then it will be as " |
24 | "though they hadn't and the next thing will be processed normally.", | 24 | "though they hadn't and the next thing will be processed normally.", |
25 | true | 25 | true |
26 | ); | 26 | ); |
27 | addOption( slot( this, &Opts::yesparam ), 'x', "things", | 27 | addOption( slot( this, &Opts::yesparam ), 'x', "things", |
28 | "This is the first test parameter. It calls a function, and " | 28 | "This is the first test parameter. It calls a function, and " |
29 | "takes a parameter." | 29 | "takes a parameter." |
30 | ); | 30 | ); |
31 | addOption( slot( this, &Opts::noparam ), 'y', "stuff", | 31 | addOption( slot( this, &Opts::noparam ), 'y', "stuff", |
32 | "This is the second test parameter. It does not take " | 32 | "This is the second test parameter. It does not take " |
33 | "parameters. However, I do want to make this part much longer to " | 33 | "parameters. However, I do want to make this part much longer to " |
34 | "see how it looks when you add way too much text to one of these " | 34 | "see how it looks when you add way too much text to one of these " |
35 | "things. It can't really be that bad, right?" | 35 | "things. It can't really be that bad, right?" |
36 | ); | 36 | ); |
37 | 37 | ||
38 | addHelpBanner("\nThis section represents options with no callback or " | 38 | addHelpBanner("\nThis section represents options with no callback or " |
39 | "signal, but do have a variable to update. They use the Formatter " | 39 | "signal, but do have a variable to update. They use the Formatter " |
40 | "system and therefore it's very, very flexible. Any data type " | 40 | "system and therefore it's very, very flexible. Any data type " |
41 | "you can read with a formatter you can set via parameter.", | 41 | "you can read with a formatter you can set via parameter.", |
42 | true | 42 | true |
43 | ); | 43 | ); |
44 | addOption( sVar, 's', "str", "Set a variable, see what it does."); | 44 | addOption( sVar, 's', "str", "Set a variable, see what it does."); |
45 | addOption( bVal, 'b', "bool", "It's a thing."); | 45 | addOption( bVal, 'b', "bool", "It's a thing."); |
46 | addOption( iBob, "bob", "Change iBob to whatever you want."); | 46 | addOption( iBob, "bob", "Change iBob to whatever you want."); |
47 | addOption( dBob, 'd', "Change dBob to whatever you want."); | 47 | addOption( dBob, 'd', "Change dBob to whatever you want."); |
48 | 48 | ||
49 | setOverride("str", "Bob!"); | 49 | setOverride("str", "Bob!"); |
50 | setHelpDefault("bob", "=542"); | 50 | setHelpDefault("bob", "=542"); |
51 | setOverride("bool", true ); | 51 | setOverride("bool", true ); |
52 | 52 | ||
53 | addHelpOption(); | 53 | addHelpOption(); |
54 | 54 | ||
55 | setNonOption( slot( this, &Opts::nonOption ) ); | 55 | setNonOption( slot( this, &Opts::nonOption ) ); |
56 | } | 56 | } |
57 | 57 | ||
58 | int yesparam( StrArray aParams ) | 58 | int yesparam( StrArray aParams ) |
59 | { | 59 | { |
60 | sio << " - yesparam" << aParams << sio.nl; | 60 | sio << " - yesparam" << aParams << sio.nl; |
61 | return 1; | 61 | return 1; |
62 | } | 62 | } |
63 | 63 | ||
64 | int noparam( StrArray aParams ) | 64 | int noparam( StrArray aParams ) |
65 | { | 65 | { |
66 | sio << " - noparam" << aParams << sio.nl; | 66 | sio << " - noparam" << aParams << sio.nl; |
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | int nonOption( StrArray aParams ) | 70 | int nonOption( StrArray aParams ) |
71 | { | 71 | { |
72 | sio << " - nonOption" << aParams << sio.nl; | 72 | sio << " - nonOption" << aParams << sio.nl; |
73 | return aParams.getSize()-1; | 73 | return aParams.getSize()-1; |
74 | } | 74 | } |
75 | 75 | ||
76 | int iBob; | 76 | int iBob; |
77 | float dBob; | 77 | float dBob; |
78 | Bu::String sVar; | 78 | Bu::String sVar; |
79 | bool bVal; | 79 | bool bVal; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | int main( int argc, char *argv[] ) | 82 | int main( int argc, char *argv[] ) |
83 | { | 83 | { |
84 | Opts o; | 84 | Opts o; |
85 | 85 | ||
86 | o.parse( argc, argv ); | 86 | o.parse( argc, argv ); |
87 | 87 | ||
88 | sio << "sVar = \"" << o.sVar << "\"" << sio.nl; | 88 | sio << "sVar = \"" << o.sVar << "\"" << sio.nl; |
89 | sio << "iBob = " << o.iBob << sio.nl; | 89 | sio << "iBob = " << o.iBob << sio.nl; |
90 | sio << "dBob = " << o.dBob << sio.nl; | 90 | sio << "dBob = " << o.dBob << sio.nl; |
91 | sio << "bVal = " << o.bVal << sio.nl; | 91 | sio << "bVal = " << o.bVal << sio.nl; |
92 | } | 92 | } |
93 | 93 | ||