0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
clanguml::common::or_regex< T > Struct Template Reference

Convenience class for configuration options with regex support. More...

Detailed Description

template<typename T>
struct clanguml::common::or_regex< T >

Convenience class for configuration options with regex support.

This template class provides a convenient way of handling configuraiton options, which can be either some basic type like std::string or regex.

Template Parameters
TType of alternative to regex (e.g. std::string)

Definition at line 276 of file types.h.

#include <types.h>

Public Member Functions

 or_regex ()=default
 
 or_regex (T v)
 Constructor from alternative type.
 
 or_regex (std::regex r, std::string p)
 Constructor from regex.
 
or_regexoperator= (const T &v)
 
or_regexoperator= (const regex &v)
 
bool operator== (const T &v) const
 
template<typename Ret >
std::optional< Ret > get () const
 
std::string to_string () const
 
const std::variant< T, regex > & value () const
 
bool is_regex () const
 

Private Attributes

std::variant< T, regexvalue_
 

Constructor & Destructor Documentation

◆ or_regex() [1/3]

template<typename T >
clanguml::common::or_regex< T >::or_regex ( )
default

◆ or_regex() [2/3]

template<typename T >
clanguml::common::or_regex< T >::or_regex ( v)
inline

Constructor from alternative type.

Definition at line 282 of file types.h.

283 : value_{std::move(v)}
284 {
285 }

◆ or_regex() [3/3]

template<typename T >
clanguml::common::or_regex< T >::or_regex ( std::regex  r,
std::string  p 
)
inline

Constructor from regex.

Parameters
rParsed regular expression
pRaw regular expression pattern used for regenerating config and debugging

Definition at line 294 of file types.h.

295 : value_{regex{std::move(r), std::move(p)}}
296 {
297 }

Member Function Documentation

◆ get()

template<typename T >
template<typename Ret >
std::optional< Ret > clanguml::common::or_regex< T >::get ( ) const
inline

Definition at line 319 of file types.h.

320 {
321 if (!std::holds_alternative<Ret>(value_))
322 return std::nullopt;
323
324 return std::get<Ret>(value_);
325 }

◆ is_regex()

template<typename T >
bool clanguml::common::or_regex< T >::is_regex ( ) const
inline

Definition at line 337 of file types.h.

337{ return std::holds_alternative<regex>(value_); }

◆ operator=() [1/2]

template<typename T >
or_regex & clanguml::common::or_regex< T >::operator= ( const regex v)
inline

Definition at line 305 of file types.h.

306 {
307 value_ = v;
308 return *this;
309 }

◆ operator=() [2/2]

template<typename T >
or_regex & clanguml::common::or_regex< T >::operator= ( const T &  v)
inline

Definition at line 299 of file types.h.

300 {
301 value_ = v;
302 return *this;
303 }

◆ operator==()

template<typename T >
bool clanguml::common::or_regex< T >::operator== ( const T &  v) const
inline

Definition at line 311 of file types.h.

312 {
313 if (std::holds_alternative<regex>(value_))
314 return std::regex_match(v, std::get<regex>(value_).regexp);
315
316 return std::get<T>(value_) == v;
317 }

◆ to_string()

template<typename T >
std::string clanguml::common::or_regex< T >::to_string ( ) const
inline

Definition at line 327 of file types.h.

328 {
329 if (std::holds_alternative<regex>(value_))
330 return std::get<regex>(value_).pattern;
331
332 return clanguml::common::to_string(std::get<T>(value_));
333 }

◆ value()

template<typename T >
const std::variant< T, regex > & clanguml::common::or_regex< T >::value ( ) const
inline

Definition at line 335 of file types.h.

335{ return value_; }

Member Data Documentation

◆ value_

template<typename T >
std::variant<T, regex> clanguml::common::or_regex< T >::value_
private

Definition at line 340 of file types.h.


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