-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathDeserializer.h
78 lines (63 loc) · 2.68 KB
/
Deserializer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include <memory>
#include <string>
#include <cstdint>
namespace tinyxml2
{
class XMLDocument;
class XMLElement;
}
namespace qualisys_cpp_sdk
{
struct Deserializer
{
private:
std::shared_ptr<tinyxml2::XMLDocument> mDocument;
tinyxml2::XMLElement* mPtr;
Deserializer(std::shared_ptr<tinyxml2::XMLDocument> document, tinyxml2::XMLElement* element);
public:
Deserializer(const char* data);
Deserializer FindChild(const char* elementName) const;
Deserializer FindNextSibling(const char* elementName) const;
bool TryReadElementDouble(const char* elementName, double& output) const;
bool TryReadElementFloat(const char* elementName, float& output) const;
bool TryReadElementUnsignedInt32(const char* elementName, std::uint32_t& output) const;
bool TryReadElementString(const char* elementName, std::string& output) const;
bool TryReadElementBool(const std::string& element, bool& value) const;
double ReadAttributeDouble(const char* attributeName, double defaultValue = 0) const;
std::uint32_t ReadAttributeUnsignedInt(const char* attributeName, std::uint32_t defaultValue = 0) const;
std::int32_t ReadAttributeInt(const char* attributeName, std::int32_t defaultValue = 0) const;
std::string ReadAttributeString(const char* name) const;
float ReadAttributeFloat(const char* name, float defaultValue = 0.0f) const;
bool ReadAttributeBool(const char* attributeName, bool defaultValue = 0) const;
std::string ReadString() const;
int ReadInt(std::int32_t defaultValue = 0) const;
unsigned int ReadUnsignedInt(std::int32_t defaultValue = 0) const;
float ReadFloat(float defaultValue = 0.0f) const;
bool operator==(const Deserializer& other) const;
bool operator!=(const Deserializer& other) const;
explicit operator bool() const;
};
struct ChildElementRange
{
private:
Deserializer& mParent;
const char* mElementName;
public:
ChildElementRange() = delete;
ChildElementRange(Deserializer& parent, const char* elementName);
struct Iterator
{
Deserializer mCurrent;
const ChildElementRange& mChildElementRange;
explicit Iterator(const ChildElementRange& range);
Iterator(const ChildElementRange& range, std::size_t index);
Deserializer operator*() const;
Iterator& operator++();
bool operator!=(const Iterator& other) const;
};
Iterator begin() const;
Iterator end() const;
};
std::string ToLowerXmlString(std::string& str);
}