diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-21 15:29:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-21 15:29:02 +0200 |
commit | dd817b37a1139f0bbc1414c8b542734662c5da88 (patch) | |
tree | 4abd8a892e4751334a78ff90fde41061dc54b50c /tests/group/driver.cxx | |
parent | 6520b63cb25580420e477cba2c776b2639cbf21b (diff) |
Implement group_scanner
Diffstat (limited to 'tests/group/driver.cxx')
-rw-r--r-- | tests/group/driver.cxx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/group/driver.cxx b/tests/group/driver.cxx new file mode 100644 index 0000000..1077670 --- /dev/null +++ b/tests/group/driver.cxx @@ -0,0 +1,59 @@ +// file : tests/group/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +// Test group_scanner. +// + +#include <iostream> + +#include "test.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + try + { + using namespace cli; + + // Mode flags. + // + // 'g' -- don't handle groups. + // 's' -- skip arguments. + // + string m (argv[1]); + + argv_scanner as (--argc, ++argv); + group_scanner s (as); + + while (s.more ()) + { + if (m.find ('s') == string::npos) + { + const char* a (s.next ()); + cout << "'" << a << "'"; + } + else + s.skip (); + + if (m.find ('g') == string::npos) + { + scanner& gs (s.group ()); + while (gs.more ()) + cout << " '" << gs.next () << "'"; + } + + cout << endl; + } + + return 0; + } + catch (const cli::exception& e) + { + cerr << e << endl; + return 1; + } +} |