Skip to content

Commit 86487c7

Browse files
committed
Add example of zero_tokens
[SVN r45450]
1 parent 6cd68a2 commit 86487c7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

example/first.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,30 @@ int main(int ac, char* av[])
2121
desc.add_options()
2222
("help", "produce help message")
2323
("compression", po::value<int>(), "set compression level")
24+
("verbose", po::value<string>()->zero_tokens()->implicit_value(""))
2425
;
2526

26-
po::variables_map vm;
27+
po::variables_map vm;
2728
po::store(po::parse_command_line(ac, av, desc), vm);
28-
po::notify(vm);
29+
po::notify(vm);
2930

3031
if (vm.count("help")) {
3132
cout << desc << "\n";
3233
return 1;
3334
}
3435

3536
if (vm.count("compression")) {
36-
cout << "Compression level was set to "
37+
cout << "Compression level was set to "
3738
<< vm["compression"].as<int>() << ".\n";
3839
} else {
3940
cout << "Compression level was not set.\n";
4041
}
42+
43+
if (vm.count("verbose")) {
44+
string v = vm["verbose"].as<string>();
45+
if (v.size() > 0)
46+
cout << "Verbosity is: " << v << ".\n";
47+
}
4148
}
4249
catch(exception& e) {
4350
cerr << "error: " << e.what() << "\n";

0 commit comments

Comments
 (0)