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.
KV1BinaryElementaddChild (std::string_view key_, KV1BinaryValue value_={})
 Add a child element to the element.
template<KV1BinaryValueNoChildren V>
KV1BinaryElementaddChild (std::string_view key_, V value_={})
 Add a child element to the element.
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.
std::vector< KV1BinaryElement > & getChildren ()
 Get the child elements of the element.
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
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 with the given key. -1 means all children with the given key.
bool isInvalid () const
 Check if the given element is invalid.
 operator bool () const

Static Public Member Functions

static const KV1BinaryElementgetInvalid ()

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 127 of file KV1Binary.h.

◆ iterator

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

Definition at line 117 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_,
KV1BinaryValue value_ = {} )

Add a child element to the element.

Definition at line 42 of file KV1Binary.cpp.

◆ addChild() [2/2]

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

Add a child element to the element.

Definition at line 97 of file KV1Binary.h.

◆ begin() [1/2]

iterator kvpp::KV1BinaryElement::begin ( )
inlinenodiscardconstexpr

Definition at line 119 of file KV1Binary.h.

◆ begin() [2/2]

const_iterator kvpp::KV1BinaryElement::begin ( ) const
inlinenodiscardconstexpr

Definition at line 129 of file KV1Binary.h.

◆ cbegin()

const_iterator kvpp::KV1BinaryElement::cbegin ( ) const
inlinenodiscardconstexpr

Definition at line 137 of file KV1Binary.h.

◆ cend()

const_iterator kvpp::KV1BinaryElement::cend ( ) const
inlinenodiscardconstexpr

Definition at line 141 of file KV1Binary.h.

◆ end() [1/2]

iterator kvpp::KV1BinaryElement::end ( )
inlinenodiscardconstexpr

Definition at line 123 of file KV1Binary.h.

◆ end() [2/2]

const_iterator kvpp::KV1BinaryElement::end ( ) const
inlinenodiscardconstexpr

Definition at line 133 of file KV1Binary.h.

◆ getChildCount() [1/2]

uint64_t KV1BinaryElement::getChildCount ( ) const
nodiscard

Get the number of child elements.

Definition at line 50 of file KV1Binary.cpp.

◆ getChildCount() [2/2]

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

Get the number of child elements with the given key.

Definition at line 54 of file KV1Binary.cpp.

◆ getChildren() [1/2]

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

Get the child elements of the element.

Definition at line 68 of file KV1Binary.cpp.

◆ getChildren() [2/2]

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

Get the child elements of the element.

Definition at line 64 of file KV1Binary.cpp.

◆ getInvalid()

const KV1BinaryElement & KV1BinaryElement::getInvalid ( )
static

Definition at line 161 of file KV1Binary.cpp.

◆ getKey()

std::string_view KV1BinaryElement::getKey ( ) const
nodiscard

Get the key associated with the element.

Definition at line 17 of file KV1Binary.cpp.

◆ getValue() [1/2]

const KV1BinaryValue & KV1BinaryElement::getValue ( ) const
nodiscard

Get the value associated with the element.

Definition at line 25 of file KV1Binary.cpp.

◆ getValue() [2/2]

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

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
nodiscard

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

Definition at line 38 of file KV1Binary.cpp.

◆ isInvalid()

bool KV1BinaryElement::isInvalid ( ) const
nodiscard

Check if the given element is invalid.

Definition at line 157 of file KV1Binary.cpp.

◆ operator bool()

KV1BinaryElement::operator bool ( ) const
explicitnodiscard

Definition at line 166 of file KV1Binary.cpp.

◆ operator()() [1/4]

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

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 97 of file KV1Binary.cpp.

◆ operator()() [2/4]

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

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

Definition at line 88 of file KV1Binary.cpp.

◆ operator()() [3/4]

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

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 121 of file KV1Binary.cpp.

◆ operator()() [4/4]

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

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

Definition at line 106 of file KV1Binary.cpp.

◆ operator=() [1/2]

KV1BinaryElement & KV1BinaryElement::operator= ( KV1BinaryValue value_)

Set the value associated with the element.

Definition at line 33 of file KV1Binary.cpp.

◆ operator=() [2/2]

template<KV1BinaryValueNoChildren V>
KV1BinaryElement & kvpp::KV1BinaryElement::operator= ( V 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)
nodiscard

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 84 of file KV1Binary.cpp.

◆ operator[]() [2/4]

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

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

Definition at line 80 of file KV1Binary.cpp.

◆ operator[]() [3/4]

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

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

Definition at line 76 of file KV1Binary.cpp.

◆ operator[]() [4/4]

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

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

Definition at line 72 of file KV1Binary.cpp.

◆ removeChild() [1/2]

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

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

Definition at line 142 of file KV1Binary.cpp.

◆ removeChild() [2/2]

void KV1BinaryElement::removeChild ( unsigned int n)

Remove a child element from the element.

Definition at line 136 of file KV1Binary.cpp.

◆ setKey()

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

Set the key associated with the element.

Definition at line 21 of file KV1Binary.cpp.

◆ setValue() [1/2]

void KV1BinaryElement::setValue ( KV1BinaryValue value_)

Set the value associated with the element.

Definition at line 29 of file KV1Binary.cpp.

◆ setValue() [2/2]

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

Set the value associated with the element.

Definition at line 78 of file KV1Binary.h.

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: