Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Add start_index argument to 'parse' function
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pavelkryukov authored and badaix committed Aug 2, 2021
1 parent 68074f2 commit f4e0334
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/popl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -916,14 +917,14 @@ inline std::shared_ptr<T> 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<argc; ++n)
for (int n=start_index; n<argc; ++n)
{
const std::string arg(argv[n]);
if (arg == "--")
Expand Down

0 comments on commit f4e0334

Please sign in to comment.