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

#include <KV1.h>

Inheritance diagram for kvpp::KV1ElementWritable< S >:
Collaboration diagram for kvpp::KV1ElementWritable< S >:

Public Member Functions

void setKey (std::string_view key_)
 Set the key associated with the element.
 
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.
 
void setConditional (std::string_view conditional_)
 Set the conditional associated with the element.
 
template<KV1ValueType V = std::string_view>
KV1ElementWritableaddChild (std::string_view key_, V value_={}, std::string_view conditional_="")
 
KV1ElementWritableoperator[] (unsigned int n)
 Get the child element of the element at the given index.
 
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.
 
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.
 
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 (std::string_view childKey, int n=-1)
 Remove a child element from the element. -1 means all children with the given key.
 
- Public Member Functions inherited from kvpp::KV1ElementBase< S, K >
std::string_view getKey () const
 Get 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.
 
std::string_view getConditional () const
 Get 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 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< K > & getChildren () const
 Get the child elements of the element.
 
const KV1ElementBaseoperator[] (unsigned int n) const
 Get the child element of the element at the given index.
 
const KV1ElementBaseoperator[] (std::string_view childKey) const
 Get the first child element of the element with the given key.
 
const KV1ElementBaseoperator() (std::string_view childKey) const
 Get the first child element of the element with the given key.
 
const KV1ElementBaseoperator() (std::string_view childKey, unsigned int n) const
 Get the nth child element of the element with the given key.
 
bool isInvalid () const
 Check if the given element is invalid.
 

Protected Member Functions

 KV1ElementWritable ()=default
 
- Protected Member Functions inherited from kvpp::KV1ElementBase< S, K >
 KV1ElementBase ()=default
 

Static Protected Member Functions

static void write (BufferStream &stream, std::vector< KV1ElementWritable > &elements, unsigned short indentLevel, const sourcepp::parser::text::EscapeSequenceMap &escapeSequences)
 
- Static Protected Member Functions inherited from kvpp::KV1ElementBase< S, K >
static const KV1ElementBasegetInvalid ()
 
static void read (BufferStreamReadOnly &stream, BufferStream &backing, std::vector< K > &elements, const sourcepp::parser::text::EscapeSequenceMap &escapeSequences)
 

Friends

class KV1ElementBase< std::string, KV1ElementWritable< S > >
 

Additional Inherited Members

- Protected Attributes inherited from kvpp::KV1ElementBase< S, K >
key = ""
 
value = ""
 
conditional = ""
 
std::vector< K > children
 

Detailed Description

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

Definition at line 204 of file KV1.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_,
value_ = {},
std::string_view  conditional_ = "" 
)
inline

Definition at line 236 of file KV1.h.

◆ operator()() [1/2]

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

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 256 of file KV1.h.

◆ operator()() [2/2]

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

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 266 of file KV1.h.

◆ operator=()

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

Set the value associated with the element.

Definition at line 225 of file KV1.h.

◆ operator[]() [1/2]

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

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 251 of file KV1.h.

◆ operator[]() [2/2]

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

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

Definition at line 246 of file KV1.h.

◆ removeChild()

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. -1 means all children with the given key.

Definition at line 280 of file KV1.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 231 of file KV1.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 209 of file KV1.h.

◆ setValue()

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

Set the value associated with the element.

Definition at line 215 of file KV1.h.

◆ write()

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

Definition at line 298 of file KV1.h.

Friends And Related Function Documentation

◆ KV1ElementBase< std::string, KV1ElementWritable< S > >

template<typename S = std::string>
friend class KV1ElementBase< std::string, KV1ElementWritable< S > >
friend

Definition at line 199 of file KV1.h.


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