SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
kvpp::KV1BinaryElement Class Reference

#include <KV1Binary.h>

Inheritance diagram for kvpp::KV1BinaryElement:
Collaboration diagram for kvpp::KV1BinaryElement:

Public Types

using iterator = std::vector< KV1BinaryElement >::iterator
 
using const_iterator = std::vector< KV1BinaryElement >::const_iterator
 

Public Member Functions

 KV1BinaryElement ()=default
 
std::string_view getKey () const
 Get the key associated with the element.
 
void setKey (std::string_view key_)
 Set the key associated with the element.
 
const KV1BinaryValuegetValue () const
 Get the value associated with the element.
 
template<KV1BinaryValueNoChildren V>
std::optional< V > getValue () const
 Get the value associated with the element as the given type.
 
void setValue (KV1BinaryValue value_)
 Set the value associated with the element.
 
KV1BinaryElementoperator= (KV1BinaryValue value_)
 Set the value associated with the element.
 
template<KV1BinaryValueNoChildren V>
void setValue (V value_)
 Set the value associated with the element.
 
template<KV1BinaryValueNoChildren V>
KV1BinaryElementoperator= (V value_)
 Set the value 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< KV1BinaryElement > & getChildren () const
 Get the child elements of the element.
 
KV1BinaryElementaddChild (std::string_view key_)
 Add a child element to the element.
 
template<KV1BinaryValueNoChildren V>
KV1BinaryElementaddChild (std::string_view key_, V value_={})
 Add a child element to the element.
 
const KV1BinaryElementoperator[] (unsigned int n) const
 Get the child element of the element at the given index.
 
KV1BinaryElementoperator[] (unsigned int n)
 Get the child element of the element at the given index.
 
const KV1BinaryElementoperator[] (std::string_view childKey) const
 Get the first child element of the element with the given key.
 
KV1BinaryElementoperator[] (std::string_view childKey)
 Get the first child element of the element with the given key, or create a new element if it doesn't exist.
 
const KV1BinaryElementoperator() (std::string_view childKey) const
 Get the first child element of the element with the given key.
 
KV1BinaryElementoperator() (std::string_view childKey)
 Get the first child element of the element with the given key, or create a new element if it doesn't exist.
 
const KV1BinaryElementoperator() (std::string_view childKey, unsigned int n) const
 Get the nth child element of the element with the given key.
 
KV1BinaryElementoperator() (std::string_view childKey, unsigned int n)
 Get the nth child element of the element with the given key, or create a new element if it doesn't exist.
 
void removeChild (unsigned int n)
 Remove a child element from the element.
 
void removeChild (std::string_view childKey, int n=-1)
 Remove a child element from the element. -1 means all children with the given key.
 
constexpr iterator begin ()
 
constexpr iterator end ()
 
constexpr const_iterator begin () const
 
constexpr const_iterator end () const
 
constexpr const_iterator cbegin () const
 
constexpr const_iterator cend () const
 
bool isInvalid () const
 Check if the given element is invalid.
 

Static Public Member Functions

static const KV1BinaryElementgetInvalid ()
 

Static Protected Member Functions

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

Protected Attributes

std::string key
 
KV1BinaryValue value
 
std::vector< KV1BinaryElementchildren
 

Detailed Description

Definition at line 48 of file KV1Binary.h.

Member Typedef Documentation

◆ const_iterator

using kvpp::KV1BinaryElement::const_iterator = std::vector<KV1BinaryElement>::const_iterator

Definition at line 154 of file KV1Binary.h.

◆ iterator

using kvpp::KV1BinaryElement::iterator = std::vector<KV1BinaryElement>::iterator

Definition at line 144 of file KV1Binary.h.

Constructor & Destructor Documentation

◆ KV1BinaryElement()

kvpp::KV1BinaryElement::KV1BinaryElement ( )
default

Member Function Documentation

◆ addChild() [1/2]

KV1BinaryElement & KV1BinaryElement::addChild ( std::string_view  key_)

Add a child element to the element.

Definition at line 55 of file KV1Binary.cpp.

◆ addChild() [2/2]

template<KV1BinaryValueNoChildren V>
KV1BinaryElement & kvpp::KV1BinaryElement::addChild ( std::string_view  key_,
value_ = {} 
)
inline

Add a child element to the element.

Definition at line 106 of file KV1Binary.h.

◆ begin() [1/2]

constexpr iterator kvpp::KV1BinaryElement::begin ( )
inlineconstexpr

Definition at line 146 of file KV1Binary.h.

◆ begin() [2/2]

constexpr const_iterator kvpp::KV1BinaryElement::begin ( ) const
inlineconstexpr

Definition at line 156 of file KV1Binary.h.

◆ cbegin()

constexpr const_iterator kvpp::KV1BinaryElement::cbegin ( ) const
inlineconstexpr

Definition at line 164 of file KV1Binary.h.

◆ cend()

constexpr const_iterator kvpp::KV1BinaryElement::cend ( ) const
inlineconstexpr

Definition at line 168 of file KV1Binary.h.

◆ end() [1/2]

constexpr iterator kvpp::KV1BinaryElement::end ( )
inlineconstexpr

Definition at line 150 of file KV1Binary.h.

◆ end() [2/2]

constexpr const_iterator kvpp::KV1BinaryElement::end ( ) const
inlineconstexpr

Definition at line 160 of file KV1Binary.h.

◆ getChildCount() [1/2]

uint64_t KV1BinaryElement::getChildCount ( ) const

Get the number of child elements.

Definition at line 37 of file KV1Binary.cpp.

◆ getChildCount() [2/2]

