SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
kvpp::KV1ElementBase< S, K > Class Template Reference

#include <KV1.h>

Inheritance diagram for kvpp::KV1ElementBase< S, K >:
Collaboration diagram for kvpp::KV1ElementBase< S, K >:

Public Member Functions

std::string_view getKey () const
 Get the key associated with the element.
 
std::string_view getValue () const
 Get the value associated with the element.
 
template<KV1ValueType V>
getValue () const
 Get the value associated with the element as the given type.
 
std::string_view getConditional () const
 Get the conditional associated with the element.
 
bool hasChild (std::string_view childKey) const
 Check if the element has one or more children with the given name.
 
uint64_t getChildCount () const
 Get the number of child elements.
 
uint64_t getChildCount (std::string_view childKey) const
 Get the number of child elements with the given key.
 
const std::vector< K > & getChildren () const
 Get the child elements of the element.
 
const KV1ElementBaseoperator[] (unsigned int n) const
 Get the child element of the element at the given index.
 
const KV1ElementBaseoperator[] (std::string_view childKey) const
 Get the first child element of the element with the given key.
 
const KV1ElementBaseoperator() (std::string_view childKey) const
 Get the first child element of the element with the given key.
 
const KV1ElementBaseoperator() (std::string_view childKey, unsigned int n) const
 Get the nth child element of the element with the given key.
 
bool isInvalid () const
 Check if the given element is invalid.
 

Protected Member Functions

 KV1ElementBase ()=default
 

Static Protected Member Functions

static const KV1ElementBasegetInvalid ()
 
static void read (BufferStreamReadOnly &stream, BufferStream &backing, std::vector< K > &elements, const sourcepp::parser::text::EscapeSequenceMap &escapeSequences)
 

Protected Attributes

key = ""
 
value = ""
 
conditional = ""
 
std::vector< K > children
 

Detailed Description

template<typename S, typename K>
requires std::convertible_to<S, std::string_view>
class kvpp::KV1ElementBase< S, K >

Definition at line 24 of file KV1.h.

Constructor & Destructor Documentation

◆ KV1ElementBase()

template<typename S , typename K >
kvpp::KV1ElementBase< S, K >::KV1ElementBase ( )
protecteddefault

Member Function Documentation

◆ getChildCount() [1/2]

template<typename S , typename K >
uint64_t kvpp::KV1ElementBase< S, K >::getChildCount ( ) const
inline

Get the number of child elements.

Definition at line 70 of file KV1.h.

◆ getChildCount() [2/2]

template<typename S , typename K >
uint64_t kvpp::KV1ElementBase< S, K >::getChildCount ( std::string_view  childKey) const
inline

Get the number of child elements with the given key.

Definition at line 75 of file KV1.h.

◆ getChildren()

template<typename S , typename K >
const std::vector< K > & kvpp::KV1ElementBase< S, K >::getChildren ( ) const
inline

Get the child elements of the element.

Definition at line 86 of file KV1.h.

◆ getConditional()

template<typename S , typename K >
std::string_view kvpp::KV1ElementBase< S, K >::getConditional ( ) const
inline

Get the conditional associated with the element.

Definition at line 60 of file KV1.h.

◆ getInvalid()

template<typename S , typename K >
static const KV1ElementBase & kvpp::KV1ElementBase< S, K >::getInvalid ( )
inlinestaticprotected

Definition at line 132 of file KV1.h.

◆ getKey()

template<typename S , typename K >
std::string_view kvpp::KV1ElementBase< S, K >::getKey ( ) const
inline

Get the key associated with the element.

Definition at line 27 of file KV1.h.

◆ getValue() [1/2]

template<typename S , typename K >
std::string_view kvpp::KV1ElementBase< S, K >::getValue ( ) const
inline

Get the value associated with the element.

Definition at line 32 of file KV1.h.

◆ getValue() [2/2]

template<typename S , typename K >
template<KV1ValueType V>
V kvpp::KV1ElementBase< S, K >::getValue ( ) const
inline

Get the value associated with the element as the given type.

Definition at line 38 of file KV1.h.

◆ hasChild()

template<typename S , typename K >
bool kvpp::KV1ElementBase< S, K >::hasChild ( std::string_view  childKey) const
inline

Check if the element has one or more children with the given name.

Definition at line 65 of file KV1.h.

◆ isInvalid()

template<typename S , typename K >
bool kvpp::KV1ElementBase< S, K >::isInvalid ( ) const
inline

Check if the given element is invalid.

Definition at line 125 of file KV1.h.

◆ operator()() [1/2]

template<typename S , typename K >
const KV1ElementBase & kvpp::KV1ElementBase< S, K >::operator() ( std::string_view  childKey) const
inline

Get the first child element of the element with the given key.

Definition at line 101 of file KV1.h.

◆ operator()() [2/2]

template<typename S , typename K >
const KV1ElementBase & kvpp::KV1ElementBase< S, K >::operator() ( std::string_view  childKey,
unsigned int  n 
) const
inline

Get the nth child element of the element with the given key.

Definition at line 111 of file KV1.h.

◆ operator[]() [1/2]

template<typename S , typename K >
const KV1ElementBase & kvpp::KV1ElementBase< S, K >::operator[] ( std::string_view  childKey) const
inline

Get the first child element of the element with the given key.

Definition at line 96 of file KV1.h.

◆ operator[]() [2/2]

template<typename S , typename K >
const KV1ElementBase & kvpp::KV1ElementBase< S, K >::operator[] ( unsigned int  n) const
inline

Get the child element of the element at the given index.

Definition at line 91 of file KV1.h.

◆ read()

template<typename S , typename K >
static void kvpp::KV1ElementBase< S, K >::read ( BufferStreamReadOnly &  stream,
BufferStream &  backing,
std::vector< K > &  elements,
const sourcepp::parser::text::EscapeSequenceMap escapeSequences 
)
inlinestaticprotected

Definition at line 137 of file KV1.h.

Member Data Documentation

◆ children

template<typename S , typename K >
std::vector<K> kvpp::KV1ElementBase< S, K >::children
protected

Definition at line 179 of file KV1.h.

◆ conditional

template<typename S , typename K >
S kvpp::KV1ElementBase< S, K >::conditional = ""
protected

Definition at line 178 of file KV1.h.

◆ key

template<typename S , typename K >
S kvpp::KV1ElementBase< S, K >::key = ""
protected

Definition at line 176 of file KV1.h.

◆ value

template<typename S , typename K >
S kvpp::KV1ElementBase< S, K >::value = ""
protected

Definition at line 177 of file KV1.h.


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