diff options
Diffstat (limited to 'cli-examples')
-rw-r--r-- | cli-examples/build/root.build | 3 | ||||
-rw-r--r-- | cli-examples/features/driver.cxx | 25 | ||||
-rw-r--r-- | cli-examples/features/options.cli | 9 | ||||
-rw-r--r-- | cli-examples/manifest | 6 |
4 files changed, 30 insertions, 13 deletions
diff --git a/cli-examples/build/root.build b/cli-examples/build/root.build index 5f4b348..90a319a 100644 --- a/cli-examples/build/root.build +++ b/cli-examples/build/root.build @@ -16,7 +16,8 @@ if ($cxx.target.system == 'win32-msvc') if ($cxx.class == 'msvc') cxx.coptions += /wd4251 /wd4275 /wd4800 -using cli +if ($build.mode != 'skeleton') + using cli # Every exe{} in this project is by default a test. # diff --git a/cli-examples/features/driver.cxx b/cli-examples/features/driver.cxx index c14b5c7..fc364a0 100644 --- a/cli-examples/features/driver.cxx +++ b/cli-examples/features/driver.cxx @@ -2,6 +2,7 @@ // author : Boris Kolpackov <boris@codesynthesis.com> // license : MIT; see accompanying LICENSE file +#include <utility> // pair #include <iostream> #include <iterator> #include <algorithm> @@ -45,13 +46,27 @@ main (int argc, char* argv[]) // --map | -m // - typedef map<std::string, std::string> str_map; - const str_map& m = o.map (); - str_map::const_iterator i (m.find ("a")); + { + typedef map<string, bool> str_map; + const str_map& m = o.map (); + str_map::const_iterator i (m.find ("a")); - if (i != m.end ()) - cerr << "value for the 'a' key: " << i->second << endl; + if (i != m.end ()) + cerr << "value for the 'a' map key: " << i->second << endl; + } + // --multimap + // + { + typedef multimap<string, int> str_multimap; + const str_multimap& m = o.multimap (); + + pair<str_multimap::const_iterator, str_multimap::const_iterator> r ( + m.equal_range ("a")); + + for (str_multimap::const_iterator i (r.first); i != r.second; ++i) + cerr << "value for the 'a' multimap key: " << i->second << endl; + } } catch (const cli::exception& e) { diff --git a/cli-examples/features/options.cli b/cli-examples/features/options.cli index ea055b3..d1e4b0c 100644 --- a/cli-examples/features/options.cli +++ b/cli-examples/features/options.cli @@ -30,10 +30,11 @@ namespace features std::vector<int> --vector | -v; std::set<int> --set | -s; - // We can also use maps. In this case the option value is expected to have - // two parts: the key and the value, separated by '='. For example: -m a=A - // -m =B -m c= -m d (same as -m d=). + // We can also use maps and multimaps. In this case the option value is + // expected to have two parts: the key and the value, separated by '='. + // For example: -m a=1 -m =true -m c= -m d (same as -m d=). // - std::map<std::string, std::string> --map | -m; + std::map<std::string, bool> --map | -m; + std::multimap<std::string, int> --multimap; }; } diff --git a/cli-examples/manifest b/cli-examples/manifest index da9cc56..a7f30dd 100644 --- a/cli-examples/manifest +++ b/cli-examples/manifest @@ -1,6 +1,6 @@ : 1 name: cli-examples -version: 1.2.0-b.7.z +version: 1.2.0 project: cli summary: Examples of using the CLI language and compiler for C++ license: MIT @@ -10,5 +10,5 @@ doc-url: https://www.codesynthesis.com/projects/cli/doc/guide/ src-url: https://git.codesynthesis.com/cgit/cli/cli/tree/cli-examples/ email: cli-users@codesynthesis.com ; Mailing list requires: c++14 -depends: * build2 >= 0.13.0 -depends: * bpkg >= 0.13.0 +depends: * build2 >= 0.16.0 +depends: * bpkg >= 0.16.0 |