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

#include <DMX.h>

Collaboration diagram for kvpp::DMXElement:

Public Types

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

Public Member Functions

 operator bool () const
std::string_view getType () const
 Get the C++ type the element maps to.
void setType (std::string type_)
 Set the C++ type the element maps to.
std::string_view getKey () const
 Get the key associated with the element.
void setKey (std::string key_)
 Set the key associated with the element.
const DMXValue::UUIDgetUUID () const
void setUUID (const DMXValue::UUID &guid_)
bool hasAttribute (std::string_view attributeKey) const
 Check if the element has one or more children with the given name.
DMXAttributeaddAttribute (std::string key_, DMXValue::Generic value_={})
 Add an attribute to the element.
uint64_t getAttributeCount () const
 Get the number of child attributes.
uint64_t getAttributeCount (std::string_view childKey) const
 Get the number of child attributes with the given key.
const std::vector< DMXAttribute > & getAttributes () const
 Get the child attributes of the element.
std::vector< DMXAttribute > & getAttributes ()
 Get the child attributes 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 DMXAttributeoperator[] (unsigned int n) const
 Get the attribute of the element at the given index.
DMXAttributeoperator[] (unsigned int n)
 Get the attribute of the element at the given index.
const DMXAttributeoperator[] (std::string_view attributeKey) const
 Get the first attribute of the element with the given key.
DMXAttributeoperator[] (std::string_view attributeKey)
 Get the first attribute of the element with the given key, or create a new element if it doesn't exist.
const DMXAttributeoperator() (std::string_view attributeKey) const
 Get the first attribute of the element with the given key.
DMXAttributeoperator() (std::string_view attributeKey)
 Get the first attribute of the element with the given key, or create a new element if it doesn't exist.
const DMXAttributeoperator() (std::string_view attributeKey, unsigned int n) const
 Get the nth attribute of the element with the given key.
DMXAttributeoperator() (std::string_view attributeKey, unsigned int n)
 Get the nth attribute of the element with the given key, or create a new element if it doesn't exist.
void removeAttribute (unsigned int n)
 Remove an attribute from the element.
void removeAttribute (std::string_view attributeKey, int n=-1)
 Remove an attribute from the element with the given key. -1 means all children with the given key.

Static Public Member Functions

static const DMXAttributegetInvalidAttribute ()

Protected Member Functions

 DMXElement ()=default

Protected Attributes

std::string type
std::string key
DMXValue::UUID uuid {}
std::vector< DMXAttributeattributes

Friends

class DMX

Detailed Description

Definition at line 584 of file DMX.h.

Member Typedef Documentation

◆ const_iterator

using kvpp::DMXElement::const_iterator = std::vector<DMXAttribute>::const_iterator

Definition at line 636 of file DMX.h.

◆ iterator

using kvpp::DMXElement::iterator = std::vector<DMXAttribute>::iterator

Definition at line 626 of file DMX.h.

Constructor & Destructor Documentation

◆ DMXElement()

kvpp::DMXElement::DMXElement ( )
protecteddefault

Member Function Documentation

◆ addAttribute()

DMXAttribute & DMXElement::addAttribute ( std::string key_,
DMXValue::Generic value_ = {} )

Add an attribute to the element.

Definition at line 384 of file DMX.cpp.

◆ begin() [1/2]

iterator kvpp::DMXElement::begin ( )
inlinenodiscardconstexpr

Definition at line 628 of file DMX.h.

◆ begin() [2/2]

const_iterator kvpp::DMXElement::begin ( ) const
inlinenodiscardconstexpr

Definition at line 638 of file DMX.h.

◆ cbegin()

const_iterator kvpp::DMXElement::cbegin ( ) const
inlinenodiscardconstexpr

Definition at line 646 of file DMX.h.

◆ cend()

const_iterator kvpp::DMXElement::cend ( ) const
inlinenodiscardconstexpr

Definition at line 650 of file DMX.h.

◆ end() [1/2]

iterator kvpp::DMXElement::end ( )
inlinenodiscardconstexpr

Definition at line 632 of file DMX.h.

◆ end() [2/2]

const_iterator kvpp::DMXElement::end ( ) const
inlinenodiscardconstexpr

Definition at line 642 of file DMX.h.

◆ getAttributeCount() [1/2]

uint64_t DMXElement::getAttributeCount ( ) const
nodiscard

Get the number of child attributes.

Definition at line 392 of file DMX.cpp.

◆ getAttributeCount() [2/2]

uint64_t DMXElement::getAttributeCount ( std::string_view childKey) const
nodiscard

Get the number of child attributes with the given key.

