OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::Option Class Reference

#include <options.hpp>

Public Types

enum  { MULTILINE = 0x8000000 }
 
enum  validate_status { STATUS_GOOD , STATUS_MULTILINE , STATUS_LENGTH }
 
enum  render_flags {
  RENDER_TRUNC_64 = (1 << 0) , RENDER_PASS_FMT = (1 << 1) , RENDER_NUMBER = (1 << 2) , RENDER_BRACKET = (1 << 3) ,
  RENDER_UNUSED = (1 << 4)
}
 

Public Member Functions

 OPENVPN_UNTAGGED_EXCEPTION (RejectedException)
 
 Option ()
 
template<typename T , typename... Args>
 Option (T first, Args... args)
 
void min_args (const size_t n) const
 
void exact_args (const size_t n) const
 
void validate_arg (const size_t index, const size_t max_len) const
 
bool is_multiline () const
 
std::string printable_directive () const
 
const std::string & get (const size_t index, const size_t max_len) const
 
std::string get_optional (const size_t index, const size_t max_len) const
 
std::string get_default (const size_t index, const size_t max_len, const std::string &default_value) const
 
const std::string * get_ptr (const size_t index, const size_t max_len) const
 
template<typename T >
get_num (const size_t idx) const
 
template<typename T >
get_num (const size_t idx, const T default_value) const
 
template<typename T >
get_num (const size_t idx, const T default_value, const T min_value, const T max_value) const
 
template<typename T >
get_num (const size_t idx, const T min_value, const T max_value) const
 
std::string render (const unsigned int flags) const
 
std::string escape (const bool csv) const
 
void clear ()
 
size_t size () const
 
bool empty () const
 
void push_back (const std::string &item)
 
void push_back (std::string &&item)
 
void reserve (const size_t n)
 
void resize (const size_t n)
 
const std::string & ref (const size_t i) const
 
std::string & ref (const size_t i)
 
bool operator== (const Option &other) const
 
bool operator!= (const Option &other) const
 
void remove_first (const size_t n_elements)
 
void touch (bool lightly=false) const
 
void enableWarnOnly ()
 
bool warnonlyunknown () const
 
bool touched () const
 
bool touched_lightly () const
 
std::string err_ref () const
 
void set_meta (bool value=true)
 
bool meta () const
 

Static Public Member Functions

static validate_status validate (const std::string &str, const size_t max_len)
 
static const char * validate_status_description (const validate_status status)
 
static void validate_string (const std::string &name, const std::string &str, const size_t max_len)
 
static void escape_string (std::ostream &out, const std::string &term, const bool must_quote)
 

Private Types

enum class  touchedState { NOT_TOUCHED , OPTION_OF_SAME_NAME_TOUCHED , TOUCHED }
 

Private Member Functions

void from_list (std::string arg)
 
void from_list (const char *arg)
 
void from_list (std::vector< std::string > arg)
 
template<typename T , typename... Args>
void from_list (T first, Args... args)
 
template<typename T >
void range_error (const size_t idx, const T min_value, const T max_value) const
 
bool must_quote_string (const std::string &str, const bool csv) const
 

Private Attributes

volatile touchedState touched_ = touchedState::NOT_TOUCHED
 
bool warn_only_if_unknown_ = false
 
bool meta_ = false
 
std::vector< std::string > data
 

Detailed Description

Definition at line 61 of file options.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MULTILINE 

Definition at line 65 of file options.hpp.

◆ render_flags

Enumerator
RENDER_TRUNC_64 
RENDER_PASS_FMT 
RENDER_NUMBER 
RENDER_BRACKET 
RENDER_UNUSED 

Definition at line 81 of file options.hpp.

◆ touchedState

enum class openvpn::Option::touchedState
strongprivate

Indicates that this option was used/consumed

Enumerator
NOT_TOUCHED 
OPTION_OF_SAME_NAME_TOUCHED 

Indicates that another option with the same name was considered. Ie, the option was not used because another option with same overrode it

TOUCHED 

Option has be used

Definition at line 498 of file options.hpp.

◆ validate_status

Enumerator
STATUS_GOOD 
STATUS_MULTILINE 
STATUS_LENGTH 

Definition at line 73 of file options.hpp.

Constructor & Destructor Documentation

◆ Option() [1/2]

openvpn::Option::Option ( )
inline

Definition at line 90 of file options.hpp.

◆ Option() [2/2]

template<typename T , typename... Args>
openvpn::Option::Option ( first,
Args...  args 
)
inlineexplicit

