diff options
Diffstat (limited to 'lib/RT.hpp')
-rw-r--r-- | lib/RT.hpp | 86 |
1 files changed, 86 insertions, 0 deletions
@@ -17,10 +17,72 @@ typedef float Float; | |||
17 | typedef bool Bool; | 17 | typedef bool Bool; |
18 | typedef std::string String; | 18 | typedef std::string String; |
19 | 19 | ||
20 | template<typename T1> | ||
21 | struct Maybe | ||
22 | { | ||
23 | T1 data; | ||
24 | bool valid; | ||
25 | }; | ||
26 | |||
27 | template<typename T> | ||
28 | struct V2 { T x,y; }; | ||
29 | |||
30 | template<typename T> | ||
31 | struct V3 { T x,y,z; }; | ||
32 | |||
33 | template<typename T> | ||
34 | struct V4 { T x,y,z,w; }; | ||
35 | |||
36 | typedef struct V2<Int> V2I; | ||
37 | typedef struct V2<Word> V2U; | ||
38 | typedef struct V2<Float> V2F; | ||
39 | typedef struct V2<Bool> V2B; | ||
40 | |||
41 | typedef struct V3<Int> V3I; | ||
42 | typedef struct V3<Word> V3U; | ||
43 | typedef struct V3<Float> V3F; | ||
44 | typedef struct V3<Bool> V3B; | ||
45 | |||
46 | typedef struct V4<Int> V4I; | ||
47 | typedef struct V4<Word> V4U; | ||
48 | typedef struct V4<Float> V4F; | ||
49 | typedef struct V4<Bool> V4B; | ||
50 | |||
51 | typedef struct V2<V2F> M22F; | ||
52 | typedef struct V2<V3F> M32F; | ||
53 | typedef struct V2<V4F> M42F; | ||
54 | typedef struct V3<V2F> M23F; | ||
55 | typedef struct V3<V3F> M33F; | ||
56 | typedef struct V3<V4F> M43F; | ||
57 | typedef struct V4<V2F> M24F; | ||
58 | typedef struct V4<V3F> M34F; | ||
59 | typedef struct V4<V4F> M44F; | ||
60 | |||
61 | |||
20 | template<typename T> | 62 | template<typename T> |
21 | json toJSON(T &v); | 63 | json toJSON(T &v); |
22 | 64 | ||
23 | template<typename any> | 65 | template<typename any> |
66 | json toJSON(Maybe<any> &value) { | ||
67 | return json(); | ||
68 | } | ||
69 | |||
70 | template<typename any> | ||
71 | json toJSON(V2<any> &value) { | ||
72 | return json(); | ||
73 | } | ||
74 | |||
75 | template<typename any> | ||
76 | json toJSON(V3<any> &value) { | ||
77 | return json(); | ||
78 | } | ||
79 | |||
80 | template<typename any> | ||
81 | json toJSON(V4<any> &value) { | ||
82 | return json(); | ||
83 | } | ||
84 | |||
85 | template<typename any> | ||
24 | json toJSON(std::vector<any> &v) { | 86 | json toJSON(std::vector<any> &v) { |
25 | json obj = json::array(); | 87 | json obj = json::array(); |
26 | for (any i : v) { | 88 | for (any i : v) { |
@@ -38,6 +100,30 @@ template<typename T> | |||
38 | T fromJSON(T &v, json &obj); | 100 | T fromJSON(T &v, json &obj); |
39 | 101 | ||
40 | template<typename any> | 102 | template<typename any> |
103 | Maybe<any> fromJSON(Maybe<any> &v, json &obj) { | ||
104 | Maybe<any> a; | ||
105 | return a; | ||
106 | } | ||
107 | |||
108 | template<typename any> | ||
109 | V2<any> fromJSON(V2<any> &v, json &obj) { | ||
110 | V2<any> a; | ||
111 | return a; | ||
112 | } | ||
113 | |||
114 | template<typename any> | ||
115 | V3<any> fromJSON(V3<any> &v, json &obj) { | ||
116 | V3<any> a; | ||
117 | return a; | ||
118 | } | ||
119 | |||
120 | template<typename any> | ||
121 | V4<any> fromJSON(V4<any> &v, json &obj) { | ||
122 | V4<any> a; | ||
123 | return a; | ||
124 | } | ||
125 | |||
126 | template<typename any> | ||
41 | std::vector<any> fromJSON(std::vector<any> &v, json &obj) { | 127 | std::vector<any> fromJSON(std::vector<any> &v, json &obj) { |
42 | std::vector<any> a; | 128 | std::vector<any> a; |
43 | return a; | 129 | return a; |