Documentation for microsoft::quantum::ParameterParser

microsoft::quantum::ParameterParser

More...

#include <Commandline/ParameterParser.hpp>

Public Types

Name
using std::vector< String > Arguments
using std::unordered_set< String > Flags
using std::unordered_map< String, String > SettingsMap
using std::unordered_set< String > UnusedSettings
using std::unordered_map< String, String > ShorthandNotation

Public Functions

Name
ParameterParser() =default
ParameterParser(ParameterParser const & other)
ParameterParser(ParameterParser && other) =default
~ParameterParser() =default
void addFlag(String const & v)
void parseArgs(int argc, char const ** argv)
Arguments const & arguments() const
String const & getArg(Arguments::size_type const & n) const
Returns the n'th commandline argument.
String const & get(String const & name, String const & default_value)
Gets a named setting, falling back to a default if the key is not found.
String const & get(String const & name)
Gets a named setting. This method throws if the setting is not present.
void markAsUsed(String const & name)
Marks a flag as used.
bool has(String const & name) const
Checks whether or not a given parameter is present.
void reset()
Resets the state of the parser to its construction state.
UnusedSettings const & unusedSettings() const
Lists unknown settings.
void addShorthandNotation(String const & parameter, String const & shorthand)
Adds short hand notation to paramters.

Detailed Description

class microsoft::quantum::ParameterParser;

Parameter parser class which allows the developer to specify a set of default settings and update those using the commandline argc and argv.

Public Types Documentation

using Arguments

using microsoft::quantum::ParameterParser::Arguments =  std::vector<String>;

using Flags

using microsoft::quantum::ParameterParser::Flags =  std::unordered_set<String>;

using SettingsMap

using microsoft::quantum::ParameterParser::SettingsMap =  std::unordered_map<String, String>;

using UnusedSettings

using microsoft::quantum::ParameterParser::UnusedSettings =  std::unordered_set<String>;

using ShorthandNotation

using microsoft::quantum::ParameterParser::ShorthandNotation =  std::unordered_map<String, String>;

Public Functions Documentation

function ParameterParser

ParameterParser() =default

function ParameterParser

ParameterParser(
    ParameterParser const & other
)

function ParameterParser

ParameterParser(
    ParameterParser && other
) =default

function ~ParameterParser

~ParameterParser() =default

function addFlag

void addFlag(
    String const & v
)

Marks a name as a flag (as opposed to an option). This ensures that no parameter is expected after the flag is specified. For instance --debug is a flag as opposed to --log-level 3 which is an option.

function parseArgs

void parseArgs(
    int argc,
    char const ** argv
)

Parses the command line arguments given the argc and argv from the main function.

function arguments

Arguments const  & arguments() const

Returns list of arguments without flags and/or options included.

function getArg

String const  & getArg(
    Arguments::size_type const & n
) const

Returns the n'th commandline argument.

function get

String const  & get(
    String const & name,
    String const & default_value
)

Gets a named setting, falling back to a default if the key is not found.

function get

String const  & get(
    String const & name
)

Gets a named setting. This method throws if the setting is not present.

function markAsUsed

void markAsUsed(
    String const & name
)

Marks a flag as used.

function has

bool has(
    String const & name
) const

Checks whether or not a given parameter is present.

function reset

void reset()

Resets the state of the parser to its construction state.

function unusedSettings

UnusedSettings const  & unusedSettings() const

Lists unknown settings.

function addShorthandNotation

void addShorthandNotation(
    String const & parameter,
    String const & shorthand
)

Adds short hand notation to paramters.


Updated on 1 August 2023 at 16:25:10 UTC