PLaSK library
Loading...
Searching...
No Matches
plask::XMLReader::EnumAttributeReader< EnumT > Struct Template Reference

Enum attribute reader class. More...

#include <plask/utils/xml/reader.hpp>

Collaboration diagram for plask::XMLReader::EnumAttributeReader< EnumT >:
[legend]

Public Member Functions

 EnumAttributeReader (XMLReader &reader, const std::string &attr_name, bool case_sensitive=false)
 Create enum attribute reader.
 
EnumAttributeReadervalue (std::string key, EnumT val, std::size_t min=std::numeric_limits< std::size_t >::max())
 Add allowed parameter.
 
EnumT require ()
 Require attribute.
 
plask::optional< EnumTget ()
 Get attribute.
 
EnumT get (EnumT default_value)
 Get attribute with default value.
 

Protected Member Functions

EnumT parse (std::string value)
 

Protected Attributes

XMLReaderreader
 
const std::string attr_name
 
bool case_insensitive
 
std::map< std::string, EnumTvalues
 
std::string help
 

Detailed Description

template<typename EnumT>
struct plask::XMLReader::EnumAttributeReader< EnumT >

Enum attribute reader class.

Definition at line 185 of file reader.hpp.

Constructor & Destructor Documentation

◆ EnumAttributeReader()

template<typename EnumT >
plask::XMLReader::EnumAttributeReader< EnumT >::EnumAttributeReader ( XMLReader reader,
const std::string &  attr_name,
bool  case_sensitive = false 
)
inline

Create enum attribute reader.

Parameters
readerXML reader
attr_namename of the attribute
case_sensitivetrue if the attribute value should be case sensitive

Definition at line 212 of file reader.hpp.

Member Function Documentation

◆ get() [1/2]

template<typename EnumT >
plask::optional< EnumT > plask::XMLReader::EnumAttributeReader< EnumT >::get ( )
inline

Get attribute.

Returns
optional set if the attribute was specified

Definition at line 250 of file reader.hpp.

◆ get() [2/2]

template<typename EnumT >
EnumT plask::XMLReader::EnumAttributeReader< EnumT >::get ( EnumT  default_value)
inline

Get attribute with default value.

Parameters
default_valuedefault value of the attribute
Returns
optional set if the attribute was specified

Definition at line 261 of file reader.hpp.

◆ parse()

template<typename EnumT >
EnumT plask::XMLReader::EnumAttributeReader< EnumT >::parse ( std::string  value)
inlineprotected

Definition at line 196 of file reader.hpp.

◆ require()

template<typename EnumT >
EnumT plask::XMLReader::EnumAttributeReader< EnumT >::require ( )
inline

Require attribute.

Definition at line 242 of file reader.hpp.

◆ value()

template<typename EnumT >
EnumAttributeReader & plask::XMLReader::EnumAttributeReader< EnumT >::value ( std::string  key,
EnumT  val,
std::size_t  min = std::numeric_limits<std::size_t>::max() 
)
inline

Add allowed parameter.

Parameters
keytext representing the attribute value
valvalue of the attribute
minminimum number of letters in the attribute

Definition at line 221 of file reader.hpp.

Member Data Documentation

◆ attr_name

template<typename EnumT >
const std::string plask::XMLReader::EnumAttributeReader< EnumT >::attr_name
protected

Definition at line 190 of file reader.hpp.

◆ case_insensitive

template<typename EnumT >
bool plask::XMLReader::EnumAttributeReader< EnumT >::case_insensitive
protected

Definition at line 191 of file reader.hpp.

◆ help

template<typename EnumT >
std::string plask::XMLReader::EnumAttributeReader< EnumT >::help
protected

Definition at line 194 of file reader.hpp.

◆ reader

Definition at line 189 of file reader.hpp.

◆ values

template<typename EnumT >
std::map<std::string, EnumT> plask::XMLReader::EnumAttributeReader< EnumT >::values
protected

Definition at line 193 of file reader.hpp.


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