path: root/LICENSE
diff options
authorBoris Kolpackov <>2021-08-03 14:11:17 +0200
committerBoris Kolpackov <>2021-08-03 14:11:17 +0200
commit0426335af0e7577148903be7a2534c4ced06cd3b (patch)
tree9d7d1de01c9e438097cfd9d235f4df3206761b54 /LICENSE
parenta54c695583015812280228bcadca3057397d4dd0 (diff)
Add support for tracking argument/option positionHEADmaster
The scanner interface now provides the position() function that returns a monotonically-increasing number which, if stored, can later be used to determine the relative position of the arguments. There is also now a parser implementation for std::pair<T, std::size_t> which parses the value T into the first half of the pair and stores the option position in the second half. Together, this can be used to establish the relative position of different options, for example: class options { std::vector<std::pair<std::uint64_t, std::size>> --config-id; std::vector<std::pair<std::string, std::size>> --config-name; }; cli::argv_scanner scan (argc, argv); options ops (scan); // Iterate over --config-id and --config-name options in the order // specified by the user. // auto ii (ops.config_id ().begin ()); auto ni (ops.config_name ().begin ()); for (size_t i (0), n (scan.position ()); i != n; ++i) { if (ii != ops.config_id ().end () && ii->second == i) { // Handle *ii. ++ii; } if (ni != ops.config_name ().end () && ni->second == i) { // Handle *ni. ++ni; } }
Diffstat (limited to 'LICENSE')
0 files changed, 0 insertions, 0 deletions