ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Fields | Public Methods | List of all members
Option Struct Reference

#include <arguments.hpp>

Inheritance diagram for Option:
[legend]
Collaboration diagram for Option:
[legend]

Class Description

An option of a command line. Options are read "automatically" using their declaration information defined with externalized strings (resources) accessed through ALib Enum Records associated with enum elements of enum custom types.

However, such automatic read is limited due to the fact, that the simple values and flags defined with OptionDecl, can not provide the flexibility needed to perfectly parse options with a complex syntax.

In this case, the way out is to use custom code that invokes ReadOptions and then processes all options that may have remaining arguments left in the list. Using field Position further arguments may be consumed from CommandLine::ArgsLeft.
Note, "processing all options" may mean a nested loop. The outer is over the option types of OptionsFound, the inner is over the vector of options per type.

Definition at line 476 of file arguments.hpp.

Public Fields

List< String, Recycling::SharedArgs
 
OptionDeclDeclaration = nullptr
 
- Public Fields inherited from Parsed
CommandLineCmdLine
 
integer Position
 
integer QtyArgsConsumed
 

Public Methods

 Option (CommandLine *cmdLine)
 
ALIB_API bool Read (OptionDecl &decl, String &arg, const integer argNo)
 
- Public Methods inherited from Parsed
 Parsed (CommandLine *cmdLine)
 

Constructor & Destructor Documentation

◆ Option()

Option ( CommandLine cmdLine)
inline

Constructor

Parameters
cmdLineThe command line main object.

Definition at line 605 of file commandline.hpp.

Member Function Documentation

◆ Read()

bool Read ( OptionDecl decl,
String arg,
const integer  argNo 
)

Tries to read the object from the current CLI arg(s).

Note
Unlike the read methods Command::Read and Parameter::Read, this method expects the argument to test not only by number with argNo but as well with string parameter arg.
This redundancy is needed to easily implement shortcut options, that just replace a shortcut option read to another one, probably with a preset argument included.
Parameters
declThe declaration used for reading.
argThe argument string starting with one or two hyphens.
argNoThe position of reading.
Returns
The true on success, false otherwise.

Definition at line 69 of file arguments.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ Args

Arguments belonging to this option.

Definition at line 482 of file arguments.hpp.

◆ Declaration

OptionDecl* Declaration = nullptr

The declaration struct.

Definition at line 479 of file arguments.hpp.


The documentation for this struct was generated from the following files: