/[PAMELA software]/FCUtils/CmdLineParser/example_update_mode.cpp
ViewVC logotype

Contents of /FCUtils/CmdLineParser/example_update_mode.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Wed May 7 10:33:14 2008 UTC (16 years, 6 months ago) by nikolas
Branch: MAIN, first
CVS Tags: v1r00, HEAD
Changes since 1.1: +0 -0 lines
 An usefull command line parser

1 #include <iostream>
2 #include <string>
3
4 #include "CmdLineParser.h"
5
6
7 using std::string;
8 using namespace FCUtils;
9
10 int main(int argc, char ** argv ){
11
12 // A simple program to explain the usage of the CmdLineParser in
13 // UPDATE mode, i.e. the options are defined in the main the command
14 // line options are used just to update the default value used in
15 // the definition
16
17 // First of all get the singleton with the option map
18 Options *provaopt=Options::Get();
19 // Define the option. Set the option name, value and the help string
20 // -file
21 provaopt->SetOption("file","nofile",
22 " -file filename, the name of the input file");
23 // -test
24 provaopt->SetOption("test","false"," -test test option");
25 // -addtree
26 provaopt->SetOption("addtree","true"," -addtree , add tree");
27 // print the help
28 provaopt->Help();
29 // print the values in the option map
30 provaopt->Print();
31
32 cout << endl << "++++++++ After CmdLineParser creation +++++++" << endl;
33 // Create the parser object in UPDATE mode, i.e. the options have
34 // been definited already, the command line values will be used to
35 // update the Options singleton
36 CmdLineParser test(argc,argv,UPDATE);
37 // Print the values as entered
38 test.Print();
39 // Move the entered values to the Options singleton
40 test.MoveToOptions();
41
42 // Print the help again
43 provaopt->Help();
44 // Print the values as entered by command line
45 provaopt->Print();
46
47 // Get the value from the option using various way
48
49 // Use the GeOption methods of the Options class
50 string ps;
51 provaopt->GetOption("file") >> ps;
52 std::cout << " The filename : " << ps << endl;
53
54 // Use the [] operator
55 Options &popt=*Options::Get();
56 popt["file"] >> ps;
57 std::cout << " The filename : " << ps << endl;
58
59 return 0;
60
61
62 }

  ViewVC Help
Powered by ViewVC 1.1.23