blob: eebb5d08b42ef3cf2504345cea6fc1f690aac36c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// file : position/driver.cxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// license : MIT; see accompanying LICENSE file
// Test argument/option position.
//
#include <iostream>
#include "test.hxx"
using namespace std;
int
main (int argc, char* argv[])
{
try
{
cli::argv_file_scanner scan (argc, argv, "--file");
options ops (scan);
if (ops.a_specified ())
cout << ops.a ().second << ": " << "-a " << ops.a ().first << endl;
for (const pair<int, size_t>& b: ops.b ())
{
cout << b.second << ": " << "-b " << b.first << endl;
}
while (scan.more ())
{
// Note that calling position() inside `cout << ...` depends on order of
// argument evaluation.
//
size_t p (scan.position ());
cout << p << ": " << scan.next () << endl;
}
cout << "max: " << scan.position () << endl;
}
catch (const cli::exception& e)
{
cerr << e << endl;
}
}
|