Definition at line 96 of file options.hpp.

Member Function Documentation

◆ clear()

void openvpn::Option::clear ( )
inline

Definition at line 318 of file options.hpp.

Here is the caller graph for this function:

◆ empty()

bool openvpn::Option::empty ( ) const
inline

Definition at line 331 of file options.hpp.

Here is the caller graph for this function:

◆ enableWarnOnly()

void openvpn::Option::enableWarnOnly ( )
inline

Definition at line 400 of file options.hpp.

Here is the caller graph for this function:

◆ err_ref()

std::string openvpn::Option::err_ref ( ) const
inline

Definition at line 425 of file options.hpp.

Here is the caller graph for this function:

◆ escape()

std::string openvpn::Option::escape ( const bool  csv) const
inline

Definition at line 302 of file options.hpp.

Here is the caller graph for this function:

◆ escape_string()

static void openvpn::Option::escape_string ( std::ostream &  out,
const std::string &  term,
const bool  must_quote 
)
inlinestatic

Definition at line 285 of file options.hpp.

Here is the caller graph for this function:

◆ exact_args()

void openvpn::Option::exact_args ( const size_t  n) const
inline

Definition at line 136 of file options.hpp.

Here is the caller graph for this function:

◆ from_list() [1/4]

void openvpn::Option::from_list ( const char *  arg)
inlineprivate

Definition at line 462 of file options.hpp.

◆ from_list() [2/4]

void openvpn::Option::from_list ( std::string  arg)
inlineprivate

Definition at line 457 of file options.hpp.

Here is the caller graph for this function:

◆ from_list() [3/4]

void openvpn::Option::from_list ( std::vector< std::string >  arg)
inlineprivate

Definition at line 467 of file options.hpp.

◆ from_list() [4/4]

template<typename T , typename... Args>
void openvpn::Option::from_list ( first,
Args...  args 
)
inlineprivate

Definition at line 473 of file options.hpp.

◆ get()

const std::string & openvpn::Option::get ( const size_t  index,
const size_t  max_len 
) const
inline

Definition at line 187 of file options.hpp.

Here is the caller graph for this function:

◆ get_default()

std::string openvpn::Option::get_default ( const size_t  index,
const size_t  max_len,
const std::string &  default_value 
) const
inline

Definition at line 203 of file options.hpp.

Here is the caller graph for this function:

◆ get_num() [1/4]

template<typename T >
T openvpn::Option::get_num ( const size_t  idx) const
inline

Definition at line 222 of file options.hpp.

Here is the caller graph for this function:

◆ get_num() [2/4]

template<typename T >
T openvpn::Option::get_num ( const size_t  idx,
const T  default_value 
) const
inline

Definition at line 238 of file options.hpp.

◆ get_num() [3/4]

template<typename T >
T openvpn::Option::get_num ( const size_t  idx,
const T  default_value,
const T  min_value,
const T  max_value 
) const
inline

Definition at line 247 of file options.hpp.

◆ get_num() [4/4]

template<typename T >
T openvpn::Option::get_num ( const size_t  idx,
const T  min_value,
const T  max_value 
) const
inline

Definition at line 256 of file options.hpp.

◆ get_optional()

std::string openvpn::Option::get_optional ( const size_t  index,
const size_t  max_len 
) const
inline

Definition at line 194 of file options.hpp.

Here is the caller graph for this function:

◆ get_ptr()

const std::string * openvpn::Option::get_ptr ( const size_t  index,
const size_t  max_len 
) const
inline

Definition at line 212 of file options.hpp.

Here is the caller graph for this function:

◆ is_multiline()

bool openvpn::Option::is_multiline ( ) const
inline

Definition at line 153 of file options.hpp.

◆ meta()

bool openvpn::Option::meta ( ) const
inline

This option has been parsed from a meta options like

OVPN_ACCESS_SERVER_USERNAME=username

Returns

Definition at line 451 of file options.hpp.

Here is the caller graph for this function:

◆ min_args()

void openvpn::Option::min_args ( const size_t  n) const
inline

Definition at line 129 of file options.hpp.

Here is the caller graph for this function:

◆ must_quote_string()

bool openvpn::Option::must_quote_string ( const std::string &  str,
const bool  csv 
) const
inlineprivate

Definition at line 485 of file options.hpp.

Here is the caller graph for this function:

◆ OPENVPN_UNTAGGED_EXCEPTION()

openvpn::Option::OPENVPN_UNTAGGED_EXCEPTION ( RejectedException  )

