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

#include <DMX.h>

Collaboration diagram for kvpp::DMX:

Public Types

enum  Encoding {
  ENCODING_INVALID , ENCODING_BINARY_OLD , ENCODING_BINARY_OLD_SFM , ENCODING_BINARY ,
  ENCODING_BINARY_SEQIDS , ENCODING_KEYVALUES2_OLD , ENCODING_KEYVALUES2_FLAT_OLD , ENCODING_KEYVALUES2 ,
  ENCODING_KEYVALUES2_FLAT , ENCODING_KEYVALUES2_NOIDS
}
using iterator = std::vector<DMXElement>::iterator
using const_iterator = std::vector<DMXElement>::const_iterator

Public Member Functions

 DMX (Encoding encodingType_, int encodingVersion_, std::string formatType_, int formatVersion_)
 DMX (std::span< const std::byte > dmxData)
 DMX (std::string_view dmxData)
 operator bool () const
Encoding getEncodingType () const
void setEncodingType (Encoding encodingType_)
bool doesEncodingTypeHaveUnicodePrefix () const
void shouldEncodingTypeHaveUnicodePrefix (bool encodingTypeHasUnicodePrefix_)
int getEncodingVersion () const
void setEncodingVersion (int encodingVersion_)
std::string_view getFormatType () const
void setFormatType (std::string formatType_)
int getFormatVersion () const
void setFormatVersion (int formatVersion_)
DMXElementaddPrefixAttributeContainer ()
uint64_t getPrefixAttributeContainerCount () const
 Get the number of prefix attributes.
const std::vector< DMXElement > & getPrefixAttributeContainers () const
std::vector< DMXElement > & getPrefixAttributeContainers ()
void removePrefixAttributeContainer (unsigned int n)
bool hasElement (std::string_view key) const
 Check if the element list has one or more elements with the given name.
DMXElementaddElement (std::string type, std::string key)
 Add an element to the element list.
uint64_t getElementCount () const
 Get the number of elements.
uint64_t getElementCount (std::string_view key) const
 Get the number of elements with the given key.
const std::vector< DMXElement > & getElements () const
std::vector< DMXElement > & getElements ()
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 DMXElementoperator[] (unsigned int n) const
 Get the element in the element list at the given index.
DMXElementoperator[] (unsigned int n)
 Get the element in the element list at the given index.
const DMXElementoperator[] (std::string_view key) const
 Get the first element in the element list with the given key.
DMXElementoperator[] (std::string_view key)
 Get the first element in the element list with the given key, or create a new element if it doesn't exist.
const DMXElementoperator() (std::string_view key) const
 Get the first element in the element list with the given key.
DMXElementoperator() (std::string_view key)
 Get the first element in the element list with the given key, or create a new element if it doesn't exist.
const DMXElementoperator() (std::string_view key, unsigned int n) const
 Get the nth element in the element list with the given key.
DMXElementoperator() (std::string_view key, unsigned int n)
 Get the nth element in the element list with the given key, or create a new element if it doesn't exist.
void removeElement (unsigned int n)
 Remove an element from the element list and update all element references.
std::vector< std::byte > bake () const
void bake (const std::filesystem::path &dmxPath) const

Static Public Member Functions

static constexpr bool isEncodingVersionValid (Encoding encodingType, int encodingVersion)
static DMXValue::UUID createRandomUUID ()
static const DMXElementgetInvalidElement ()

Protected Attributes

Encoding encodingType = ENCODING_INVALID
bool encodingTypeHasUnicodePrefix = false
int encodingVersion = -1
std::string formatType
int formatVersion = -1
std::vector< DMXElementprefixAttributeContainers
std::vector< DMXElementelements

Detailed Description

Definition at line 695 of file DMX.h.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 775 of file DMX.h.

◆ iterator

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

Definition at line 765 of file DMX.h.

Member Enumeration Documentation

◆ Encoding

Enumerator
ENCODING_INVALID 
ENCODING_BINARY_OLD 
ENCODING_BINARY_OLD_SFM 
ENCODING_BINARY 
ENCODING_BINARY_SEQIDS 
ENCODING_KEYVALUES2_OLD 
ENCODING_KEYVALUES2_FLAT_OLD 
ENCODING_KEYVALUES2 
ENCODING_KEYVALUES2_FLAT 
ENCODING_KEYVALUES2_NOIDS 

