diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-21 13:19:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-21 13:19:18 +0200 |
commit | 6520b63cb25580420e477cba2c776b2639cbf21b (patch) | |
tree | b166ff171780389a0f079ae587dd8cc75fb0d68e /cli/runtime-header.cxx | |
parent | 1dea398d6f864c99b9e1c34e4a718239cfd3d8ac (diff) |
Guarantee validity of values returned by scanner for two arguments
Diffstat (limited to 'cli/runtime-header.cxx')
-rw-r--r-- | cli/runtime-header.cxx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/cli/runtime-header.cxx b/cli/runtime-header.cxx index 9861166..9f92262 100644 --- a/cli/runtime-header.cxx +++ b/cli/runtime-header.cxx @@ -246,7 +246,13 @@ generate_runtime_header (context& ctx) // scanner // - os << "class scanner" + os << "// Command line argument scanner interface." << endl + << "//" << endl + << "// The values returned by next() are guaranteed to be valid" << endl + << "// for the two previous arguments up until a call to a third" << endl + << "// peek() or next()." << endl + << "//" << endl + << "class scanner" << "{" << "public:" << endl << "virtual" << endl @@ -396,11 +402,16 @@ generate_runtime_header (context& ctx) << "const option_info* options_;" << "std::size_t options_count_;" << endl - << "std::string hold_;" - << "std::deque<std::string> args_;"; + << "std::deque<std::string> args_;" + << endl + << "// Circular buffer of two arguments." << endl + << "//" << endl + << "std::string hold_[2];" + << "std::size_t i_;"; if (!ctx.opt_sep.empty ()) - os << "bool skip_;"; + os << endl + << "bool skip_;"; os << "};"; } |