Tileson
1.4.0
A helpful json parser for Tiled maps
Loading...
Searching...
No Matches
include
tiled
Frame.hpp
Go to the documentation of this file.
1
//
2
// Created by robin on 22.03.2020.
3
//
4
5
#ifndef TILESON_FRAME_HPP
6
#define TILESON_FRAME_HPP
7
8
//#include "../external/json.hpp"
9
10
namespace
tson
11
{
12
class
Frame
13
{
14
public
:
15
inline
Frame
() =
default
;
16
inline
Frame
(
int
duration, uint32_t tileId);
17
inline
explicit
Frame
(
IJson
&json);
18
19
inline
bool
parse
(
IJson
&json);
20
21
[[nodiscard]]
inline
int
getDuration
()
const
;
22
[[nodiscard]]
inline
uint32_t
getTileId
()
const
;
23
24
private
:
25
int
m_duration {};
26
uint32_t m_tileId {};
27
};
28
}
29
35
tson::Frame::Frame
(
int
duration, uint32_t tileId) : m_duration {duration}, m_tileId {tileId}
36
{
37
38
}
39
44
tson::Frame::Frame
(
IJson
&json)
45
{
46
parse(json);
47
}
48
54
bool
tson::Frame::parse
(
IJson
&json)
55
{
56
bool
allFound =
true
;
57
58
if
(json.
count
(
"duration"
) > 0) m_duration = json[
"duration"
].
get
<
int
>();
else
allFound =
false
;
59
if
(json.
count
(
"tileid"
) > 0) m_tileId = json[
"tileid"
].get<uint32_t>() + 1;
else
allFound =
false
;
60
61
return
allFound;
62
}
63
68
int
tson::Frame::getDuration
()
const
69
{
70
return
m_duration;
71
}
72
77
uint32_t
tson::Frame::getTileId
()
const
78
{
79
return
m_tileId;
80
}
81
82
#endif
//TILESON_FRAME_HPP
tson::Frame
Definition
Frame.hpp:13
tson::Frame::getDuration
int getDuration() const
Definition
Frame.hpp:68
tson::Frame::Frame
Frame()=default
tson::Frame::getTileId
uint32_t getTileId() const
Definition
Frame.hpp:77
tson::Frame::parse
bool parse(IJson &json)
Definition
Frame.hpp:54
tson::IJson
Definition
IJson.hpp:11
tson::IJson::get
T get(std::string_view key)
Definition
IJson.hpp:82
tson::IJson::count
virtual size_t count(std::string_view key) const =0
tson
Definition
Base64.hpp:12
Generated by
1.9.8