SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
dmxpp.h
Go to the documentation of this file.
1#pragma once
2
3#include "structs/Value.h"
4
5class BufferStream;
6
7namespace dmxpp {
8
9namespace Format {
10
11constexpr std::string_view TEXT = "keyvalues2";
12constexpr std::string_view BINARY = "binary";
13
14} // namespace Format
15
16class DMX {
17public:
18 DMX(const std::byte* dmxData, std::size_t dmxSize);
19
20 DMX(const unsigned char* dmxData, std::size_t dmxSize);
21
22 explicit DMX(const std::vector<std::byte>& dmxData);
23
24 explicit DMX(const std::vector<unsigned char>& dmxData);
25
26 [[nodiscard]] explicit operator bool() const;
27
28 [[nodiscard]] std::string_view getFormatType() const;
29
30 [[nodiscard]] int getFormatVersion() const;
31
32 [[nodiscard]] std::string_view getEncodingType() const;
33
34 [[nodiscard]] int getEncodingVersion() const;
35
36 [[nodiscard]] const std::vector<DMXElement>& getElements() const;
37
38protected:
39 [[nodiscard]] bool openText(const std::byte* dmxData, std::size_t dmxSize);
40
41 [[nodiscard]] bool openBinary(BufferStream& stream);
42
43private:
44 bool opened = false;
45
46 // Header
47 std::string formatType;
48 int formatVersion = -1;
49 std::string encodingType;
50 int encodingVersion = -1;
51
52 // Elements
53 std::vector<DMXElement> elements;
54};
55
56} // namespace dmxpp
int getFormatVersion() const
Definition: dmxpp.cpp:68
bool openBinary(BufferStream &stream)
Definition: dmxpp.cpp:88
const std::vector< DMXElement > & getElements() const
Definition: dmxpp.cpp:80
std::string_view getEncodingType() const
Definition: dmxpp.cpp:72
bool openText(const std::byte *dmxData, std::size_t dmxSize)
Definition: dmxpp.cpp:84
std::string_view getFormatType() const
Definition: dmxpp.cpp:64
int getEncodingVersion() const
Definition: dmxpp.cpp:76
constexpr std::string_view TEXT
Definition: dmxpp.h:11
constexpr std::string_view BINARY
Definition: dmxpp.h:12
Definition: dmxpp.h:7