---
title: llarp::OptionDefinitionBase
summary: A base class for specifying config options and their constraints. 

---

# llarp::OptionDefinitionBase



A base class for specifying config options and their constraints.  [More...](#detailed-description)


`#include <definition.hpp>`

Inherited by [llarp::OptionDefinition< T >](Classes/structllarp_1_1OptionDefinition.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| template <typename... T\> <br>| **[OptionDefinitionBase](Classes/structllarp_1_1OptionDefinitionBase.md#function-optiondefinitionbase)**(std::string section_, std::string name_, const T & ...) |
| virtual | **[~OptionDefinitionBase](Classes/structllarp_1_1OptionDefinitionBase.md#function-~optiondefinitionbase)**() =default |
| virtual std::vector< std::string > | **[defaultValuesAsString](Classes/structllarp_1_1OptionDefinitionBase.md#function-defaultvaluesasstring)**() =0<br>Subclasses should provide their default value as a string.  |
| virtual void | **[parseValue](Classes/structllarp_1_1OptionDefinitionBase.md#function-parsevalue)**(const std::string & input) =0<br>Subclasses should parse and store the provided input.  |
| virtual size_t | **[getNumberFound](Classes/structllarp_1_1OptionDefinitionBase.md#function-getnumberfound)**() const =0<br>Subclasses should provide the number of values found.  |
| virtual std::vector< std::string > | **[valuesAsString](Classes/structllarp_1_1OptionDefinitionBase.md#function-valuesasstring)**() =0<br>Subclasess should write their parsed values as strings.  |
| virtual void | **[tryAccept](Classes/structllarp_1_1OptionDefinitionBase.md#function-tryaccept)**() const =0<br>Subclassess should call their acceptor, if present.  |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| std::string | **[section](Classes/structllarp_1_1OptionDefinitionBase.md#variable-section)**  |
| std::string | **[name](Classes/structllarp_1_1OptionDefinitionBase.md#variable-name)**  |
| bool | **[required](Classes/structllarp_1_1OptionDefinitionBase.md#variable-required)**  |
| bool | **[multiValued](Classes/structllarp_1_1OptionDefinitionBase.md#variable-multivalued)**  |
| bool | **[deprecated](Classes/structllarp_1_1OptionDefinitionBase.md#variable-deprecated)**  |
| bool | **[hidden](Classes/structllarp_1_1OptionDefinitionBase.md#variable-hidden)**  |
| bool | **[relayOnly](Classes/structllarp_1_1OptionDefinitionBase.md#variable-relayonly)**  |
| bool | **[clientOnly](Classes/structllarp_1_1OptionDefinitionBase.md#variable-clientonly)**  |
| std::vector< std::string > | **[comments](Classes/structllarp_1_1OptionDefinitionBase.md#variable-comments)**  |

## Detailed Description

```cpp
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

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


### function ~OptionDefinitionBase

```cpp
virtual ~OptionDefinitionBase() =default
```


### function defaultValuesAsString

```cpp
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](Classes/structllarp_1_1OptionDefinition.md#function-defaultvaluesasstring)


### function parseValue

```cpp
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](Classes/structllarp_1_1OptionDefinition.md#function-parsevalue)


### function getNumberFound

```cpp
virtual size_t getNumberFound() const =0
```

Subclasses should provide the number of values found. 

**Return**: number of values found 

**Reimplemented by**: [llarp::OptionDefinition::getNumberFound](Classes/structllarp_1_1OptionDefinition.md#function-getnumberfound)


### function valuesAsString

```cpp
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](Classes/structllarp_1_1OptionDefinition.md#function-valuesasstring)


### function tryAccept

```cpp
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](Classes/structllarp_1_1OptionDefinition.md#function-tryaccept)


See [OptionDefinition](Classes/structllarp_1_1OptionDefinition.md) for more details.


## Public Attributes Documentation

### variable section

```cpp
std::string section;
```


### variable name

```cpp
std::string name;
```


### variable required

```cpp
bool required = false;
```


### variable multiValued

```cpp
bool multiValued = false;
```


### variable deprecated

```cpp
bool deprecated = false;
```


### variable hidden

```cpp
bool hidden = false;
```


### variable relayOnly

```cpp
bool relayOnly = false;
```


### variable clientOnly

```cpp
bool clientOnly = false;
```


### variable comments

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


-------------------------------

Updated on 2023-03-26 at 04:03:14 +0000