SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
kvpp::KV1ElementWritable< S > Class Template Reference

#include <KV1Writer.h>

Collaboration diagram for kvpp::KV1ElementWritable< S >:

Public Types

using iterator = std::vector<KV1ElementWritable>::iterator
using const_iterator = std::vector<KV1ElementWritable>::const_iterator

Public Member Functions

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.
std::string_view getValue () const
 Get the value associated with the element.
template<KV1ValueType V>
getValue () const
 Get the value associated with the element as the given type.
template<KV1ValueType V>
void setValue (V value_)
 Set the value associated with the element.
template<KV1ValueType V>
KV1ElementWritableoperator= (V value_)
 Set the value associated with the element.
std::string_view getConditional () const
 Get the conditional associated with the element.
void setConditional (std::string_view conditional_)
 Set the conditional associated with the element.
bool hasChild (std::string_view childKey) const
 Check if the element has one or more children with the given key.
template<KV1ValueType V = std::string_view>
KV1ElementWritableaddChild (std::string_view key_, V value_={}, std::string_view conditional_="")
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< KV1ElementWritable > & getChildren () const
 Get the child elements of the element.
std::vector< KV1ElementWritable > & 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 KV1ElementWritableoperator[] (unsigned int n) const
 Get the child element of the element at the given index.
KV1ElementWritableoperator[] (unsigned int n)
 Get the child element of the element at the given index.
const KV1ElementWritableoperator[] (std::string_view childKey) const
 Get the first child element of the element with the given key.
