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

#include <KV1Binary.h>

Inheritance diagram for kvpp::KV1Binary:
Collaboration diagram for kvpp::KV1Binary:

Public Member Functions

 KV1Binary (std::span< const std::byte > kv1Data={})
 KV1Binary (const std::filesystem::path &kv1Path)
std::vector< std::byte > bake () const
void bake (const std::filesystem::path &kv1Path) const
std::string bakeText () const
void bakeText (const std::filesystem::path &kv1Path) const
Public Member Functions inherited from kvpp::KV1BinaryElement
 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

Additional Inherited Members

Public Types inherited from kvpp::KV1BinaryElement
using iterator = std::vector<KV1BinaryElement>::iterator
using const_iterator = std::vector<KV1BinaryElement>::const_iterator
Static Public Member Functions inherited from kvpp::KV1BinaryElement
static const KV1BinaryElementgetInvalid ()
Protected Attributes inherited from kvpp::KV1BinaryElement
std::string key
KV1BinaryValue value
std::vector< KV1BinaryElementchildren

Detailed Description

Definition at line 188 of file KV1Binary.h.

Constructor & Destructor Documentation

◆ KV1Binary() [1/2]

KV1Binary::KV1Binary ( std::span< const std::byte > kv1Data = {})
explicit

Definition at line 170 of file KV1Binary.cpp.

◆ KV1Binary() [2/2]

KV1Binary::KV1Binary ( const std::filesystem::path & kv1Path)
explicit

Definition at line 232 of file KV1Binary.cpp.

Member Function Documentation

◆ bake() [1/2]

std::vector< std::byte > KV1Binary::bake ( ) const
nodiscard

Definition at line 235 of file KV1Binary.cpp.

◆ bake() [2/2]

void KV1Binary::bake ( const std::filesystem::path & kv1Path) const

Definition at line 291 of file KV1Binary.cpp.

◆ bakeText() [1/2]

std::string KV1Binary::bakeText ( ) const
nodiscard

Definition at line 295 of file KV1Binary.cpp.

◆ bakeText() [2/2]

void KV1Binary::bakeText ( const std::filesystem::path & kv1Path) const

Definition at line 337 of file KV1Binary.cpp.


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