This repository was archived by the owner on Dec 10, 2022. It is now read-only.
forked from ataulien/ZenLib
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathzenParserPropRead.h
104 lines (87 loc) · 2.82 KB
/
zenParserPropRead.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include "parserImpl.h"
#include "zenParser.h"
namespace ZenLoad
{
/**
* @brief Templated function-calls to read the right type of data
* and convert it to a string for the given type
*/
template <typename T>
inline void read(ZenParser& /*p*/, T& /*outData*/, const char* /*exName*/);
template <>
inline void read<float>(ZenParser& p, float& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<bool>(ZenParser& p, bool& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<uint32_t>(ZenParser& p, uint32_t& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<int32_t>(ZenParser& p, int32_t& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<uint16_t>(ZenParser& p, uint16_t& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<uint8_t>(ZenParser& p, uint8_t& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<ZMath::float2>(ZenParser& p, ZMath::float2& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<ZMath::float3>(ZenParser& p, ZMath::float3& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<ZMath::float4>(ZenParser& p, ZMath::float4& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<ZMath::Matrix>(ZenParser& p, ZMath::Matrix& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<std::string>(ZenParser& p, std::string& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <>
inline void read<Daedalus::ZString>(ZenParser& p, Daedalus::ZString& outData, const char* exName)
{
p.getImpl()->readEntry(exName, outData);
}
template <typename... T>
static void ReadObjectProperties(ZenParser& ZenParser, std::pair<const char*, T*>... d)
{
auto fn = [&ZenParser](auto pair) {
// Read the given datatype from the file
read<typename std::remove_pointer<decltype(pair.second)>::type>(ZenParser, *pair.second, pair.first);
};
auto x = {(fn(d), 0)...};
(void)x;
}
template <typename S>
static std::pair<const char*, S*> Prop(const char* t, S& s)
{
return std::make_pair(t, &s);
}
} // namespace ZenLoad