ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
parser_options.hpp File Reference
#include <optional>
#include <string>
#include <map>
#include <vector>
#include <getopt.h>
#include <arkanjo/cli/cli_error.hpp>
+ Include dependency graph for parser_options.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CliOption
 
struct  ParsedOptions
 

Macros

#define OPTION_END   {nullptr, 0, NoArgument, nullptr}
 This marks the end of a long array of options. More...
 

Enumerations

enum  ArgumentsType { NoArgument , RequiredArgument , OptionalArgument , PositionalArgument }
 

Functions

bool parse_options (int argc, char *argv[], const std::vector< CliOption > &options, ParsedOptions &ctx_options)
 Analyzes command-line arguments and populates ParsedOptions. More...
 

Macro Definition Documentation

◆ OPTION_END

#define OPTION_END   {nullptr, 0, NoArgument, nullptr}

This marks the end of a long array of options.

Definition at line 27 of file parser_options.hpp.

Enumeration Type Documentation

◆ ArgumentsType

Enumerator
NoArgument 
RequiredArgument 
OptionalArgument 
PositionalArgument 

Definition at line 10 of file parser_options.hpp.

Function Documentation

◆ parse_options()

bool parse_options ( int  argc,
char *  argv[],
const std::vector< CliOption > &  options,
ParsedOptions &  ctx_options 
)

Analyzes command-line arguments and populates ParsedOptions.

It supports short (-c) and long (–config) options. Flags without arguments receive the value "true". Arguments that are not options are added to extra_args.

Parameters
argcNumber of arguments passed to the application.
argvVector of strings containing the arguments.
optionsArray of CliOption containing the options.
ctx_optionsReference to ParsedOptions that will be filled in.

Definition at line 45 of file parser_options.cpp.