Definition at line 697 of file DMX.h.

Constructor & Destructor Documentation

◆ DMX() [1/3]

DMX::DMX ( Encoding encodingType_,
int encodingVersion_,
std::string formatType_,
int formatVersion_ )

Definition at line 504 of file DMX.cpp.

◆ DMX() [2/3]

DMX::DMX ( std::span< const std::byte > dmxData)
explicit

Definition at line 510 of file DMX.cpp.

◆ DMX() [3/3]

DMX::DMX ( std::string_view dmxData)
explicit

Definition at line 851 of file DMX.cpp.

Member Function Documentation

◆ addElement()

DMXElement & DMX::addElement ( std::string type,
std::string key )

Add an element to the element list.

Definition at line 930 of file DMX.cpp.

◆ addPrefixAttributeContainer()

DMXElement & DMX::addPrefixAttributeContainer ( )

Definition at line 903 of file DMX.cpp.

◆ bake() [1/2]

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

Definition at line 1054 of file DMX.cpp.

◆ bake() [2/2]

void DMX::bake ( const std::filesystem::path & dmxPath) const

Definition at line 1063 of file DMX.cpp.

◆ begin() [1/2]

iterator kvpp::DMX::begin ( )
inlinenodiscardconstexpr

Definition at line 767 of file DMX.h.

◆ begin() [2/2]

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

Definition at line 777 of file DMX.h.

◆ cbegin()

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

Definition at line 785 of file DMX.h.

◆ cend()

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

Definition at line 789 of file DMX.h.

◆ createRandomUUID()

DMXValue::UUID DMX::createRandomUUID ( )
staticnodiscard

Definition at line 1067 of file DMX.cpp.

◆ doesEncodingTypeHaveUnicodePrefix()

bool DMX::doesEncodingTypeHaveUnicodePrefix ( ) const
nodiscard

Definition at line 869 of file DMX.cpp.

◆ end() [1/2]

iterator kvpp::DMX::end ( )
inlinenodiscardconstexpr

Definition at line 771 of file DMX.h.

◆ end() [2/2]

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

Definition at line 781 of file DMX.h.

◆ getElementCount() [1/2]

uint64_t DMX::getElementCount ( ) const
nodiscard

Get the number of elements.

Definition at line 939 of file DMX.cpp.

◆ getElementCount() [2/2]

uint64_t DMX::getElementCount ( std::string_view key) const
nodiscard

Get the number of elements with the given key.

Definition at line 943 of file DMX.cpp.

◆ getElements() [1/2]

std::vector< DMXElement > & DMX::getElements ( )
nodiscard

Definition at line 957 of file DMX.cpp.

◆ getElements() [2/2]

const std::vector< DMXElement > & DMX::getElements ( ) const
nodiscard

Definition at line 953 of file DMX.cpp.

◆ getEncodingType()

DMX::Encoding DMX::getEncodingType ( ) const
nodiscard

Definition at line 858 of file DMX.cpp.

◆ getEncodingVersion()

int DMX::getEncodingVersion ( ) const
nodiscard

Definition at line 877 of file DMX.cpp.

◆ getFormatType()

std::string_view DMX::getFormatType ( ) const
nodiscard

Definition at line 887 of file DMX.cpp.

◆ getFormatVersion()

int DMX::getFormatVersion ( ) const
nodiscard

Definition at line 895 of file DMX.cpp.

◆ getInvalidElement()

const DMXElement & DMX::getInvalidElement ( )
staticnodiscard

Definition at line 1079 of file DMX.cpp.

◆ getPrefixAttributeContainerCount()

uint64_t DMX::getPrefixAttributeContainerCount ( ) const
nodiscard

Get the number of prefix attributes.

Definition at line 908 of file DMX.cpp.

◆ getPrefixAttributeContainers() [1/2]

std::vector< DMXElement > & DMX::getPrefixAttributeContainers ( )
nodiscard

Definition at line 916 of file DMX.cpp.

◆ getPrefixAttributeContainers() [2/2]

const std::vector< DMXElement > & DMX::getPrefixAttributeContainers ( ) const
nodiscard

Definition at line 912 of file DMX.cpp.

◆ hasElement()

bool DMX::hasElement ( std::string_view key) const
nodiscard

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

Definition at line 926 of file DMX.cpp.

◆ isEncodingVersionValid()

constexpr bool kvpp::DMX::isEncodingVersionValid ( Encoding encodingType,
int encodingVersion )
inlinestaticnodiscardconstexpr

Definition at line 824 of file DMX.h.

◆ operator bool()

DMX::operator bool ( ) const
explicitnodiscard

Definition at line 854 of file DMX.cpp.

◆ operator()() [1/4]

DMXElement & DMX::operator() ( std::string_view key)
nodiscard

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

Definition at line 986 of file DMX.cpp.

◆ operator()() [2/4]

const DMXElement & DMX::operator() ( std::string_view key) const
nodiscard

Get the first element in the element list with the given key.

Definition at line 977 of file DMX.cpp.

◆ operator()() [3/4]

DMXElement & DMX::operator() ( std::string_view key,
unsigned int n )
nodiscard

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

Definition at line 1010 of file DMX.cpp.

◆ operator()() [4/4]

const DMXElement & DMX::operator() ( std::string_view key,
unsigned int n ) const
nodiscard

Get the nth element in the element list with the given key.

Definition at line 995 of file DMX.cpp.

◆ operator[]() [1/4]

DMXElement & DMX::operator[] ( std::string_view key)
nodiscard

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

Definition at line 973 of file DMX.cpp.

◆ operator[]() [2/4]

const DMXElement & DMX::operator[] ( std::string_view key) const
nodiscard

Get the first element in the element list with the given key.

Definition at line 969 of file DMX.cpp.

◆ operator[]() [3/4]

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

Get the element in the element list at the given index.

Definition at line 965 of file DMX.cpp.

◆ operator[]() [4/4]

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

Get the element in the element list at the given index.

Definition at line 961 of file DMX.cpp.

◆ removeElement()

void DMX::removeElement ( unsigned int n)

Remove an element from the element list and update all element references.

Definition at line 1025 of file DMX.cpp.

◆ removePrefixAttributeContainer()

void DMX::removePrefixAttributeContainer ( unsigned int n)

Definition at line 920 of file DMX.cpp.

◆ setEncodingType()

void DMX::setEncodingType ( Encoding encodingType_)

Definition at line 862 of file DMX.cpp.

◆ setEncodingVersion()

void DMX::setEncodingVersion ( int encodingVersion_)

Definition at line 881 of file DMX.cpp.

◆ setFormatType()

void DMX::setFormatType ( std::string formatType_)

Definition at line 891 of file DMX.cpp.

◆ setFormatVersion()

void DMX::setFormatVersion ( int formatVersion_)

Definition at line 899 of file DMX.cpp.

◆ shouldEncodingTypeHaveUnicodePrefix()

void DMX::shouldEncodingTypeHaveUnicodePrefix ( bool encodingTypeHasUnicodePrefix_)

Definition at line 873 of file DMX.cpp.

Member Data Documentation

◆ elements

std::vector<DMXElement> kvpp::DMX::elements
protected

Definition at line 859 of file DMX.h.

◆ encodingType

Encoding kvpp::DMX::encodingType = ENCODING_INVALID
protected

Definition at line 852 of file DMX.h.

◆ encodingTypeHasUnicodePrefix

bool kvpp::DMX::encodingTypeHasUnicodePrefix = false
protected

Definition at line 853 of file DMX.h.

◆ encodingVersion

int kvpp::DMX::encodingVersion = -1
protected

Definition at line 854 of file DMX.h.

◆ formatType

std::string kvpp::DMX::formatType
protected

Definition at line 855 of file DMX.h.

◆ formatVersion

int kvpp::DMX::formatVersion = -1
protected

Definition at line 856 of file DMX.h.

◆ prefixAttributeContainers

std::vector<DMXElement> kvpp::DMX::prefixAttributeContainers
protected

Definition at line 858 of file DMX.h.


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