1 /* !!!! GENERATED FILE - DO NOT EDIT !!!!
2  * --------------------------------------
3  *
4  * This file is part of liblcf. Copyright (c) 2021 liblcf authors.
5  * https://github.com/EasyRPG/liblcf - https://easyrpg.org
6  *
7  * liblcf is Free/Libre Open Source Software, released under the MIT License.
8  * For the full copyright and license information, please view the COPYING
9  * file that was distributed with this source code.
10  */
11 
12 #ifndef LCF_RPG_TREEMAP_H
13 #define LCF_RPG_TREEMAP_H
14 
15 // Headers
16 #include <stdint.h>
17 #include <vector>
18 #include "lcf/rpg/mapinfo.h"
19 #include "lcf/rpg/start.h"
20 #include "lcf/context.h"
21 #include <ostream>
22 #include <type_traits>
23 
24 /**
25  * rpg::TreeMap class.
26  */
27 namespace lcf {
28 namespace rpg {
29 	class TreeMap {
30 	public:
31 		std::string lmt_header;
32 		enum MapType {
33 			MapType_root = 0,
34 			MapType_map = 1,
35 			MapType_area = 2
36 		};
37 		static constexpr auto kMapTypeTags = lcf::makeEnumTags<MapType>(
38 			"root",
39 			"map",
40 			"area"
41 		);
42 
43 		std::vector<MapInfo> maps;
44 		std::vector<int32_t> tree_order;
45 		int32_t active_node = 0;
46 		Start start;
47 	};
48 	inline std::ostream& operator<<(std::ostream& os, TreeMap::MapType code) {
49 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
50 		return os;
51 	}
52 
53 	inline bool operator==(const TreeMap& l, const TreeMap& r) {
54 		return l.maps == r.maps
55 		&& l.tree_order == r.tree_order
56 		&& l.active_node == r.active_node
57 		&& l.start == r.start;
58 	}
59 
60 	inline bool operator!=(const TreeMap& l, const TreeMap& r) {
61 		return !(l == r);
62 	}
63 
64 	std::ostream& operator<<(std::ostream& os, const TreeMap& obj);
65 
66 	template <typename F, typename ParentCtx = Context<void,void>>
67 	void ForEachString(TreeMap& obj, const F& f, const ParentCtx* parent_ctx = nullptr) {
68 		for (int i = 0; i < static_cast<int>(obj.maps.size()); ++i) {
69 			const auto ctx1 = Context<TreeMap, ParentCtx>{ "maps", i, &obj, parent_ctx };
70 			ForEachString(obj.maps[i], f, &ctx1);
71 		}
72 		const auto ctx4 = Context<TreeMap, ParentCtx>{ "start", -1, &obj, parent_ctx };
73 		ForEachString(obj.start, f, &ctx4);
74 		(void)obj;
75 		(void)f;
76 		(void)parent_ctx;
77 	}
78 
79 } // namespace rpg
80 } // namespace lcf
81 
82 #endif
83