uint64_t KV1BinaryElement::getChildCount ( std::string_view  childKey) const

Get the number of child elements with the given key.

Definition at line 41 of file KV1Binary.cpp.

◆ getChildren()

const std::vector< KV1BinaryElement > & KV1BinaryElement::getChildren ( ) const

Get the child elements of the element.

Definition at line 51 of file KV1Binary.cpp.

◆ getInvalid()

const KV1BinaryElement & KV1BinaryElement::getInvalid ( )
static

Definition at line 147 of file KV1Binary.cpp.

◆ getKey()

std::string_view KV1BinaryElement::getKey ( ) const

Get the key associated with the element.

Definition at line 12 of file KV1Binary.cpp.

◆ getValue() [1/2]

const KV1BinaryValue & KV1BinaryElement::getValue ( ) const

Get the value associated with the element.

Definition at line 20 of file KV1Binary.cpp.

◆ getValue() [2/2]

template<KV1BinaryValueNoChildren V>
std::optional< V > kvpp::KV1BinaryElement::getValue ( ) const
inline

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

Definition at line 63 of file KV1Binary.h.

◆ hasChild()

bool KV1BinaryElement::hasChild ( std::string_view  childKey) const

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

Definition at line 33 of file KV1Binary.cpp.

◆ isInvalid()

bool KV1BinaryElement::isInvalid ( ) const

Check if the given element is invalid.

Definition at line 143 of file KV1Binary.cpp.

◆ operator()() [1/4]

KV1BinaryElement & KV1BinaryElement::operator() ( std::string_view  childKey)

Get the first child element of the element with the given key, or create a new element if it doesn't exist.

Definition at line 87 of file KV1Binary.cpp.

◆ operator()() [2/4]

const KV1BinaryElement & KV1BinaryElement::operator() ( std::string_view  childKey) const

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

Definition at line 78 of file KV1Binary.cpp.

◆ operator()() [3/4]

KV1BinaryElement & KV1BinaryElement::operator() ( std::string_view  childKey,
unsigned int  n 
)

Get the nth child element of the element with the given key, or create a new element if it doesn't exist.

Definition at line 109 of file KV1Binary.cpp.

◆ operator()() [4/4]

const KV1BinaryElement & KV1BinaryElement::operator() ( std::string_view  childKey,
unsigned int  n 
) const

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

Definition at line 96 of file KV1Binary.cpp.

◆ operator=() [1/2]

KV1BinaryElement & KV1BinaryElement::operator= ( KV1BinaryValue  value_)

Set the value associated with the element.

Definition at line 28 of file KV1Binary.cpp.

◆ operator=() [2/2]

template<KV1BinaryValueNoChildren V>
KV1BinaryElement & kvpp::KV1BinaryElement::operator= ( value_)
inline

Set the value associated with the element.

Definition at line 84 of file KV1Binary.h.

◆ operator[]() [1/4]

KV1BinaryElement & KV1BinaryElement::operator[] ( std::string_view  childKey)

Get the first child element of the element with the given key, or create a new element if it doesn't exist.

Definition at line 74 of file KV1Binary.cpp.

◆ operator[]() [2/4]

const KV1BinaryElement & KV1BinaryElement::operator[] ( std::string_view  childKey) const

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

Definition at line 70 of file KV1Binary.cpp.

◆ operator[]() [3/4]

KV1BinaryElement & KV1BinaryElement::operator[] ( unsigned int  n)

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

Definition at line 66 of file KV1Binary.cpp.

◆ operator[]() [4/4]

const KV1BinaryElement & KV1BinaryElement::operator[] ( unsigned int  n) const

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

Definition at line 62 of file KV1Binary.cpp.

◆ read()

void KV1BinaryElement::read ( BufferStreamReadOnly &  stream,
std::vector< KV1BinaryElement > &  elements,
const sourcepp::parser::text::EscapeSequenceMap escapeSequences 
)
staticprotected

Definition at line 152 of file KV1Binary.cpp.

◆ removeChild() [1/2]

void KV1BinaryElement::removeChild ( std::string_view  childKey,
int  n = -1 
)

Remove a child element from the element. -1 means all children with the given key.

Definition at line 128 of file KV1Binary.cpp.

◆ removeChild() [2/2]

void KV1BinaryElement::removeChild ( unsigned int  n)

Remove a child element from the element.

Definition at line 122 of file KV1Binary.cpp.

◆ setKey()

void KV1BinaryElement::setKey ( std::string_view  key_)

Set the key associated with the element.

Definition at line 16 of file KV1Binary.cpp.

◆ setValue() [1/2]

void KV1BinaryElement::setValue ( KV1BinaryValue  value_)

Set the value associated with the element.

Definition at line 24 of file KV1Binary.cpp.

◆ setValue() [2/2]

template<KV1BinaryValueNoChildren V>
void kvpp::KV1BinaryElement::setValue ( value_)
inline

Set the value associated with the element.

Definition at line 78 of file KV1Binary.h.

◆ write()

void KV1BinaryElement::write ( BufferStream &  stream,
const std::vector< KV1BinaryElement > &  elements,
const sourcepp::parser::text::EscapeSequenceMap escapeSequences 
)
staticprotected

Definition at line 204 of file KV1Binary.cpp.

Member Data Documentation

◆ children

std::vector<KV1BinaryElement> kvpp::KV1BinaryElement::children
protected

Definition at line 185 of file KV1Binary.h.

◆ key

std::string kvpp::KV1BinaryElement::key
protected

Definition at line 183 of file KV1Binary.h.

◆ value

KV1BinaryValue kvpp::KV1BinaryElement::value
protected

Definition at line 184 of file KV1Binary.h.


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