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

Annotation of /FCUtils/CmdLineParser/example_define_mode.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide 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 nikolas 1.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     // DEFINE mode, i.e. the options are not defined in the main. The command
14     // line options them self are used to define and to update the value used in
15     // the Options map singleton. Note that no help can be defined
16    
17     // First of all get the singleton with the option map
18     Options *provaopt=Options::Get();
19     // print the help. We are in DEFINE mode, no options have been
20     // definited the Options singleton will be empty
21     provaopt->Help();
22     // print the values in the option map. Same as for the help
23     provaopt->Print();
24    
25     cout << endl << "++++++++ After CmdLineParser creation +++++++" << endl;
26     // Create the parser object in DEFINE (default) mode, i.e. the
27     // options will be definited reading them from the command line.
28     CmdLineParser test(argc,argv);
29     // Print the values as entered
30     test.Print();
31     // Move the entered values to the Options singleton
32     test.MoveToOptions();
33    
34     // Print the help again
35     provaopt->Help();
36     // Print the values as entered by command line
37     provaopt->Print();
38    
39     // Get the value from the option using various way
40    
41     // Use the GeOption methods of the Options class
42     string ps;
43     provaopt->GetOption("file") >> ps;
44     std::cout << " The filename : " << ps << endl;
45    
46     // Use the [] operator
47     Options &popt=*Options::Get();
48     popt["file"] >> ps;
49     std::cout << " The filename : " << ps << endl;
50    
51     return 0;
52    
53    
54     }

  ViewVC Help
Powered by ViewVC 1.1.23