5#ifndef TILESON_PROJECTPROPERTYTYPES_HPP
6#define TILESON_PROJECTPROPERTYTYPES_HPP
16 inline const std::vector<tson::EnumDefinition> &
getEnums()
const;
17 inline const std::vector<tson::TiledClass> &
getClasses()
const;
23 std::vector<tson::EnumDefinition> m_enums;
24 std::vector<tson::TiledClass> m_classes;
25 bool m_unhandledContentFound {
false};
33 m_unhandledContentFound =
false;
35 if(json.
count(
"propertyTypes") > 0 && json[
"propertyTypes"].
isArray())
37 auto &array = json.
array(
"propertyTypes");
38 std::vector<tson::IJson*> classes;
39 std::vector<tson::IJson*> other;
40 std::for_each(array.begin(), array.end(), [&](std::unique_ptr<IJson> &item)
43 if(j.count(
"type") > 0)
45 std::string t = j[
"type"].get<std::string>();
48 m_enums.emplace_back(j);
52 classes.push_back(item.get());
55 other.push_back(item.get());
59 std::for_each(classes.begin(), classes.end(), [&](
IJson *item)
61 m_classes.emplace_back(*item, project);
65 m_unhandledContentFound =
true;
71 const std::vector<tson::EnumDefinition> &ProjectPropertyTypes::getEnums()
const
76 const std::vector<tson::TiledClass> &ProjectPropertyTypes::getClasses()
const
81 bool ProjectPropertyTypes::isUnhandledContentFound()
const
83 return m_unhandledContentFound;
88 auto it = std::find_if(m_enums.begin(), m_enums.end(), [&](
const EnumDefinition &def)
90 return def.getName() == name;
93 if(it != m_enums.end())
94 return &it.operator*();
101 auto it = std::find_if(m_classes.begin(), m_classes.end(), [&](
const TiledClass &def)
103 return def.getName() == name;
106 if(it != m_classes.end())
107 return &it.operator*();
Definition TiledEnum.hpp:11
virtual bool isArray() const =0
virtual size_t count(std::string_view key) const =0
virtual std::vector< std::unique_ptr< IJson > > array()=0
Definition ProjectPropertyTypes.hpp:11
ProjectPropertyTypes()=default
const std::vector< tson::EnumDefinition > & getEnums() const
Definition ProjectPropertyTypes.hpp:71
const std::vector< tson::TiledClass > & getClasses() const
Definition ProjectPropertyTypes.hpp:76
tson::EnumDefinition * getEnumDefinition(std::string_view name)
Definition ProjectPropertyTypes.hpp:86
tson::TiledClass * getClass(std::string_view name)
Definition ProjectPropertyTypes.hpp:99
bool isUnhandledContentFound() const
Definition ProjectPropertyTypes.hpp:81
bool parse(IJson &json, tson::Project *project)
Definition ProjectPropertyTypes.hpp:29
Definition Project.hpp:20
Definition TiledClass.hpp:11