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 KV1BinaryValue & getValue () 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.
KV1BinaryElement & operator= (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>
KV1BinaryElement & operator= (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.
KV1BinaryElement & addChild (std::string_view key_, KV1BinaryValue value_={})
 Add a child element to the element.
template<KV1BinaryValueNoChildren V>
KV1BinaryElement & addChild (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 KV1BinaryElement & operator[] (unsigned int n) const
 Get the child element of the element at the given index.
KV1BinaryElement & operator[] (unsigned int n)
 Get the child element of the element at the given index.
const KV1BinaryElement & operator[] (std::string_view childKey) const
 Get the first child element of the element with the given key.
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.
const KV1BinaryElement & operator() (std::string_view childKey) const
 Get the first child element of the element with the given key.
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.
const KV1BinaryElement & operator() (std::string_view childKey, unsigned int n) const
 Get the nth child element of the element with the given key.
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.
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 KV1BinaryElement & getInvalid ()

Protected Attributes

std::string key
KV1BinaryValue value
std::vector< KV1BinaryElement > children

Detailed Description

Definition at line 63 of file KV1Binary.h.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 142 of file KV1Binary.h.

◆ iterator

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

Definition at line 132 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 43 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 112 of file KV1Binary.h.

◆ begin() [1/2]

iterator kvpp::KV1BinaryElement::begin ( )
inlinenodiscardconstexpr

Definition at line 134 of file KV1Binary.h.

◆ begin() [2/2]

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

Definition at line 144 of file KV1Binary.h.

◆ cbegin()

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

Definition at line 152 of file KV1Binary.h.

◆ cend()

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

Definition at line 156 of file KV1Binary.h.

◆ end() [1/2]

iterator kvpp::KV1BinaryElement::end ( )
inlinenodiscardconstexpr

Definition at line 138 of file KV1Binary.h.

◆ end() [2/2]

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

Definition at line 148 of file KV1Binary.h.

◆ getChildCount() [1/2]

uint64_t KV1BinaryElement::getChildCount ( ) const
nodiscard

Get the number of child elements.

Definition at line 51 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 55 of file KV1Binary.cpp.

◆ getChildren() [1/2]

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

Get the child elements of the element.

Definition at line 69 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 65 of file KV1Binary.cpp.

◆ getInvalid()

const KV1BinaryElement & KV1BinaryElement::getInvalid ( )
static

Definition at line 162 of file KV1Binary.cpp.

◆ getKey()

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

Get the key associated with the element.

Definition at line 18 of file KV1Binary.cpp.

◆ getValue() [1/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 78 of file KV1Binary.h.

◆ getValue() [2/2]

const KV1BinaryValue & KV1BinaryElement::getValue ( ) const
nodiscard

Get the value associated with the element.

Definition at line 26 of file KV1Binary.cpp.

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

◆ isInvalid()

bool KV1BinaryElement::isInvalid ( ) const
nodiscard

Check if the given element is invalid.

Definition at line 158 of file KV1Binary.cpp.

◆ operator bool()

KV1BinaryElement::operator bool ( ) const
explicitnodiscard

Definition at line 167 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 98 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 89 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 122 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 107 of file KV1Binary.cpp.

◆ operator=() [1/2]

KV1BinaryElement & KV1BinaryElement::operator= ( KV1BinaryValue value_)

Set the value associated with the element.

Definition at line 34 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 99 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 85 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 81 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 77 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 73 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 143 of file KV1Binary.cpp.

◆ removeChild() [2/2]

void KV1BinaryElement::removeChild ( unsigned int n)

Remove a child element from the element.

Definition at line 137 of file KV1Binary.cpp.

◆ setKey()

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

Set the key associated with the element.

Definition at line 22 of file KV1Binary.cpp.

◆ setValue() [1/2]

void KV1BinaryElement::setValue ( KV1BinaryValue value_)

Set the value associated with the element.

Definition at line 30 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 93 of file KV1Binary.h.

Member Data Documentation

◆ children

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

Definition at line 200 of file KV1Binary.h.

◆ key

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

Definition at line 198 of file KV1Binary.h.

◆ value

KV1BinaryValue kvpp::KV1BinaryElement::value
protected

Definition at line 199 of file KV1Binary.h.


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