◆ operator!=()

bool openvpn::Option::operator!= ( const Option other) const
inline

Definition at line 367 of file options.hpp.

◆ operator==()

bool openvpn::Option::operator== ( const Option other) const
inline

Definition at line 363 of file options.hpp.

◆ printable_directive()

std::string openvpn::Option::printable_directive ( ) const
inline

Definition at line 172 of file options.hpp.

Here is the caller graph for this function:

◆ push_back() [1/2]

void openvpn::Option::push_back ( const std::string &  item)
inline

Definition at line 335 of file options.hpp.

Here is the caller graph for this function:

◆ push_back() [2/2]

void openvpn::Option::push_back ( std::string &&  item)
inline

Definition at line 339 of file options.hpp.

◆ range_error()

template<typename T >
void openvpn::Option::range_error ( const size_t  idx,
const T  min_value,
const T  max_value 
) const
inlineprivate

Definition at line 480 of file options.hpp.

Here is the caller graph for this function:

◆ ref() [1/2]

std::string & openvpn::Option::ref ( const size_t  i)
inline

Definition at line 357 of file options.hpp.

◆ ref() [2/2]

const std::string & openvpn::Option::ref ( const size_t  i) const
inline

Definition at line 353 of file options.hpp.

Here is the caller graph for this function:

◆ remove_first()

void openvpn::Option::remove_first ( const size_t  n_elements)
inline

Definition at line 373 of file options.hpp.

Here is the caller graph for this function:

◆ render()

std::string openvpn::Option::render ( const unsigned int  flags) const
inline

Definition at line 264 of file options.hpp.

Here is the caller graph for this function:

◆ reserve()

void openvpn::Option::reserve ( const size_t  n)
inline

Definition at line 343 of file options.hpp.

Here is the caller graph for this function:

◆ resize()

void openvpn::Option::resize ( const size_t  n)
inline

Definition at line 347 of file options.hpp.

Here is the caller graph for this function:

◆ set_meta()

void openvpn::Option::set_meta ( bool  value = true)
inline

Marks this option as parsed from a meta options like

OVPN_ACCESS_SERVER_USERNAME=username

Definition at line 441 of file options.hpp.

Here is the caller graph for this function:

◆ size()

size_t openvpn::Option::size ( ) const
inline

Definition at line 327 of file options.hpp.

Here is the caller graph for this function:

◆ touch()

void openvpn::Option::touch ( bool  lightly = false) const
inline

indicate that this option was processed

Parameters
lightlyan option of the same name has been used

Definition at line 385 of file options.hpp.

Here is the caller graph for this function:

◆ touched()

bool openvpn::Option::touched ( ) const
inline

Definition at line 411 of file options.hpp.

Here is the caller graph for this function:

◆ touched_lightly()

bool openvpn::Option::touched_lightly ( ) const
inline

Definition at line 418 of file options.hpp.

◆ validate()

static validate_status openvpn::Option::validate ( const std::string &  str,
const size_t  max_len 
)
inlinestatic

Definition at line 102 of file options.hpp.

Here is the caller graph for this function:

◆ validate_arg()

void openvpn::Option::validate_arg ( const size_t  index,
const size_t  max_len 
) const
inline

Definition at line 143 of file options.hpp.

Here is the caller graph for this function:

◆ validate_status_description()

static const char * openvpn::Option::validate_status_description ( const validate_status  status)
inlinestatic

Definition at line 114 of file options.hpp.

Here is the caller graph for this function:

◆ validate_string()

static void openvpn::Option::validate_string ( const std::string &  name,
const std::string &  str,
const size_t  max_len 
)
inlinestatic

Definition at line 165 of file options.hpp.

Here is the caller graph for this function:

◆ warnonlyunknown()

bool openvpn::Option::warnonlyunknown ( ) const
inline

Definition at line 405 of file options.hpp.

Member Data Documentation

◆ data

std::vector<std::string> openvpn::Option::data
private

Definition at line 513 of file options.hpp.

◆ meta_

bool openvpn::Option::meta_ = false
private

Definition at line 512 of file options.hpp.

◆ touched_

volatile touchedState openvpn::Option::touched_ = touchedState::NOT_TOUCHED
mutableprivate

Definition at line 509 of file options.hpp.

◆ warn_only_if_unknown_

bool openvpn::Option::warn_only_if_unknown_ = false
private

Definition at line 511 of file options.hpp.


The documentation for this class was generated from the following file: