From f4e0334480a115295452fa1efe2012351e6ef7ad Mon Sep 17 00:00:00 2001 From: Pavel Kryukov Date: Tue, 11 Sep 2018 15:01:57 +0300 Subject: [PATCH] Add start_index argument to 'parse' function Usual case for emulation programs, like sde or gdb, is to pass first arguments to the emulator, and let the guest application handle latter arguments. To support this behavior, we introduce an option to choose index of the first argument to be handled by POPL. By default it is 1, as it is usually corresponds to the binary name. --- include/popl.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/popl.hpp b/include/popl.hpp index 23cbb12..fad23b4 100644 --- a/include/popl.hpp +++ b/include/popl.hpp @@ -326,7 +326,8 @@ class OptionParser /// Parse the command line into the added Options /// @param argc command line argument count /// @param argv command line arguments - void parse(int argc, const char * const argv[]); + /// @param start_index index of starting argument + void parse(int argc, const char * const argv[], int start_index = 1); /// Produce a help message /// @param max_attribute show options up to this level (optional, advanced, expert) @@ -916,14 +917,14 @@ inline std::shared_ptr OptionParser::get_option(char short_name) const } -inline void OptionParser::parse(int argc, const char * const argv[]) +inline void OptionParser::parse(int argc, const char * const argv[], int start_index) { unknown_options_.clear(); non_option_args_.clear(); for (auto& opt : options_) opt->clear(); - for (int n=1; n