A structure used to represent an argument's description.
More...
#include <argument_descriptor.hpp>
|
| argument_descriptor (const std::string &name, const std::optional< std::string > &help) |
|
void | add_param (const std::string &name, const std::string &value) |
| Adds a parameter descriptor with the given string value.
|
|
template<c_writable T> |
void | add_param (const std::string &name, const T &value) |
| Adds a parameter descriptor with the given value.
|
|
template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>) |
void | add_range_param (const std::string &name, const R &range, const std::string_view delimiter=default_delimiter) |
| Adds a range parameter descriptor with the given value.
|
|
std::string | get_basic (const uint8_t indent_width, const std::optional< std::size_t > align_to=std::nullopt) const |
|
std::string | get (const uint8_t indent_width, std::optional< std::size_t > max_line_width=std::nullopt) const |
|
A structure used to represent an argument's description.
Definition at line 32 of file argument_descriptor.hpp.
◆ argument_descriptor()
ap::detail::argument_descriptor::argument_descriptor |
( |
const std::string & |
name, |
|
|
const std::optional< std::string > & |
help |
|
) |
| |
|
inline |
- Parameters
-
name | The string representation of the argument's name. |
help | An optional help message string. |
Definition at line 38 of file argument_descriptor.hpp.
◆ add_param() [1/2]
void ap::detail::argument_descriptor::add_param |
( |
const std::string & |
name, |
|
|
const std::string & |
value |
|
) |
| |
|
inline |
Adds a parameter descriptor with the given string value.
- Parameters
-
name | The parameter's name. |
value | The parameter's value's string representation. |
Definition at line 46 of file argument_descriptor.hpp.
◆ add_param() [2/2]
template<c_writable T>
void ap::detail::argument_descriptor::add_param |
( |
const std::string & |
name, |
|
|
const T & |
value |
|
) |
| |
|
inline |
Adds a parameter descriptor with the given value.
- Template Parameters
-
- Parameters
-
name | The parameter's name. |
value | The parameter's value. |
Definition at line 57 of file argument_descriptor.hpp.
◆ add_range_param()
template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
void ap::detail::argument_descriptor::add_range_param |
( |
const std::string & |
name, |
|
|
const R & |
range, |
|
|
const std::string_view |
delimiter = default_delimiter |
|
) |
| |
|
inline |
Adds a range parameter descriptor with the given value.
- Template Parameters
-
- Parameters
-
name | The parameter's name. |
range | The parameter value range. |
delimiter | The delimiter used to separate the range values. |
Definition at line 72 of file argument_descriptor.hpp.
◆ get()
std::string ap::detail::argument_descriptor::get |
( |
const uint8_t |
indent_width, |
|
|
std::optional< std::size_t > |
max_line_width = std::nullopt |
|
) |
| const |
|
inline |
Generates a full string representation of the argument descriptor, optionally formatted to fit within a specified maximum line width. The output includes the argument name, help message (if present), and any added parameters.
If no parameters are present, or the generated one-line representation fits within the max_line_width
, a single-line format is used: "<indent><arg-name> : <help-msg> (<param1>: <value1>, ...)"
Otherwise, a multi-line format is returned, listing each parameter on its own line with additional indentation.
- Parameters
-
indent_width | The number of spaces to insert before the argument name. |
max_line_width | Optional maximum number of characters allowed for the one-line representation. If the one-line output exceeds this, a multi-line format is used instead. |
- Returns
- A formatted string describing the argument and its parameters.
- Note
- The help message is only included if it is not
std::nullopt
.
Definition at line 120 of file argument_descriptor.hpp.
◆ get_basic()
std::string ap::detail::argument_descriptor::get_basic |
( |
const uint8_t |
indent_width, |
|
|
const std::optional< std::size_t > |
align_to = std::nullopt |
|
) |
| const |
|
inline |
- Parameters
-
indent_width | The indentation width. |
align_to | Optional minimum width for the argument name; if provided, the name will be left-aligned and padded with spaces to this width. |
- Returns
- A basic argument description in the format "<indent><arg-name> : <help-msg>"
- Note
- The help message will only be visible in the output if it's not
std::nullopt
Definition at line 86 of file argument_descriptor.hpp.
◆ help
std::optional<std::string> ap::detail::argument_descriptor::help |
◆ name
std::string ap::detail::argument_descriptor::name |
◆ params
The documentation for this class was generated from the following file: