17using UUID = std::array<std::byte, 16>;
177enum class ID : uint8_t {
331 incompatible =
false;
372 return static_cast<std::byte
>(out);
413 return static_cast<std::byte
>(out);
454 return static_cast<std::byte
>(out);
468 std::vector<std::byte>,
481 std::vector<Element>,
482 std::vector<int32_t>,
485 std::vector<std::string>,
486 std::vector<std::vector<std::byte>>,
490 std::vector<Vector2>,
491 std::vector<Vector3>,
492 std::vector<Vector4>,
493 std::vector<EulerAngles>,
494 std::vector<Quaternion>,
495 std::vector<Matrix4x4>,
496 std::vector<uint64_t>,
502 return static_cast<ID>(
static_cast<uint8_t
>(id) -
static_cast<uint8_t
>(
ID::VALUE_END));
509 return static_cast<ID>(
static_cast<uint8_t
>(id) +
static_cast<uint8_t
>(
ID::VALUE_END));
519 if (
id ==
"element")
return ELEMENT;
520 if (
id ==
"int")
return INT32;
521 if (
id ==
"float")
return FLOAT;
522 if (
id ==
"bool")
return BOOL;
523 if (
id ==
"string")
return STRING;
525 if (
id ==
"objectid")
return UUID;
526 if (
id ==
"time")
return TIME;
527 if (
id ==
"color")
return COLOR;
528 if (
id ==
"vector2")
return VECTOR2;
529 if (
id ==
"vector3")
return VECTOR3;
530 if (
id ==
"vector4")
return VECTOR4;
534 if (
id ==
"uint64")
return UINT64;
535 if (
id ==
"uint8")
return UINT8;
536 if (
id.ends_with(
"_array")) {
552 [[nodiscard]]
explicit operator bool()
const;
554 [[nodiscard]] std::string_view
getKey()
const;
556 void setKey(std::string key_);
566 return std::get<T>(this->
value);
588 [[nodiscard]]
explicit operator bool()
const;
591 [[nodiscard]] std::string_view
getType()
const;
594 void setType(std::string type_);
597 [[nodiscard]] std::string_view
getKey()
const;
600 void setKey(std::string key_);
609 [[nodiscard]]
bool hasAttribute(std::string_view attributeKey)
const;
621 [[nodiscard]]
const std::vector<DMXAttribute>&
getAttributes()
const;
626 using iterator = std::vector<DMXAttribute>::iterator;
710 DMX(
Encoding encodingType_,
int encodingVersion_, std::string formatType_,
int formatVersion_);
712 explicit DMX(std::span<const std::byte> dmxData);
714 explicit DMX(std::string_view dmxData);
716 [[nodiscard]]
explicit operator bool()
const;
750 [[nodiscard]]
bool hasElement(std::string_view key)
const;
761 [[nodiscard]]
const std::vector<DMXElement>&
getElements()
const;
763 [[nodiscard]] std::vector<DMXElement>&
getElements();
765 using iterator = std::vector<DMXElement>::iterator;
820 [[nodiscard]] std::vector<std::byte>
bake()
const;
822 void bake(
const std::filesystem::path& dmxPath)
const;
864DMX operator""_kv2(
const char* str, std::size_t len);
bool isInvalid() const
Check if the given attribute is invalid.
DMXAttribute & operator=(DMXValue::Generic value_)
Set the value associated with the attribute.
void setValue(DMXValue::Generic value_)
Set the value associated with the attribute.
bool isValueArray() const
const DMXValue::Generic & getValue() const
DMXValue::ID getValueType() const
void setKey(std::string key_)
std::string getValueString() const
std::string_view getKey() const
static const DMXAttribute & getInvalidAttribute()
uint64_t getAttributeCount() const
Get the number of child attributes.
constexpr const_iterator cbegin() const
void setUUID(const DMXValue::UUID &guid_)
void setKey(std::string key_)
Set the key associated with the element.
bool hasAttribute(std::string_view attributeKey) const
Check if the element has one or more children with the given name.
constexpr const_iterator cend() const
const DMXAttribute & operator()(std::string_view attributeKey) const
Get the first attribute of the element with the given key.
constexpr iterator begin()
std::string_view getType() const
Get the C++ type the element maps to.
const DMXAttribute & operator[](unsigned int n) const
Get the attribute of the element at the given index.
std::vector< DMXAttribute >::const_iterator const_iterator
constexpr const_iterator end() const
constexpr const_iterator begin() const
DMXAttribute & addAttribute(std::string key_, DMXValue::Generic value_={})
Add an attribute to the element.
const std::vector< DMXAttribute > & getAttributes() const
Get the child attributes of the element.
void setType(std::string type_)
Set the C++ type the element maps to.
std::vector< DMXAttribute > attributes
const DMXValue::UUID & getUUID() const
void removeAttribute(unsigned int n)
Remove an attribute from the element.
std::vector< DMXAttribute >::iterator iterator
std::string_view getKey() const
Get the key associated with the element.
std::vector< DMXElement > prefixAttributeContainers
const DMXElement & operator()(std::string_view key) const
Get the first element in the element list with the given key.
constexpr iterator begin()
int getFormatVersion() const
DMX(Encoding encodingType_, int encodingVersion_, std::string formatType_, int formatVersion_)
std::vector< DMXElement >::const_iterator const_iterator
void removeElement(unsigned int n)
Remove an element from the element list and update all element references.
bool doesEncodingTypeHaveUnicodePrefix() const
static const DMXElement & getInvalidElement()
@ ENCODING_KEYVALUES2_FLAT
@ ENCODING_KEYVALUES2_NOIDS
@ ENCODING_KEYVALUES2_FLAT_OLD
@ ENCODING_KEYVALUES2_OLD
@ ENCODING_BINARY_OLD_SFM
bool encodingTypeHasUnicodePrefix
const std::vector< DMXElement > & getPrefixAttributeContainers() const
std::vector< DMXElement >::iterator iterator
void shouldEncodingTypeHaveUnicodePrefix(bool encodingTypeHasUnicodePrefix_)
void setFormatType(std::string formatType_)
constexpr const_iterator begin() const
std::vector< DMXElement > elements
constexpr const_iterator end() const
Encoding getEncodingType() const
std::vector< std::byte > bake() const
uint64_t getElementCount() const
Get the number of elements.
const std::vector< DMXElement > & getElements() const
bool hasElement(std::string_view key) const
Check if the element list has one or more elements with the given name.
void setEncodingVersion(int encodingVersion_)
constexpr const_iterator cend() const
constexpr const_iterator cbegin() const
DMXElement & addPrefixAttributeContainer()
void removePrefixAttributeContainer(unsigned int n)
static DMXValue::UUID createRandomUUID()
const DMXElement & operator[](unsigned int n) const
Get the element in the element list at the given index.
static constexpr bool isEncodingVersionValid(Encoding encodingType, int encodingVersion)
void setFormatVersion(int formatVersion_)
std::string_view getFormatType() const
DMXElement & addElement(std::string type, std::string key)
Add an element to the element list.
void setEncodingType(Encoding encodingType_)
int getEncodingVersion() const
uint64_t getPrefixAttributeContainerCount() const
Get the number of prefix attributes.
IDVersion
Not representative of DMX encoding version, although the attribute type enum variances are linked to ...
sourcepp::math::Mat4x4f Matrix4x4
constexpr ID arrayIDToInnerID(ID id)
std::variant< std::monostate, Element, int32_t, float, bool, std::string, std::vector< std::byte >, UUID, Time, Color, Vector2, Vector3, Vector4, EulerAngles, Quaternion, Matrix4x4, uint64_t, uint8_t, std::vector< Element >, std::vector< int32_t >, std::vector< float >, std::vector< bool >, std::vector< std::string >, std::vector< std::vector< std::byte > >, std::vector< UUID >, std::vector< Time >, std::vector< Color >, std::vector< Vector2 >, std::vector< Vector3 >, std::vector< Vector4 >, std::vector< EulerAngles >, std::vector< Quaternion >, std::vector< Matrix4x4 >, std::vector< uint64_t >, std::vector< uint8_t > > Generic
constexpr ID stringToID(std::string_view id)
std::array< std::byte, 16 > UUID
sourcepp::math::Vec3f Vector3
std::string idToString(ID id)
constexpr ID decodeID(IDv1 id)
constexpr ID innerIDToArrayID(ID id)
sourcepp::math::Vec4f Vector4
sourcepp::math::Vec2f Vector2
std::vector< std::byte > ByteArray
constexpr std::byte encodeID(ID id, IDVersion version, bool &incompatible)
static constexpr int32_t NULL_INDEX
static constexpr int32_t EXTERNAL_INDEX