KV1ElementWritableoperator[] (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 KV1ElementWritableoperator() (std::string_view childKey) const
 Get the first child element of the element with the given key.
KV1ElementWritableoperator() (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 KV1ElementWritableoperator() (std::string_view childKey, unsigned int n) const
 Get the nth child element of the element with the given key.
KV1ElementWritableoperator() (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 KV1ElementWritablegetInvalid ()

Protected Member Functions

 KV1ElementWritable ()=default

Static Protected Member Functions

static void read (BufferStreamReadOnly &stream, std::vector< KV1ElementWritable > &elements, const sourcepp::parser::text::EscapeSequenceMap &escapeSequences)
static void write (BufferStream &stream, const std::vector< KV1ElementWritable > &elements, unsigned short indentLevel, const sourcepp::parser::text::EscapeSequenceMap &escapeSequences)

Protected Attributes

key = ""
value = ""
conditional = ""
std::vector< KV1ElementWritablechildren

Detailed Description

template<typename S = std::string>
requires std::convertible_to<S, std::string>
class kvpp::KV1ElementWritable< S >

Definition at line 11 of file KV1Writer.h.

Member Typedef Documentation

◆ const_iterator

template<typename S = std::string>
using kvpp::KV1ElementWritable< S >::const_iterator = std::vector<KV1ElementWritable>::const_iterator

Definition at line 130 of file KV1Writer.h.

◆ iterator

template<typename S = std::string>
using kvpp::KV1ElementWritable< S >::iterator = std::vector<KV1ElementWritable>::iterator

Definition at line 120 of file KV1Writer.h.

Constructor & Destructor Documentation

◆ KV1ElementWritable()

template<typename S = std::string>
kvpp::KV1ElementWritable< S >::KV1ElementWritable ( )
protecteddefault

Member Function Documentation

◆ addChild()

template<typename S = std::string>
template<KV1ValueType V = std::string_view>
KV1ElementWritable & kvpp::KV1ElementWritable< S >::addChild ( std::string_view key_,
V value_ = {},
std::string_view conditional_ = "" )
inline

Definition at line 85 of file KV1Writer.h.

◆ begin() [1/2]

template<typename S = std::string>
iterator kvpp::KV1ElementWritable< S >::begin ( )
inlinenodiscardconstexpr

Definition at line 122 of file KV1Writer.h.

◆ begin() [2/2]

template<typename S = std::string>
const_iterator kvpp::KV1ElementWritable< S >::begin ( ) const
inlinenodiscardconstexpr

Definition at line 132 of file KV1Writer.h.

◆ cbegin()

template<typename S = std::string>
const_iterator kvpp::KV1ElementWritable< S >::cbegin ( ) const
inlinenodiscardconstexpr

Definition at line 140 of file KV1Writer.h.

◆ cend()

template<typename S = std::string>
const_iterator kvpp::KV1ElementWritable< S >::cend ( ) const
inlinenodiscardconstexpr

Definition at line 144 of file KV1Writer.h.

◆ end() [1/2]

template<typename S = std::string>
iterator kvpp::KV1ElementWritable< S >::end ( )
inlinenodiscardconstexpr

Definition at line 126 of file KV1Writer.h.

◆ end() [2/2]

template<typename S = std::string>
const_iterator kvpp::KV1ElementWritable< S >::end ( ) const
inlinenodiscardconstexpr

Definition at line 136 of file KV1Writer.h.

◆ getChildCount() [1/2]

template<typename S = std::string>
uint64_t kvpp::KV1ElementWritable< S >::getChildCount ( ) const
inlinenodiscard

Get the number of child elements.

Definition at line 95 of file KV1Writer.h.

◆ getChildCount() [2/2]

template<typename S = std::string>
uint64_t kvpp::KV1ElementWritable< S >::getChildCount ( std::string_view childKey) const
inlinenodiscard

Get the number of child elements with the given key.

Definition at line 100 of file KV1Writer.h.

◆ getChildren() [1/2]

template<typename S = std::string>
std::vector< KV1ElementWritable > & kvpp::KV1ElementWritable< S >::getChildren ( )
inlinenodiscard

Get the child elements of the element.

Definition at line 116 of file KV1Writer.h.

◆ getChildren() [2/2]

template<typename S = std::string>
const std::vector< KV1ElementWritable > & kvpp::KV1ElementWritable< S >::getChildren ( ) const
inlinenodiscard

Get the child elements of the element.

Definition at line 111 of file KV1Writer.h.

◆ getConditional()

template<typename S = std::string>
std::string_view kvpp::KV1ElementWritable< S >::getConditional ( ) const
inlinenodiscard

Get the conditional associated with the element.

Definition at line 69 of file KV1Writer.h.

◆ getInvalid()

template<typename S = std::string>
const KV1ElementWritable & kvpp::KV1ElementWritable< S >::getInvalid ( )
inlinestatic

Definition at line 248 of file KV1Writer.h.

◆ getKey()

template<typename S = std::string>
std::string_view kvpp::KV1ElementWritable< S >::getKey ( ) const
inlinenodiscard

Get the key associated with the element.

Definition at line 14 of file KV1Writer.h.

◆ getValue() [1/2]

template<typename S = std::string>
std::string_view kvpp::KV1ElementWritable< S >::getValue ( ) const
inlinenodiscard

Get the value associated with the element.

Definition at line 24 of file KV1Writer.h.

◆ getValue() [2/2]

template<typename S = std::string>
template<KV1ValueType V>
V kvpp::KV1ElementWritable< S >::getValue ( ) const
inlinenodiscard

Get the value associated with the element as the given type.

Definition at line 30 of file KV1Writer.h.

◆ hasChild()

template<typename S = std::string>
bool kvpp::KV1ElementWritable< S >::hasChild ( std::string_view childKey) const
inlinenodiscard

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

Definition at line 79 of file KV1Writer.h.

◆ isInvalid()

template<typename S = std::string>
bool kvpp::KV1ElementWritable< S >::isInvalid ( ) const
inlinenodiscard

Check if the given element is invalid.

Definition at line 244 of file KV1Writer.h.

◆ operator bool()

template<typename S = std::string>
kvpp::KV1ElementWritable< S >::operator bool ( ) const
inlineexplicitnodiscard

Definition at line 253 of file KV1Writer.h.

◆ operator()() [1/4]

template<typename S = std::string>
KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator() ( std::string_view childKey)
inlinenodiscard

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 179 of file KV1Writer.h.

◆ operator()() [2/4]

template<typename S = std::string>
const KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator() ( std::string_view childKey) const
inlinenodiscard

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

Definition at line 169 of file KV1Writer.h.

◆ operator()() [3/4]

template<typename S = std::string>
KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator() ( std::string_view childKey,
unsigned int n )
inlinenodiscard

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 205 of file KV1Writer.h.

◆ operator()() [4/4]

template<typename S = std::string>
const KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator() ( std::string_view childKey,
unsigned int n ) const
inlinenodiscard

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

Definition at line 189 of file KV1Writer.h.

◆ operator=()

template<typename S = std::string>
template<KV1ValueType V>
KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator= ( V value_)
inline

Set the value associated with the element.

Definition at line 63 of file KV1Writer.h.

◆ operator[]() [1/4]

template<typename S = std::string>
KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator[] ( std::string_view childKey)
inlinenodiscard

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 164 of file KV1Writer.h.

◆ operator[]() [2/4]

template<typename S = std::string>
const KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator[] ( std::string_view childKey) const
inlinenodiscard

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

Definition at line 159 of file KV1Writer.h.

◆ operator[]() [3/4]

template<typename S = std::string>
KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator[] ( unsigned int n)
inlinenodiscard

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

Definition at line 154 of file KV1Writer.h.

◆ operator[]() [4/4]

template<typename S = std::string>
const KV1ElementWritable & kvpp::KV1ElementWritable< S >::operator[] ( unsigned int n) const
inlinenodiscard

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

Definition at line 149 of file KV1Writer.h.

◆ read()

template<typename S = std::string>
void kvpp::KV1ElementWritable< S >::read ( BufferStreamReadOnly & stream,
std::vector< KV1ElementWritable< S > > & elements,
const sourcepp::parser::text::EscapeSequenceMap & escapeSequences )
inlinestaticprotected

Definition at line 260 of file KV1Writer.h.

◆ removeChild() [1/2]

template<typename S = std::string>
void kvpp::KV1ElementWritable< S >::removeChild ( std::string_view childKey,
int n = -1 )
inline

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

Definition at line 228 of file KV1Writer.h.

◆ removeChild() [2/2]

template<typename S = std::string>
void kvpp::KV1ElementWritable< S >::removeChild ( unsigned int n)
inline

Remove a child element from the element.

Definition at line 221 of file KV1Writer.h.

◆ setConditional()

template<typename S = std::string>
void kvpp::KV1ElementWritable< S >::setConditional ( std::string_view conditional_)
inline

Set the conditional associated with the element.

Definition at line 74 of file KV1Writer.h.

◆ setKey()

template<typename S = std::string>
void kvpp::KV1ElementWritable< S >::setKey ( std::string_view key_)
inline

Set the key associated with the element.

Definition at line 19 of file KV1Writer.h.

◆ setValue()

template<typename S = std::string>
template<KV1ValueType V>
void kvpp::KV1ElementWritable< S >::setValue ( V value_)
inline

Set the value associated with the element.

Definition at line 53 of file KV1Writer.h.

◆ write()

template<typename S = std::string>
void kvpp::KV1ElementWritable< S >::write ( BufferStream & stream,
const std::vector< KV1ElementWritable< S > > & elements,
unsigned short indentLevel,
const sourcepp::parser::text::EscapeSequenceMap & escapeSequences )
inlinestaticprotected

Definition at line 298 of file KV1Writer.h.

Member Data Documentation

◆ children

template<typename S = std::string>
std::vector<KV1ElementWritable> kvpp::KV1ElementWritable< S >::children
protected

Definition at line 338 of file KV1Writer.h.

◆ conditional

template<typename S = std::string>
S kvpp::KV1ElementWritable< S >::conditional = ""
protected

Definition at line 337 of file KV1Writer.h.

◆ key

template<typename S = std::string>
S kvpp::KV1ElementWritable< S >::key = ""
protected

Definition at line 335 of file KV1Writer.h.

◆ value

template<typename S = std::string>
S kvpp::KV1ElementWritable< S >::value = ""
protected

Definition at line 336 of file KV1Writer.h.


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