Tileson 1.4.0
A helpful json parser for Tiled maps
Loading...
Searching...
No Matches
Transformations.hpp
Go to the documentation of this file.
1//
2// Created by robin on 04.04.2021.
3//
4
5#ifndef TILESON_TRANSFORMATIONS_HPP
6#define TILESON_TRANSFORMATIONS_HPP
7
8namespace tson
9{
11 {
12 public:
13 inline Transformations() = default;
14 inline explicit Transformations(IJson &json);
15 inline bool parse(IJson &json);
16
17 inline bool allowHflip() const;
18 inline bool allowPreferuntransformed() const;
19 inline bool allowRotation() const;
20 inline bool allowVflip() const;
21
22 private:
23 bool m_hflip {};
24 bool m_preferuntransformed {};
25 bool m_rotate {};
26 bool m_vflip {};
27 };
28
30 {
31 parse(json);
32 }
33
35 {
36 if(json.count("hflip") > 0) m_hflip = json["hflip"].get<bool>(); //Optional
37 if(json.count("preferuntransformed") > 0) m_preferuntransformed = json["preferuntransformed"].get<bool>(); //Optional
38 if(json.count("rotate") > 0) m_rotate = json["rotate"].get<bool>(); //Optional
39 if(json.count("vflip") > 0) m_vflip = json["vflip"].get<bool>(); //Optional
40
41 return true;
42 }
43
49 {
50 return m_hflip;
51 }
52
58 {
59 return m_preferuntransformed;
60 }
61
67 {
68 return m_rotate;
69 }
70
76 {
77 return m_vflip;
78 }
79}
80
81#endif //TILESON_TRANSFORMATIONS_HPP
Definition IJson.hpp:11
T get(std::string_view key)
Definition IJson.hpp:82
virtual size_t count(std::string_view key) const =0
Definition Transformations.hpp:11
bool parse(IJson &json)
Definition Transformations.hpp:34
bool allowVflip() const
Definition Transformations.hpp:75
bool allowRotation() const
Definition Transformations.hpp:66
bool allowHflip() const
Definition Transformations.hpp:48
bool allowPreferuntransformed() const
Definition Transformations.hpp:57
Definition Base64.hpp:12