Definition at line 396 of file DMX.cpp.

◆ getAttributes() [1/2]

std::vector< DMXAttribute > & DMXElement::getAttributes ( )
nodiscard

Get the child attributes of the element.

Definition at line 410 of file DMX.cpp.

◆ getAttributes() [2/2]

const std::vector< DMXAttribute > & DMXElement::getAttributes ( ) const
nodiscard

Get the child attributes of the element.

Definition at line 406 of file DMX.cpp.

◆ getInvalidAttribute()

const DMXAttribute & DMXElement::getInvalidAttribute ( )
static

Definition at line 499 of file DMX.cpp.

◆ getKey()

std::string_view DMXElement::getKey ( ) const
nodiscard

Get the key associated with the element.

Definition at line 364 of file DMX.cpp.

◆ getType()

std::string_view DMXElement::getType ( ) const
nodiscard

Get the C++ type the element maps to.

Definition at line 356 of file DMX.cpp.

◆ getUUID()

const DMXValue::UUID & DMXElement::getUUID ( ) const
nodiscard

Definition at line 372 of file DMX.cpp.

◆ hasAttribute()

bool DMXElement::hasAttribute ( std::string_view attributeKey) const
nodiscard

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

Definition at line 380 of file DMX.cpp.

◆ operator bool()

DMXElement::operator bool ( ) const
explicitnodiscard

Definition at line 352 of file DMX.cpp.

◆ operator()() [1/4]

DMXAttribute & DMXElement::operator() ( std::string_view attributeKey)
nodiscard

Get the first attribute of the element with the given key, or create a new element if it doesn't exist.

Definition at line 439 of file DMX.cpp.

◆ operator()() [2/4]

const DMXAttribute & DMXElement::operator() ( std::string_view attributeKey) const
nodiscard

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

Definition at line 430 of file DMX.cpp.

◆ operator()() [3/4]

DMXAttribute & DMXElement::operator() ( std::string_view attributeKey,
unsigned int n )
nodiscard

Get the nth attribute of the element with the given key, or create a new element if it doesn't exist.

Definition at line 463 of file DMX.cpp.

◆ operator()() [4/4]

const DMXAttribute & DMXElement::operator() ( std::string_view attributeKey,
unsigned int n ) const
nodiscard

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

Definition at line 448 of file DMX.cpp.

◆ operator[]() [1/4]

DMXAttribute & DMXElement::operator[] ( std::string_view attributeKey)
nodiscard

Get the first attribute of the element with the given key, or create a new element if it doesn't exist.

Definition at line 426 of file DMX.cpp.

◆ operator[]() [2/4]

const DMXAttribute & DMXElement::operator[] ( std::string_view attributeKey) const
nodiscard

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

Definition at line 422 of file DMX.cpp.

◆ operator[]() [3/4]

DMXAttribute & DMXElement::operator[] ( unsigned int n)
nodiscard

Get the attribute of the element at the given index.

Definition at line 418 of file DMX.cpp.

◆ operator[]() [4/4]

const DMXAttribute & DMXElement::operator[] ( unsigned int n) const
nodiscard

Get the attribute of the element at the given index.

Definition at line 414 of file DMX.cpp.

◆ removeAttribute() [1/2]

void DMXElement::removeAttribute ( std::string_view attributeKey,
int n = -1 )

Remove an attribute from the element with the given key. -1 means all children with the given key.

Definition at line 484 of file DMX.cpp.

◆ removeAttribute() [2/2]

void DMXElement::removeAttribute ( unsigned int n)

Remove an attribute from the element.

Definition at line 478 of file DMX.cpp.

◆ setKey()

void DMXElement::setKey ( std::string key_)

Set the key associated with the element.

Definition at line 368 of file DMX.cpp.

◆ setType()

void DMXElement::setType ( std::string type_)

Set the C++ type the element maps to.

Definition at line 360 of file DMX.cpp.

◆ setUUID()

void DMXElement::setUUID ( const DMXValue::UUID & guid_)

Definition at line 376 of file DMX.cpp.

◆ DMX

friend class DMX
friend

Definition at line 585 of file DMX.h.

Member Data Documentation

◆ attributes

std::vector<DMXAttribute> kvpp::DMXElement::attributes
protected

Definition at line 692 of file DMX.h.

◆ key

std::string kvpp::DMXElement::key
protected

Definition at line 690 of file DMX.h.

◆ type

std::string kvpp::DMXElement::type
protected

Definition at line 689 of file DMX.h.

◆ uuid

DMXValue::UUID kvpp::DMXElement::uuid {}
protected

Definition at line 691 of file DMX.h.


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