Boost logo

Boost-Commit :

From: ghost_at_[hidden]
Date: 2008-05-17 03:28:17


Author: vladimir_prus
Date: 2008-05-17 03:28:17 EDT (Sat, 17 May 2008)
New Revision: 45450
URL: http://svn.boost.org/trac/boost/changeset/45450

Log:
Add example of zero_tokens
Text files modified:
   branches/release/libs/program_options/example/first.cpp | 13 ++++++++++---
   1 files changed, 10 insertions(+), 3 deletions(-)

Modified: branches/release/libs/program_options/example/first.cpp
==============================================================================
--- branches/release/libs/program_options/example/first.cpp (original)
+++ branches/release/libs/program_options/example/first.cpp 2008-05-17 03:28:17 EDT (Sat, 17 May 2008)
@@ -21,11 +21,12 @@
         desc.add_options()
             ("help", "produce help message")
             ("compression", po::value<int>(), "set compression level")
+ ("verbose", po::value<string>()->zero_tokens()->implicit_value(""))
         ;
 
- po::variables_map vm;
+ po::variables_map vm;
         po::store(po::parse_command_line(ac, av, desc), vm);
- po::notify(vm);
+ po::notify(vm);
 
         if (vm.count("help")) {
             cout << desc << "\n";
@@ -33,11 +34,17 @@
         }
 
         if (vm.count("compression")) {
- cout << "Compression level was set to "
+ cout << "Compression level was set to "
                  << vm["compression"].as<int>() << ".\n";
         } else {
             cout << "Compression level was not set.\n";
         }
+
+ if (vm.count("verbose")) {
+ string v = vm["verbose"].as<string>();
+ if (v.size() > 0)
+ cout << "Verbosity is: " << v << ".\n";
+ }
     }
     catch(exception& e) {
         cerr << "error: " << e.what() << "\n";


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk