llarp::OptionDefinitionBase

A base class for specifying config options and their constraints. More...

#include <definition.hpp>

Inherited by llarp::OptionDefinition< T >

Public Functions

Name
template <typename... T>
OptionDefinitionBase(std::string section_, std::string name_, const T & ...)
virtual ~OptionDefinitionBase() =default
virtual std::vector< std::string > defaultValuesAsString() =0
Subclasses should provide their default value as a string.
virtual void parseValue(const std::string & input) =0
Subclasses should parse and store the provided input.
virtual size_t getNumberFound() const =0
Subclasses should provide the number of values found.
virtual std::vector< std::string > valuesAsString() =0
Subclasess should write their parsed values as strings.
virtual void tryAccept() const =0
Subclassess should call their acceptor, if present.

Public Attributes

Name
std::string section
std::string name
bool required
bool multiValued
bool deprecated
bool hidden
bool relayOnly
bool clientOnly
std::vector< std::string > comments

Detailed Description

struct llarp::OptionDefinitionBase;

A base class for specifying config options and their constraints.

The basic to/from string type functions are provided pure-virtual. The type-aware implementations which implement these functions are templated classes. One reason for providing a non-templated base class is so that they can all be mixed into the same containers (albiet as pointers).

Public Functions Documentation

function OptionDefinitionBase

template <typename... T>
inline OptionDefinitionBase(
    std::string section_,
    std::string name_,
    const T & ...
)

function ~OptionDefinitionBase

virtual ~OptionDefinitionBase() =default

function defaultValuesAsString

virtual std::vector< std::string > defaultValuesAsString() =0

Subclasses should provide their default value as a string.

Return: the option's default value represented as a string

Reimplemented by: llarp::OptionDefinition::defaultValuesAsString

function parseValue

virtual void parseValue(
    const std::string & input
) =0

Subclasses should parse and store the provided input.

Parameters:

  • input is the string input to interpret

Reimplemented by: llarp::OptionDefinition::parseValue

function getNumberFound

virtual size_t getNumberFound() const =0

Subclasses should provide the number of values found.

Return: number of values found

Reimplemented by: llarp::OptionDefinition::getNumberFound

function valuesAsString

virtual std::vector< std::string > valuesAsString() =0

Subclasess should write their parsed values as strings.

Return: the option's value(s) as strings

Reimplemented by: llarp::OptionDefinition::valuesAsString

function tryAccept

virtual void tryAccept() const =0

Subclassess should call their acceptor, if present.

Exceptions:

  • if the acceptor throws or the option is required but missing

Reimplemented by: llarp::OptionDefinition::tryAccept

See OptionDefinition for more details.

Public Attributes Documentation

variable section

std::string section;

variable name

std::string name;

variable required

bool required = false;

variable multiValued

bool multiValued = false;

variable deprecated

bool deprecated = false;

variable hidden

bool hidden = false;

variable relayOnly

bool relayOnly = false;

variable clientOnly

bool clientOnly = false;

variable comments

std::vector< std::string > comments;

Updated on 2026-01-10 at 22:49:45 +0000