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={}, bool useEscapeSequences_=false)
 
std::vector< std::byte > bake () const
 
void bake (const std::string &kv1Path) const
 
std::string bakeText () const
 
void bakeText (const std::string &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.
 
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.
 

Protected Attributes

bool useEscapeSequences
 
- Protected Attributes inherited from kvpp::KV1BinaryElement
std::string key
 
KV1BinaryValue value
 
std::vector< KV1BinaryElementchildren
 

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 ()
 
- Static Protected Member Functions inherited from kvpp::KV1BinaryElement
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)
 

Detailed Description

Definition at line 188 of file KV1Binary.h.

Constructor & Destructor Documentation

◆ KV1Binary()

KV1Binary::KV1Binary ( std::span< const std::byte >  kv1Data = {},
bool  useEscapeSequences_ = false 
)
explicit

Definition at line 250 of file KV1Binary.cpp.

Member Function Documentation

◆ bake() [1/2]

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

Definition at line 260 of file KV1Binary.cpp.

◆ bake() [2/2]

void KV1Binary::bake ( const std::string &  kv1Path) const

Definition at line 268 of file KV1Binary.cpp.

◆ bakeText() [1/2]

std::string KV1Binary::bakeText ( ) const

Definition at line 272 of file KV1Binary.cpp.

◆ bakeText() [2/2]

void KV1Binary::bakeText ( const std::string &  kv1Path) const

Definition at line 314 of file KV1Binary.cpp.

Member Data Documentation

◆ useEscapeSequences

bool kvpp::KV1Binary::useEscapeSequences
protected

Definition at line 201 of file KV1Binary.h.


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