![]() |
SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
|
#include <KV1Binary.h>
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. | |
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. | |
KV1BinaryElement & | addChild (std::string_view key_) |
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. | |
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. -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 KV1BinaryElement & | getInvalid () |
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< KV1BinaryElement > | children |
Definition at line 48 of file KV1Binary.h.
using kvpp::KV1BinaryElement::const_iterator = std::vector<KV1BinaryElement>::const_iterator |
Definition at line 154 of file KV1Binary.h.
using kvpp::KV1BinaryElement::iterator = std::vector<KV1BinaryElement>::iterator |
Definition at line 144 of file KV1Binary.h.
|
default |
KV1BinaryElement & KV1BinaryElement::addChild | ( | std::string_view | key_ | ) |
Add a child element to the element.
Definition at line 55 of file KV1Binary.cpp.
|
inline |
Add a child element to the element.
Definition at line 106 of file KV1Binary.h.
|
inlineconstexpr |
Definition at line 146 of file KV1Binary.h.
|
inlineconstexpr |
Definition at line 156 of file KV1Binary.h.
|
inlineconstexpr |
Definition at line 164 of file KV1Binary.h.
|
inlineconstexpr |
Definition at line 168 of file KV1Binary.h.
|
inlineconstexpr |
Definition at line 150 of file KV1Binary.h.
|
inlineconstexpr |
Definition at line 160 of file KV1Binary.h.
uint64_t KV1BinaryElement::getChildCount | ( | ) | const |
Get the number of child elements.
Definition at line 37 of file KV1Binary.cpp.
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.
const std::vector< KV1BinaryElement > & KV1BinaryElement::getChildren | ( | ) | const |
Get the child elements of the element.
Definition at line 51 of file KV1Binary.cpp.
|
static |
Definition at line 147 of file KV1Binary.cpp.
std::string_view KV1BinaryElement::getKey | ( | ) | const |
Get the key associated with the element.
Definition at line 12 of file KV1Binary.cpp.
const KV1BinaryValue & KV1BinaryElement::getValue | ( | ) | const |
Get the value associated with the element.
Definition at line 20 of file KV1Binary.cpp.
|
inline |
Get the value associated with the element as the given type.
Definition at line 63 of file KV1Binary.h.
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.
bool KV1BinaryElement::isInvalid | ( | ) | const |
Check if the given element is invalid.
Definition at line 143 of file KV1Binary.cpp.
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.
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.
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.
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.
KV1BinaryElement & KV1BinaryElement::operator= | ( | KV1BinaryValue | value_ | ) |
Set the value associated with the element.
Definition at line 28 of file KV1Binary.cpp.
|
inline |
Set the value associated with the element.
Definition at line 84 of file KV1Binary.h.
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.
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.
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.
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.
|
staticprotected |
Definition at line 152 of file KV1Binary.cpp.
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.
void KV1BinaryElement::removeChild | ( | unsigned int | n | ) |
Remove a child element from the element.
Definition at line 122 of file KV1Binary.cpp.
void KV1BinaryElement::setKey | ( | std::string_view | key_ | ) |
Set the key associated with the element.
Definition at line 16 of file KV1Binary.cpp.
void KV1BinaryElement::setValue | ( | KV1BinaryValue | value_ | ) |
Set the value associated with the element.
Definition at line 24 of file KV1Binary.cpp.
|
inline |
Set the value associated with the element.
Definition at line 78 of file KV1Binary.h.
|
staticprotected |
Definition at line 204 of file KV1Binary.cpp.
|
protected |
Definition at line 185 of file KV1Binary.h.
|
protected |
Definition at line 183 of file KV1Binary.h.
|
protected |
Definition at line 184 of file KV1Binary.h.