From fcb7b86c2519f2fc928355e7c124b28ca35742da Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Fri, 10 Nov 2023 21:31:18 -0600 Subject: [PATCH] adding a global state var for the xml parsers --- .../cpp_templates/attribute_template.hpp | 3 + .../attribute_template_compoundvalue.cpp | 1 + .../cpp_templates/attribute_template_enum.cpp | 1 + .../attribute_template_multiflagvalue.cpp | 1 + .../cpp_templates/class_template.cpp | 12 +- .../cpp_templates/class_template.hpp | 14 +- xml_converter/generators/generate_cpp.py | 3 +- xml_converter/src/attribute/bool.cpp | 2 + xml_converter/src/attribute/bool.hpp | 3 + xml_converter/src/attribute/color.cpp | 1 + xml_converter/src/attribute/color.hpp | 3 + .../src/attribute/cull_chirality_gen.cpp | 1 + .../src/attribute/cull_chirality_gen.hpp | 3 + .../src/attribute/euler_rotation_gen.cpp | 1 + .../src/attribute/euler_rotation_gen.hpp | 3 + .../src/attribute/festival_filter_gen.cpp | 1 + .../src/attribute/festival_filter_gen.hpp | 3 + xml_converter/src/attribute/float.cpp | 1 + xml_converter/src/attribute/float.hpp | 2 + xml_converter/src/attribute/image.cpp | 1 + xml_converter/src/attribute/image.hpp | 3 + xml_converter/src/attribute/int.cpp | 1 + xml_converter/src/attribute/int.hpp | 2 + .../src/attribute/map_type_filter_gen.cpp | 1 + .../src/attribute/map_type_filter_gen.hpp | 3 + .../src/attribute/marker_category.cpp | 1 + .../src/attribute/marker_category.hpp | 3 + .../src/attribute/mount_filter_gen.cpp | 1 + .../src/attribute/mount_filter_gen.hpp | 3 + xml_converter/src/attribute/position_gen.cpp | 1 + xml_converter/src/attribute/position_gen.hpp | 3 + .../src/attribute/profession_filter_gen.cpp | 1 + .../src/attribute/profession_filter_gen.hpp | 3 + .../src/attribute/reset_behavior_gen.cpp | 1 + .../src/attribute/reset_behavior_gen.hpp | 3 + .../attribute/specialization_filter_gen.cpp | 1 + .../attribute/specialization_filter_gen.hpp | 3 + .../src/attribute/species_filter_gen.cpp | 1 + .../src/attribute/species_filter_gen.hpp | 3 + xml_converter/src/attribute/string.cpp | 1 + xml_converter/src/attribute/string.hpp | 2 + xml_converter/src/attribute/trail_data.cpp | 7 +- xml_converter/src/attribute/trail_data.hpp | 4 +- xml_converter/src/attribute/unique_id.cpp | 1 + xml_converter/src/attribute/unique_id.hpp | 3 + xml_converter/src/category_gen.cpp | 20 +-- xml_converter/src/category_gen.hpp | 5 +- xml_converter/src/icon_gen.cpp | 146 +++++++++--------- xml_converter/src/icon_gen.hpp | 3 +- xml_converter/src/packaging_xml.cpp | 23 ++- xml_converter/src/packaging_xml.hpp | 1 + xml_converter/src/parseable.cpp | 6 +- xml_converter/src/parseable.hpp | 6 +- .../src/state_structs/xml_parse_state.hpp | 11 ++ xml_converter/src/trail_gen.cpp | 82 +++++----- xml_converter/src/trail_gen.hpp | 3 +- 56 files changed, 265 insertions(+), 157 deletions(-) create mode 100644 xml_converter/src/state_structs/xml_parse_state.hpp diff --git a/xml_converter/generators/cpp_templates/attribute_template.hpp b/xml_converter/generators/cpp_templates/attribute_template.hpp index 3788bc5f..a8245b31 100644 --- a/xml_converter/generators/cpp_templates/attribute_template.hpp +++ b/xml_converter/generators/cpp_templates/attribute_template.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + {% if type == "Enum" %} #include "waypoint.pb.h" @@ -33,6 +35,7 @@ void xml_attribute_to_{{attribute_name}}( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, {{class_name}}* value, bool* is_set); diff --git a/xml_converter/generators/cpp_templates/attribute_template_compoundvalue.cpp b/xml_converter/generators/cpp_templates/attribute_template_compoundvalue.cpp index bcad298d..71c606a5 100644 --- a/xml_converter/generators/cpp_templates/attribute_template_compoundvalue.cpp +++ b/xml_converter/generators/cpp_templates/attribute_template_compoundvalue.cpp @@ -14,6 +14,7 @@ using namespace std; void xml_attribute_to_{{attribute_name}}( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, {{class_name}}* value, bool* is_set) { {{class_name}} {{attribute_name}}; diff --git a/xml_converter/generators/cpp_templates/attribute_template_enum.cpp b/xml_converter/generators/cpp_templates/attribute_template_enum.cpp index 339012f8..91fe3dcd 100644 --- a/xml_converter/generators/cpp_templates/attribute_template_enum.cpp +++ b/xml_converter/generators/cpp_templates/attribute_template_enum.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_{{attribute_name}}( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, {{class_name}}* value, bool* is_set) { {{class_name}} {{attribute_name}}; diff --git a/xml_converter/generators/cpp_templates/attribute_template_multiflagvalue.cpp b/xml_converter/generators/cpp_templates/attribute_template_multiflagvalue.cpp index 9c53b032..ff532c90 100644 --- a/xml_converter/generators/cpp_templates/attribute_template_multiflagvalue.cpp +++ b/xml_converter/generators/cpp_templates/attribute_template_multiflagvalue.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_{{attribute_name}}( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, {{class_name}}* value, bool* is_set) { {{class_name}} {{attribute_name}}; diff --git a/xml_converter/generators/cpp_templates/class_template.cpp b/xml_converter/generators/cpp_templates/class_template.cpp index 45239935..7dcd5716 100644 --- a/xml_converter/generators/cpp_templates/class_template.cpp +++ b/xml_converter/generators/cpp_templates/class_template.cpp @@ -18,12 +18,12 @@ string {{cpp_class}}::classname() { return "{{xml_class_name}}"; } {% if cpp_class == "Category": %} - void {{cpp_class}}::init_from_xml(rapidxml::xml_node<>* node, vector* errors, string base_dir) { + void {{cpp_class}}::init_from_xml(rapidxml::xml_node<>* node, vector* errors, XMLParseState* state) { for (rapidxml::xml_attribute<>* attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute()) { - bool is_icon_value = this->default_icon.init_xml_attribute(attribute, errors); - bool is_trail_value = this->default_trail.init_xml_attribute(attribute, errors); + bool is_icon_value = this->default_icon.init_xml_attribute(attribute, errors, state); + bool is_trail_value = this->default_trail.init_xml_attribute(attribute, errors, state); - if (init_xml_attribute(attribute, errors, base_dir)) { + if (init_xml_attribute(attribute, errors, state)) { } else if (is_icon_value || is_trail_value) { } @@ -34,13 +34,13 @@ string {{cpp_class}}::classname() { } {% endif %} -bool {{cpp_class}}::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, string base_dir) { +bool {{cpp_class}}::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, XMLParseState* state) { string attributename; attributename = normalize(get_attribute_name(attribute)); {% for n, attribute_variable in enumerate(attribute_variables) %} {% for i, value in enumerate(attribute_variable.xml_fields) %} {{ "if" if i == n == 0 else "else if" }} (attributename == "{{value}}") { - {{attribute_variable.deserialize_xml_function}}(attribute, errors, {% if attribute_variable.uses_file_path %}base_dir, {% endif %}&(this->{{attribute_variable.attribute_name}}), &(this->{{attribute_variable.attribute_flag_name}}){% for side_effect in attribute_variable.deserialize_xml_side_effects %}, &(this->{{side_effect}}){% endfor %}); + {{attribute_variable.deserialize_xml_function}}(attribute, errors, state, &(this->{{attribute_variable.attribute_name}}), &(this->{{attribute_variable.attribute_flag_name}}){% for side_effect in attribute_variable.deserialize_xml_side_effects %}, &(this->{{side_effect}}){% endfor %}); } {% endfor %} {% endfor %} diff --git a/xml_converter/generators/cpp_templates/class_template.hpp b/xml_converter/generators/cpp_templates/class_template.hpp index 19d7aa26..b5db4eab 100644 --- a/xml_converter/generators/cpp_templates/class_template.hpp +++ b/xml_converter/generators/cpp_templates/class_template.hpp @@ -14,26 +14,26 @@ class {{cpp_class}} : public Parseable { public: - {% for attribute_variable in attribute_variables: %} - {% if attribute_variable.is_component == false: %} + {% for attribute_variable in attribute_variables %} + {% if attribute_variable.is_component == false %} {{attribute_variable.cpp_type}} {{attribute_variable.attribute_name}}; {% endif %} {% endfor %} - {% for attribute_variable in attribute_variables: %} - {% if attribute_variable.is_component == false: %} + {% for attribute_variable in attribute_variables %} + {% if attribute_variable.is_component == false %} bool {{attribute_variable.attribute_flag_name}} = false; {% endif %} {% endfor %} - {% if cpp_class == "Category": %} + {% if cpp_class == "Category" %} std::map children; Icon default_icon; Trail default_trail; - void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, std::string base_dir = ""); + void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, XMLParseState* state); {% endif %} virtual std::vector as_xml() const; virtual std::string classname(); - bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, std::string base_dir = ""); + bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, XMLParseState* state); waypoint::{{cpp_class}} as_protobuf() const; void parse_protobuf(waypoint::{{cpp_class}} proto_{{cpp_class_header}}); {% if attributes_of_type_marker_category %} diff --git a/xml_converter/generators/generate_cpp.py b/xml_converter/generators/generate_cpp.py index 4c7fa21d..abf01c0e 100644 --- a/xml_converter/generators/generate_cpp.py +++ b/xml_converter/generators/generate_cpp.py @@ -216,14 +216,15 @@ def generate_cpp_variable_data( cpp_includes.hpp_absolute_includes.add("string") cpp_includes.hpp_absolute_includes.add("vector") + cpp_includes.hpp_absolute_includes.add("functional") cpp_includes.hpp_relative_includes.add("rapidxml-1.13/rapidxml.hpp") cpp_includes.hpp_relative_includes.add("parseable.hpp") cpp_includes.hpp_relative_includes.add("waypoint.pb.h") + cpp_includes.hpp_relative_includes.add("state_structs/xml_parse_state.hpp") cpp_includes.hpp_forward_declarations.add("XMLError") cpp_includes.cpp_absolute_includes.add("iosfwd") cpp_includes.cpp_absolute_includes.add("string") - cpp_includes.hpp_absolute_includes.add("functional") cpp_includes.cpp_relative_includes.add("rapidxml-1.13/rapidxml.hpp") cpp_includes.cpp_relative_includes.add("string_helper.hpp") cpp_includes.cpp_relative_includes.add("rapid_helpers.hpp") diff --git a/xml_converter/src/attribute/bool.cpp b/xml_converter/src/attribute/bool.cpp index bafdf6e7..afdc2199 100644 --- a/xml_converter/src/attribute/bool.cpp +++ b/xml_converter/src/attribute/bool.cpp @@ -19,6 +19,7 @@ using namespace std; void xml_attribute_to_bool( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, bool* value, bool* is_set) { if (get_attribute_value(input) == "0" || get_attribute_value(input) == "false") { @@ -58,6 +59,7 @@ string bool_to_xml_attribute(const string& attribute_name, const bool* value) { void inverted_xml_attribute_to_bool( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, bool* value, bool* is_set) { if (get_attribute_value(input) == "0" || get_attribute_value(input) == "false") { diff --git a/xml_converter/src/attribute/bool.hpp b/xml_converter/src/attribute/bool.hpp index d7ce25d0..7650ff59 100644 --- a/xml_converter/src/attribute/bool.hpp +++ b/xml_converter/src/attribute/bool.hpp @@ -5,12 +5,14 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; void xml_attribute_to_bool( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, bool* value, bool* is_set); @@ -21,6 +23,7 @@ std::string bool_to_xml_attribute( void inverted_xml_attribute_to_bool( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, bool* value, bool* is_set); diff --git a/xml_converter/src/attribute/color.cpp b/xml_converter/src/attribute/color.cpp index be6f7c13..e566b984 100644 --- a/xml_converter/src/attribute/color.cpp +++ b/xml_converter/src/attribute/color.cpp @@ -51,6 +51,7 @@ int convert_color_channel_float_to_int(float input) { void xml_attribute_to_color( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, Color* value, bool* is_set) { Color color; diff --git a/xml_converter/src/attribute/color.hpp b/xml_converter/src/attribute/color.hpp index 0747ce1d..d12db8a5 100644 --- a/xml_converter/src/attribute/color.hpp +++ b/xml_converter/src/attribute/color.hpp @@ -5,8 +5,10 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; + namespace waypoint { class RGBAColor; } @@ -22,6 +24,7 @@ class Color { void xml_attribute_to_color( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, Color* value, bool* is_set); diff --git a/xml_converter/src/attribute/cull_chirality_gen.cpp b/xml_converter/src/attribute/cull_chirality_gen.cpp index 12bbd883..5c3dc038 100644 --- a/xml_converter/src/attribute/cull_chirality_gen.cpp +++ b/xml_converter/src/attribute/cull_chirality_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_cull_chirality( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, CullChirality* value, bool* is_set) { CullChirality cull_chirality; diff --git a/xml_converter/src/attribute/cull_chirality_gen.hpp b/xml_converter/src/attribute/cull_chirality_gen.hpp index 3f680d27..78173a5a 100644 --- a/xml_converter/src/attribute/cull_chirality_gen.hpp +++ b/xml_converter/src/attribute/cull_chirality_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + #include "waypoint.pb.h" class XMLError; @@ -17,6 +19,7 @@ enum CullChirality { void xml_attribute_to_cull_chirality( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, CullChirality* value, bool* is_set); diff --git a/xml_converter/src/attribute/euler_rotation_gen.cpp b/xml_converter/src/attribute/euler_rotation_gen.cpp index 5cc44878..4f4a1cb4 100644 --- a/xml_converter/src/attribute/euler_rotation_gen.cpp +++ b/xml_converter/src/attribute/euler_rotation_gen.cpp @@ -14,6 +14,7 @@ using namespace std; void xml_attribute_to_euler_rotation( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, EulerRotation* value, bool* is_set) { EulerRotation euler_rotation; diff --git a/xml_converter/src/attribute/euler_rotation_gen.hpp b/xml_converter/src/attribute/euler_rotation_gen.hpp index a2c0c392..89542d03 100644 --- a/xml_converter/src/attribute/euler_rotation_gen.hpp +++ b/xml_converter/src/attribute/euler_rotation_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class EulerRotation; @@ -23,6 +25,7 @@ class EulerRotation { void xml_attribute_to_euler_rotation( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, EulerRotation* value, bool* is_set); diff --git a/xml_converter/src/attribute/festival_filter_gen.cpp b/xml_converter/src/attribute/festival_filter_gen.cpp index d1dcd2e3..d80117c1 100644 --- a/xml_converter/src/attribute/festival_filter_gen.cpp +++ b/xml_converter/src/attribute/festival_filter_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_festival_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, FestivalFilter* value, bool* is_set) { FestivalFilter festival_filter; diff --git a/xml_converter/src/attribute/festival_filter_gen.hpp b/xml_converter/src/attribute/festival_filter_gen.hpp index 217d9164..87b125b6 100644 --- a/xml_converter/src/attribute/festival_filter_gen.hpp +++ b/xml_converter/src/attribute/festival_filter_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class FestivalFilter; @@ -27,6 +29,7 @@ class FestivalFilter { void xml_attribute_to_festival_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, FestivalFilter* value, bool* is_set); diff --git a/xml_converter/src/attribute/float.cpp b/xml_converter/src/attribute/float.cpp index 4508fc6c..65a4c5d2 100644 --- a/xml_converter/src/attribute/float.cpp +++ b/xml_converter/src/attribute/float.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_float( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, float* value, bool* is_set) { *value = std::stof(get_attribute_value(input)); diff --git a/xml_converter/src/attribute/float.hpp b/xml_converter/src/attribute/float.hpp index 27b7b7a2..b3da1bdf 100644 --- a/xml_converter/src/attribute/float.hpp +++ b/xml_converter/src/attribute/float.hpp @@ -5,12 +5,14 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; void xml_attribute_to_float( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, float* value, bool* is_set); diff --git a/xml_converter/src/attribute/image.cpp b/xml_converter/src/attribute/image.cpp index fd2688b5..4093f654 100644 --- a/xml_converter/src/attribute/image.cpp +++ b/xml_converter/src/attribute/image.cpp @@ -18,6 +18,7 @@ using namespace std; void xml_attribute_to_image( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, Image* value, bool* is_set) { value->path = get_attribute_value(input); diff --git a/xml_converter/src/attribute/image.hpp b/xml_converter/src/attribute/image.hpp index fb067108..6185e521 100644 --- a/xml_converter/src/attribute/image.hpp +++ b/xml_converter/src/attribute/image.hpp @@ -5,8 +5,10 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; + namespace waypoint { class TexturePath; } @@ -19,6 +21,7 @@ class Image { void xml_attribute_to_image( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, Image* value, bool* is_set); diff --git a/xml_converter/src/attribute/int.cpp b/xml_converter/src/attribute/int.cpp index fc095a50..dac2416e 100644 --- a/xml_converter/src/attribute/int.cpp +++ b/xml_converter/src/attribute/int.cpp @@ -19,6 +19,7 @@ using namespace std; void xml_attribute_to_int( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, int* value, bool* is_set) { try { diff --git a/xml_converter/src/attribute/int.hpp b/xml_converter/src/attribute/int.hpp index 13c1abda..cfc81162 100644 --- a/xml_converter/src/attribute/int.hpp +++ b/xml_converter/src/attribute/int.hpp @@ -5,12 +5,14 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; void xml_attribute_to_int( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, int* value, bool* is_set); diff --git a/xml_converter/src/attribute/map_type_filter_gen.cpp b/xml_converter/src/attribute/map_type_filter_gen.cpp index a091935e..f8e4d40f 100644 --- a/xml_converter/src/attribute/map_type_filter_gen.cpp +++ b/xml_converter/src/attribute/map_type_filter_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_map_type_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, MapTypeFilter* value, bool* is_set) { MapTypeFilter map_type_filter; diff --git a/xml_converter/src/attribute/map_type_filter_gen.hpp b/xml_converter/src/attribute/map_type_filter_gen.hpp index 13bd7dd4..4085f101 100644 --- a/xml_converter/src/attribute/map_type_filter_gen.hpp +++ b/xml_converter/src/attribute/map_type_filter_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class MapTypeFilter; @@ -44,6 +46,7 @@ class MapTypeFilter { void xml_attribute_to_map_type_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, MapTypeFilter* value, bool* is_set); diff --git a/xml_converter/src/attribute/marker_category.cpp b/xml_converter/src/attribute/marker_category.cpp index 3b70c60f..2756f42e 100644 --- a/xml_converter/src/attribute/marker_category.cpp +++ b/xml_converter/src/attribute/marker_category.cpp @@ -15,6 +15,7 @@ void xml_attribute_to_marker_category( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, MarkerCategory* value, bool* is_set) { value->category = get_attribute_value(input); diff --git a/xml_converter/src/attribute/marker_category.hpp b/xml_converter/src/attribute/marker_category.hpp index cf9903cc..fedc29b6 100644 --- a/xml_converter/src/attribute/marker_category.hpp +++ b/xml_converter/src/attribute/marker_category.hpp @@ -5,8 +5,10 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; + namespace waypoint { class Category; } @@ -19,6 +21,7 @@ class MarkerCategory { void xml_attribute_to_marker_category( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, MarkerCategory* value, bool* is_set); diff --git a/xml_converter/src/attribute/mount_filter_gen.cpp b/xml_converter/src/attribute/mount_filter_gen.cpp index 3e16ba05..56434514 100644 --- a/xml_converter/src/attribute/mount_filter_gen.cpp +++ b/xml_converter/src/attribute/mount_filter_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_mount_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, MountFilter* value, bool* is_set) { MountFilter mount_filter; diff --git a/xml_converter/src/attribute/mount_filter_gen.hpp b/xml_converter/src/attribute/mount_filter_gen.hpp index b9f5d9da..3960b9a8 100644 --- a/xml_converter/src/attribute/mount_filter_gen.hpp +++ b/xml_converter/src/attribute/mount_filter_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class MountFilter; @@ -30,6 +32,7 @@ class MountFilter { void xml_attribute_to_mount_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, MountFilter* value, bool* is_set); diff --git a/xml_converter/src/attribute/position_gen.cpp b/xml_converter/src/attribute/position_gen.cpp index 275bf9e0..4101a286 100644 --- a/xml_converter/src/attribute/position_gen.cpp +++ b/xml_converter/src/attribute/position_gen.cpp @@ -14,6 +14,7 @@ using namespace std; void xml_attribute_to_position( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, Position* value, bool* is_set) { Position position; diff --git a/xml_converter/src/attribute/position_gen.hpp b/xml_converter/src/attribute/position_gen.hpp index 9033cb32..e6bc2119 100644 --- a/xml_converter/src/attribute/position_gen.hpp +++ b/xml_converter/src/attribute/position_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class Position; @@ -23,6 +25,7 @@ class Position { void xml_attribute_to_position( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, Position* value, bool* is_set); diff --git a/xml_converter/src/attribute/profession_filter_gen.cpp b/xml_converter/src/attribute/profession_filter_gen.cpp index fd965add..68f4c2e8 100644 --- a/xml_converter/src/attribute/profession_filter_gen.cpp +++ b/xml_converter/src/attribute/profession_filter_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_profession_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, ProfessionFilter* value, bool* is_set) { ProfessionFilter profession_filter; diff --git a/xml_converter/src/attribute/profession_filter_gen.hpp b/xml_converter/src/attribute/profession_filter_gen.hpp index 3c11493c..b3a4f5f8 100644 --- a/xml_converter/src/attribute/profession_filter_gen.hpp +++ b/xml_converter/src/attribute/profession_filter_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class ProfessionFilter; @@ -29,6 +31,7 @@ class ProfessionFilter { void xml_attribute_to_profession_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, ProfessionFilter* value, bool* is_set); diff --git a/xml_converter/src/attribute/reset_behavior_gen.cpp b/xml_converter/src/attribute/reset_behavior_gen.cpp index 3fdbb3ec..ad5d1490 100644 --- a/xml_converter/src/attribute/reset_behavior_gen.cpp +++ b/xml_converter/src/attribute/reset_behavior_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_reset_behavior( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, ResetBehavior* value, bool* is_set) { ResetBehavior reset_behavior; diff --git a/xml_converter/src/attribute/reset_behavior_gen.hpp b/xml_converter/src/attribute/reset_behavior_gen.hpp index d9bfeede..ddf9d21d 100644 --- a/xml_converter/src/attribute/reset_behavior_gen.hpp +++ b/xml_converter/src/attribute/reset_behavior_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + #include "waypoint.pb.h" class XMLError; @@ -23,6 +25,7 @@ enum ResetBehavior { void xml_attribute_to_reset_behavior( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, ResetBehavior* value, bool* is_set); diff --git a/xml_converter/src/attribute/specialization_filter_gen.cpp b/xml_converter/src/attribute/specialization_filter_gen.cpp index 50ce0dcf..3820686e 100644 --- a/xml_converter/src/attribute/specialization_filter_gen.cpp +++ b/xml_converter/src/attribute/specialization_filter_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_specialization_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, SpecializationFilter* value, bool* is_set) { SpecializationFilter specialization_filter; diff --git a/xml_converter/src/attribute/specialization_filter_gen.hpp b/xml_converter/src/attribute/specialization_filter_gen.hpp index 586bff71..d14dfc15 100644 --- a/xml_converter/src/attribute/specialization_filter_gen.hpp +++ b/xml_converter/src/attribute/specialization_filter_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class SpecializationFilter; @@ -92,6 +94,7 @@ class SpecializationFilter { void xml_attribute_to_specialization_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, SpecializationFilter* value, bool* is_set); diff --git a/xml_converter/src/attribute/species_filter_gen.cpp b/xml_converter/src/attribute/species_filter_gen.cpp index e257418d..176afcbd 100644 --- a/xml_converter/src/attribute/species_filter_gen.cpp +++ b/xml_converter/src/attribute/species_filter_gen.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_species_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, SpeciesFilter* value, bool* is_set) { SpeciesFilter species_filter; diff --git a/xml_converter/src/attribute/species_filter_gen.hpp b/xml_converter/src/attribute/species_filter_gen.hpp index 51de4d7d..c572d008 100644 --- a/xml_converter/src/attribute/species_filter_gen.hpp +++ b/xml_converter/src/attribute/species_filter_gen.hpp @@ -5,6 +5,8 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" + class XMLError; namespace waypoint { class SpeciesFilter; @@ -25,6 +27,7 @@ class SpeciesFilter { void xml_attribute_to_species_filter( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, SpeciesFilter* value, bool* is_set); diff --git a/xml_converter/src/attribute/string.cpp b/xml_converter/src/attribute/string.cpp index b93272e5..5a76a1af 100644 --- a/xml_converter/src/attribute/string.cpp +++ b/xml_converter/src/attribute/string.cpp @@ -18,6 +18,7 @@ using namespace std; void xml_attribute_to_string( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, string* value, bool* is_set) { *value = get_attribute_value(input); diff --git a/xml_converter/src/attribute/string.hpp b/xml_converter/src/attribute/string.hpp index 97d139c1..843df591 100644 --- a/xml_converter/src/attribute/string.hpp +++ b/xml_converter/src/attribute/string.hpp @@ -5,12 +5,14 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; void xml_attribute_to_string( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, std::string* value, bool* is_set); diff --git a/xml_converter/src/attribute/trail_data.cpp b/xml_converter/src/attribute/trail_data.cpp index 9de6ac2d..6e552a93 100644 --- a/xml_converter/src/attribute/trail_data.cpp +++ b/xml_converter/src/attribute/trail_data.cpp @@ -10,6 +10,7 @@ #include "../rapid_helpers.hpp" #include "../rapidxml-1.13/rapidxml.hpp" #include "waypoint.pb.h" +#include "../packaging_xml.hpp" using namespace std; @@ -21,14 +22,14 @@ using namespace std; void xml_attribute_to_trail_data( rapidxml::xml_attribute<>* input, vector* errors, - string base_dir, + XMLParseState* state, TrailData* value, bool* is_set, int* map_id_value, bool* is_map_id_set) { TrailData trail_data; string trail_data_relative_path = get_attribute_value(input); - if (base_dir == "") { + if (state->xml_filedir == "") { throw "Error: Marker pack base directory is an empty string"; } if (trail_data_relative_path == "") { @@ -37,7 +38,7 @@ void xml_attribute_to_trail_data( } ifstream trail_data_file; - string trail_path = base_dir + "/" + trail_data_relative_path; + string trail_path = state->xml_filedir + "/" + trail_data_relative_path; trail_data_file.open(trail_path, ios::in | ios::binary); if (!trail_data_file.good()) { errors->push_back(new XMLAttributeValueError("No trail file found at " + trail_path, input)); diff --git a/xml_converter/src/attribute/trail_data.hpp b/xml_converter/src/attribute/trail_data.hpp index ee7c7f18..b36fedfe 100644 --- a/xml_converter/src/attribute/trail_data.hpp +++ b/xml_converter/src/attribute/trail_data.hpp @@ -5,8 +5,10 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; + namespace waypoint { class TrailData; } @@ -21,7 +23,7 @@ class TrailData { void xml_attribute_to_trail_data( rapidxml::xml_attribute<>* input, std::vector* errors, - std::string base_dir, + XMLParseState* state, TrailData* value, bool* is_set, int* map_id_value, diff --git a/xml_converter/src/attribute/unique_id.cpp b/xml_converter/src/attribute/unique_id.cpp index e78fcf5c..d2be3422 100644 --- a/xml_converter/src/attribute/unique_id.cpp +++ b/xml_converter/src/attribute/unique_id.cpp @@ -15,6 +15,7 @@ using namespace std; void xml_attribute_to_unique_id( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, UniqueId* value, bool* is_set) { string base64; diff --git a/xml_converter/src/attribute/unique_id.hpp b/xml_converter/src/attribute/unique_id.hpp index 310ce0e9..b49f00b3 100644 --- a/xml_converter/src/attribute/unique_id.hpp +++ b/xml_converter/src/attribute/unique_id.hpp @@ -6,8 +6,10 @@ #include #include "../rapidxml-1.13/rapidxml.hpp" +#include "../state_structs/xml_parse_state.hpp" class XMLError; + namespace waypoint { class GUID; } @@ -20,6 +22,7 @@ class UniqueId { void xml_attribute_to_unique_id( rapidxml::xml_attribute<>* input, std::vector* errors, + XMLParseState* state, UniqueId* value, bool* is_set); diff --git a/xml_converter/src/category_gen.cpp b/xml_converter/src/category_gen.cpp index c530a06e..0e58d28e 100644 --- a/xml_converter/src/category_gen.cpp +++ b/xml_converter/src/category_gen.cpp @@ -18,12 +18,12 @@ using namespace std; string Category::classname() { return "MarkerCategory"; } -void Category::init_from_xml(rapidxml::xml_node<>* node, vector* errors, string base_dir) { +void Category::init_from_xml(rapidxml::xml_node<>* node, vector* errors, XMLParseState* state) { for (rapidxml::xml_attribute<>* attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute()) { - bool is_icon_value = this->default_icon.init_xml_attribute(attribute, errors); - bool is_trail_value = this->default_trail.init_xml_attribute(attribute, errors); + bool is_icon_value = this->default_icon.init_xml_attribute(attribute, errors, state); + bool is_trail_value = this->default_trail.init_xml_attribute(attribute, errors, state); - if (init_xml_attribute(attribute, errors, base_dir)) { + if (init_xml_attribute(attribute, errors, state)) { } else if (is_icon_value || is_trail_value) { } @@ -33,23 +33,23 @@ void Category::init_from_xml(rapidxml::xml_node<>* node, vector* erro } } -bool Category::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, string base_dir) { +bool Category::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, XMLParseState* state) { string attributename; attributename = normalize(get_attribute_name(attribute)); if (attributename == "defaulttoggle") { - xml_attribute_to_bool(attribute, errors, &(this->default_visibility), &(this->default_visibility_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->default_visibility), &(this->default_visibility_is_set)); } else if (attributename == "displayname") { - xml_attribute_to_string(attribute, errors, &(this->display_name), &(this->display_name_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->display_name), &(this->display_name_is_set)); } else if (attributename == "isseparator") { - xml_attribute_to_bool(attribute, errors, &(this->is_separator), &(this->is_separator_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->is_separator), &(this->is_separator_is_set)); } else if (attributename == "name") { - xml_attribute_to_string(attribute, errors, &(this->name), &(this->name_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->name), &(this->name_is_set)); } else if (attributename == "tipdescription") { - xml_attribute_to_string(attribute, errors, &(this->tooltip_description), &(this->tooltip_description_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->tooltip_description), &(this->tooltip_description_is_set)); } else { return false; diff --git a/xml_converter/src/category_gen.hpp b/xml_converter/src/category_gen.hpp index 8f51ea43..0ca10d7a 100644 --- a/xml_converter/src/category_gen.hpp +++ b/xml_converter/src/category_gen.hpp @@ -8,6 +8,7 @@ #include "icon_gen.hpp" #include "parseable.hpp" #include "rapidxml-1.13/rapidxml.hpp" +#include "state_structs/xml_parse_state.hpp" #include "trail_gen.hpp" #include "waypoint.pb.h" @@ -29,10 +30,10 @@ class Category : public Parseable { Icon default_icon; Trail default_trail; - void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, std::string base_dir = ""); + void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, XMLParseState* state); virtual std::vector as_xml() const; virtual std::string classname(); - bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, std::string base_dir = ""); + bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, XMLParseState* state); waypoint::Category as_protobuf() const; void parse_protobuf(waypoint::Category proto_category); }; diff --git a/xml_converter/src/icon_gen.cpp b/xml_converter/src/icon_gen.cpp index 181c8636..459522d3 100644 --- a/xml_converter/src/icon_gen.cpp +++ b/xml_converter/src/icon_gen.cpp @@ -19,224 +19,224 @@ string Icon::classname() { return "POI"; } -bool Icon::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, string base_dir) { +bool Icon::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, XMLParseState* state) { string attributename; attributename = normalize(get_attribute_name(attribute)); if (attributename == "achievementbit") { - xml_attribute_to_int(attribute, errors, &(this->achievement_bitmask), &(this->achievement_bitmask_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->achievement_bitmask), &(this->achievement_bitmask_is_set)); } else if (attributename == "achievementid") { - xml_attribute_to_int(attribute, errors, &(this->achievement_id), &(this->achievement_id_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->achievement_id), &(this->achievement_id_is_set)); } else if (attributename == "autotrigger") { - xml_attribute_to_bool(attribute, errors, &(this->auto_trigger), &(this->auto_trigger_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->auto_trigger), &(this->auto_trigger_is_set)); } else if (attributename == "bouncedelay") { - xml_attribute_to_float(attribute, errors, &(this->bounce_delay), &(this->bounce_delay_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->bounce_delay), &(this->bounce_delay_is_set)); } else if (attributename == "bounceduration") { - xml_attribute_to_float(attribute, errors, &(this->bounce_duration), &(this->bounce_duration_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->bounce_duration), &(this->bounce_duration_is_set)); } else if (attributename == "bounceheight") { - xml_attribute_to_float(attribute, errors, &(this->bounce_height), &(this->bounce_height_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->bounce_height), &(this->bounce_height_is_set)); } else if (attributename == "type") { - xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->category), &(this->category_is_set)); } else if (attributename == "category") { - xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->category), &(this->category_is_set)); } else if (attributename == "color") { - xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); + xml_attribute_to_color(attribute, errors, state, &(this->color), &(this->color_is_set)); } else if (attributename == "bhcolor") { - xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); + xml_attribute_to_color(attribute, errors, state, &(this->color), &(this->color_is_set)); } else if (attributename == "alpha") { - xml_attribute_to_float(attribute, errors, &(this->color.alpha), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.alpha), &(this->color_is_set)); } else if (attributename == "blue") { - xml_attribute_to_float(attribute, errors, &(this->color.blue), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.blue), &(this->color_is_set)); } else if (attributename == "green") { - xml_attribute_to_float(attribute, errors, &(this->color.green), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.green), &(this->color_is_set)); } else if (attributename == "red") { - xml_attribute_to_float(attribute, errors, &(this->color.red), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.red), &(this->color_is_set)); } else if (attributename == "copy") { - xml_attribute_to_string(attribute, errors, &(this->copy_clipboard), &(this->copy_clipboard_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->copy_clipboard), &(this->copy_clipboard_is_set)); } else if (attributename == "copyclipboard") { - xml_attribute_to_string(attribute, errors, &(this->copy_clipboard), &(this->copy_clipboard_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->copy_clipboard), &(this->copy_clipboard_is_set)); } else if (attributename == "copymessage") { - xml_attribute_to_string(attribute, errors, &(this->copy_message), &(this->copy_message_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->copy_message), &(this->copy_message_is_set)); } else if (attributename == "cull") { - xml_attribute_to_cull_chirality(attribute, errors, &(this->cull_chirality), &(this->cull_chirality_is_set)); + xml_attribute_to_cull_chirality(attribute, errors, state, &(this->cull_chirality), &(this->cull_chirality_is_set)); } else if (attributename == "canfade") { - inverted_xml_attribute_to_bool(attribute, errors, &(this->disable_player_cutout), &(this->disable_player_cutout_is_set)); + inverted_xml_attribute_to_bool(attribute, errors, state, &(this->disable_player_cutout), &(this->disable_player_cutout_is_set)); } else if (attributename == "fadefar") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "distancefadeend") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "fadenear") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "distancefadestart") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "rotate") { - xml_attribute_to_euler_rotation(attribute, errors, &(this->euler_rotation), &(this->euler_rotation_is_set)); + xml_attribute_to_euler_rotation(attribute, errors, state, &(this->euler_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "rotatex") { - xml_attribute_to_float(attribute, errors, &(this->euler_rotation.x_rotation), &(this->euler_rotation_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->euler_rotation.x_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "rotatey") { - xml_attribute_to_float(attribute, errors, &(this->euler_rotation.y_rotation), &(this->euler_rotation_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->euler_rotation.y_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "rotatez") { - xml_attribute_to_float(attribute, errors, &(this->euler_rotation.z_rotation), &(this->euler_rotation_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->euler_rotation.z_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "festival") { - xml_attribute_to_festival_filter(attribute, errors, &(this->festival_filter), &(this->festival_filter_is_set)); + xml_attribute_to_festival_filter(attribute, errors, state, &(this->festival_filter), &(this->festival_filter_is_set)); } else if (attributename == "guid") { - xml_attribute_to_unique_id(attribute, errors, &(this->guid), &(this->guid_is_set)); + xml_attribute_to_unique_id(attribute, errors, state, &(this->guid), &(this->guid_is_set)); } else if (attributename == "hascountdown") { - xml_attribute_to_bool(attribute, errors, &(this->has_countdown), &(this->has_countdown_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->has_countdown), &(this->has_countdown_is_set)); } else if (attributename == "heightoffset") { - xml_attribute_to_float(attribute, errors, &(this->height_offset), &(this->height_offset_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->height_offset), &(this->height_offset_is_set)); } else if (attributename == "bhheightoffset") { - xml_attribute_to_float(attribute, errors, &(this->height_offset), &(this->height_offset_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->height_offset), &(this->height_offset_is_set)); } else if (attributename == "hide") { - xml_attribute_to_marker_category(attribute, errors, &(this->hide_category), &(this->hide_category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->hide_category), &(this->hide_category_is_set)); } else if (attributename == "iconfile") { - xml_attribute_to_image(attribute, errors, &(this->icon), &(this->icon_is_set)); + xml_attribute_to_image(attribute, errors, state, &(this->icon), &(this->icon_is_set)); } else if (attributename == "iconsize") { - xml_attribute_to_float(attribute, errors, &(this->icon_size), &(this->icon_size_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->icon_size), &(this->icon_size_is_set)); } else if (attributename == "info") { - xml_attribute_to_string(attribute, errors, &(this->info_message), &(this->info_message_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->info_message), &(this->info_message_is_set)); } else if (attributename == "invertbehavior") { - xml_attribute_to_bool(attribute, errors, &(this->invert_visibility), &(this->invert_visibility_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->invert_visibility), &(this->invert_visibility_is_set)); } else if (attributename == "mapdisplaysize") { - xml_attribute_to_int(attribute, errors, &(this->map_display_size), &(this->map_display_size_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->map_display_size), &(this->map_display_size_is_set)); } else if (attributename == "mapid") { - xml_attribute_to_int(attribute, errors, &(this->map_id), &(this->map_id_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->map_id), &(this->map_id_is_set)); } else if (attributename == "maptype") { - xml_attribute_to_map_type_filter(attribute, errors, &(this->map_type_filter), &(this->map_type_filter_is_set)); + xml_attribute_to_map_type_filter(attribute, errors, state, &(this->map_type_filter), &(this->map_type_filter_is_set)); } else if (attributename == "maxsize") { - xml_attribute_to_int(attribute, errors, &(this->maximum_size_on_screen), &(this->maximum_size_on_screen_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->maximum_size_on_screen), &(this->maximum_size_on_screen_is_set)); } else if (attributename == "minsize") { - xml_attribute_to_int(attribute, errors, &(this->minimum_size_on_screen), &(this->minimum_size_on_screen_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->minimum_size_on_screen), &(this->minimum_size_on_screen_is_set)); } else if (attributename == "mount") { - xml_attribute_to_mount_filter(attribute, errors, &(this->mount_filter), &(this->mount_filter_is_set)); + xml_attribute_to_mount_filter(attribute, errors, state, &(this->mount_filter), &(this->mount_filter_is_set)); } else if (attributename == "position") { - xml_attribute_to_position(attribute, errors, &(this->position), &(this->position_is_set)); + xml_attribute_to_position(attribute, errors, state, &(this->position), &(this->position_is_set)); } else if (attributename == "xpos") { - xml_attribute_to_float(attribute, errors, &(this->position.x_position), &(this->position_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->position.x_position), &(this->position_is_set)); } else if (attributename == "positionx") { - xml_attribute_to_float(attribute, errors, &(this->position.x_position), &(this->position_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->position.x_position), &(this->position_is_set)); } else if (attributename == "ypos") { - xml_attribute_to_float(attribute, errors, &(this->position.y_position), &(this->position_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->position.y_position), &(this->position_is_set)); } else if (attributename == "positiony") { - xml_attribute_to_float(attribute, errors, &(this->position.y_position), &(this->position_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->position.y_position), &(this->position_is_set)); } else if (attributename == "zpos") { - xml_attribute_to_float(attribute, errors, &(this->position.z_position), &(this->position_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->position.z_position), &(this->position_is_set)); } else if (attributename == "positionz") { - xml_attribute_to_float(attribute, errors, &(this->position.z_position), &(this->position_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->position.z_position), &(this->position_is_set)); } else if (attributename == "profession") { - xml_attribute_to_profession_filter(attribute, errors, &(this->profession_filter), &(this->profession_filter_is_set)); + xml_attribute_to_profession_filter(attribute, errors, state, &(this->profession_filter), &(this->profession_filter_is_set)); } else if (attributename == "ingamevisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "bhingamevisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "mapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "bhmapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "minimapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "bhminimapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "behavior") { - xml_attribute_to_reset_behavior(attribute, errors, &(this->reset_behavior), &(this->reset_behavior_is_set)); + xml_attribute_to_reset_behavior(attribute, errors, state, &(this->reset_behavior), &(this->reset_behavior_is_set)); } else if (attributename == "resetlength") { - xml_attribute_to_float(attribute, errors, &(this->reset_length), &(this->reset_length_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->reset_length), &(this->reset_length_is_set)); } else if (attributename == "scaleonmapwithzoom") { - xml_attribute_to_bool(attribute, errors, &(this->scale_on_map_with_zoom), &(this->scale_on_map_with_zoom_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->scale_on_map_with_zoom), &(this->scale_on_map_with_zoom_is_set)); } else if (attributename == "schedule") { - xml_attribute_to_string(attribute, errors, &(this->schedule), &(this->schedule_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->schedule), &(this->schedule_is_set)); } else if (attributename == "scheduleduration") { - xml_attribute_to_float(attribute, errors, &(this->schedule_duration), &(this->schedule_duration_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->schedule_duration), &(this->schedule_duration_is_set)); } else if (attributename == "show") { - xml_attribute_to_marker_category(attribute, errors, &(this->show_category), &(this->show_category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->show_category), &(this->show_category_is_set)); } else if (attributename == "specialization") { - xml_attribute_to_specialization_filter(attribute, errors, &(this->specialization_filter), &(this->specialization_filter_is_set)); + xml_attribute_to_specialization_filter(attribute, errors, state, &(this->specialization_filter), &(this->specialization_filter_is_set)); } else if (attributename == "race") { - xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); + xml_attribute_to_species_filter(attribute, errors, state, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "species") { - xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); + xml_attribute_to_species_filter(attribute, errors, state, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "toggle") { - xml_attribute_to_marker_category(attribute, errors, &(this->toggle_category), &(this->toggle_category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->toggle_category), &(this->toggle_category_is_set)); } else if (attributename == "togglecategory") { - xml_attribute_to_marker_category(attribute, errors, &(this->toggle_category), &(this->toggle_category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->toggle_category), &(this->toggle_category_is_set)); } else if (attributename == "tipdescription") { - xml_attribute_to_string(attribute, errors, &(this->tooltip_description), &(this->tooltip_description_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->tooltip_description), &(this->tooltip_description_is_set)); } else if (attributename == "tipname") { - xml_attribute_to_string(attribute, errors, &(this->tooltip_name), &(this->tooltip_name_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->tooltip_name), &(this->tooltip_name_is_set)); } else if (attributename == "triggerrange") { - xml_attribute_to_float(attribute, errors, &(this->trigger_range), &(this->trigger_range_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->trigger_range), &(this->trigger_range_is_set)); } else if (attributename == "inforange") { - xml_attribute_to_float(attribute, errors, &(this->trigger_range), &(this->trigger_range_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->trigger_range), &(this->trigger_range_is_set)); } else { return false; diff --git a/xml_converter/src/icon_gen.hpp b/xml_converter/src/icon_gen.hpp index cbf4d271..406b8029 100644 --- a/xml_converter/src/icon_gen.hpp +++ b/xml_converter/src/icon_gen.hpp @@ -20,6 +20,7 @@ #include "attribute/unique_id.hpp" #include "parseable.hpp" #include "rapidxml-1.13/rapidxml.hpp" +#include "state_structs/xml_parse_state.hpp" #include "waypoint.pb.h" class XMLError; @@ -122,7 +123,7 @@ class Icon : public Parseable { bool trigger_range_is_set = false; virtual std::vector as_xml() const; virtual std::string classname(); - bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, std::string base_dir = ""); + bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, XMLParseState* state); waypoint::Icon as_protobuf() const; void parse_protobuf(waypoint::Icon proto_icon); bool validate_attributes_of_type_marker_category(); diff --git a/xml_converter/src/packaging_xml.cpp b/xml_converter/src/packaging_xml.cpp index 3101a84d..12edad84 100644 --- a/xml_converter/src/packaging_xml.cpp +++ b/xml_converter/src/packaging_xml.cpp @@ -7,20 +7,26 @@ #include "rapidxml-1.13/rapidxml_utils.hpp" #include "string_helper.hpp" + using namespace std; //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// SERIALIZE /////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -void parse_marker_categories(rapidxml::xml_node<>* node, map* marker_categories, vector* errors, int depth = 0) { +void parse_marker_categories(rapidxml::xml_node<>* node, map* marker_categories, vector* errors, string base_dir, int depth = 0) { if (get_node_name(node) == "MarkerCategory") { string name = lowercase(find_attribute_value(node, "name")); + XMLParseState state = { + base_dir, + marker_categories, + }; + Category* this_category = &(*marker_categories)[name]; - this_category->init_from_xml(node, errors); + this_category->init_from_xml(node, errors, &state); for (rapidxml::xml_node<>* child_node = node->first_node(); child_node; child_node = child_node->next_sibling()) { - parse_marker_categories(child_node, &(this_category->children), errors, depth + 1); + parse_marker_categories(child_node, &(this_category->children), errors, base_dir, depth + 1); } } else { @@ -74,6 +80,11 @@ Category* get_category(rapidxml::xml_node<>* node, map* marker vector parse_pois(rapidxml::xml_node<>* root_node, map* marker_categories, vector* errors, string base_dir) { vector markers; + XMLParseState state = { + base_dir, + marker_categories, + }; + for (rapidxml::xml_node<>* node = root_node->first_node(); node; node = node->next_sibling()) { if (get_node_name(node) == "POI") { Category* default_category = get_category(node, marker_categories, errors); @@ -84,7 +95,7 @@ vector parse_pois(rapidxml::xml_node<>* root_node, mapdefault_icon; } - icon->init_from_xml(node, errors); + icon->init_from_xml(node, errors, &state); markers.push_back(icon); } else if (get_node_name(node) == "Trail") { @@ -96,7 +107,7 @@ vector parse_pois(rapidxml::xml_node<>* root_node, mapdefault_trail; } - trail->init_from_xml(node, errors, base_dir); + trail->init_from_xml(node, errors, &state); markers.push_back(trail); } else { @@ -131,7 +142,7 @@ void parse_xml_file(string xml_filepath, map* marker_categorie for (rapidxml::xml_node<>* node = root_node->first_node(); node; node = node->next_sibling()) { if (get_node_name(node) == "MarkerCategory") { - parse_marker_categories(node, marker_categories, &errors); + parse_marker_categories(node, marker_categories, &errors, base_dir); } else if (get_node_name(node) == "POIs") { vector temp_vector = parse_pois(node, marker_categories, &errors, base_dir); diff --git a/xml_converter/src/packaging_xml.hpp b/xml_converter/src/packaging_xml.hpp index 9ffa1282..8e45fc8e 100644 --- a/xml_converter/src/packaging_xml.hpp +++ b/xml_converter/src/packaging_xml.hpp @@ -8,6 +8,7 @@ #include "parseable.hpp" #include "rapidxml-1.13/rapidxml.hpp" #include "rapidxml-1.13/rapidxml_utils.hpp" +#include "state_structs/xml_parse_state.hpp" void parse_xml_file( std::string xml_filepath, diff --git a/xml_converter/src/parseable.cpp b/xml_converter/src/parseable.cpp index bd5bee47..137fb6f2 100644 --- a/xml_converter/src/parseable.cpp +++ b/xml_converter/src/parseable.cpp @@ -11,9 +11,9 @@ std::string Parseable::classname() { return "Parseable"; } -void Parseable::init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, std::string base_dir) { +void Parseable::init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, XMLParseState* state) { for (rapidxml::xml_attribute<>* attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute()) { - if (init_xml_attribute(attribute, errors, base_dir)) { + if (init_xml_attribute(attribute, errors, state)) { } else { errors->push_back(new XMLAttributeNameError("Unknown " + this->classname() + " attribute ", attribute)); @@ -28,7 +28,7 @@ void Parseable::init_from_xml(rapidxml::xml_node<>* node, std::vector // all of the other parsible classes. So just return false right away without // doing anything. //////////////////////////////////////////////////////////////////////////////// -bool Parseable::init_xml_attribute(rapidxml::xml_attribute<>*, std::vector*, std::string) { +bool Parseable::init_xml_attribute(rapidxml::xml_attribute<>*, std::vector*, XMLParseState*) { return false; } diff --git a/xml_converter/src/parseable.hpp b/xml_converter/src/parseable.hpp index 455886e6..f1bbc30c 100644 --- a/xml_converter/src/parseable.hpp +++ b/xml_converter/src/parseable.hpp @@ -4,6 +4,8 @@ #include #include "rapidxml-1.13/rapidxml.hpp" +#include "state_structs/xml_parse_state.hpp" + class XMLError; class Parseable { @@ -12,10 +14,10 @@ class Parseable { virtual std::string classname(); // A default parser function to parse an entire XML node into the class. - void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, std::string base_dir = ""); + void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, XMLParseState* state); // A default parser function to parse a single XML attribute into the class. - virtual bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, std::string base_dir = ""); + virtual bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, XMLParseState*); virtual std::vector as_xml() const; }; diff --git a/xml_converter/src/state_structs/xml_parse_state.hpp b/xml_converter/src/state_structs/xml_parse_state.hpp new file mode 100644 index 00000000..61d6b745 --- /dev/null +++ b/xml_converter/src/state_structs/xml_parse_state.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include +#include + +class Category; + +struct XMLParseState { + std::string xml_filedir; + std::map* marker_categories; +}; diff --git a/xml_converter/src/trail_gen.cpp b/xml_converter/src/trail_gen.cpp index dacfb07e..07d263cf 100644 --- a/xml_converter/src/trail_gen.cpp +++ b/xml_converter/src/trail_gen.cpp @@ -19,128 +19,128 @@ string Trail::classname() { return "Trail"; } -bool Trail::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, string base_dir) { +bool Trail::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vector* errors, XMLParseState* state) { string attributename; attributename = normalize(get_attribute_name(attribute)); if (attributename == "achievementbit") { - xml_attribute_to_int(attribute, errors, &(this->achievement_bitmask), &(this->achievement_bitmask_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->achievement_bitmask), &(this->achievement_bitmask_is_set)); } else if (attributename == "achievementid") { - xml_attribute_to_int(attribute, errors, &(this->achievement_id), &(this->achievement_id_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->achievement_id), &(this->achievement_id_is_set)); } else if (attributename == "animspeed") { - xml_attribute_to_float(attribute, errors, &(this->animation_speed), &(this->animation_speed_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->animation_speed), &(this->animation_speed_is_set)); } else if (attributename == "animationspeed") { - xml_attribute_to_float(attribute, errors, &(this->animation_speed), &(this->animation_speed_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->animation_speed), &(this->animation_speed_is_set)); } else if (attributename == "type") { - xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->category), &(this->category_is_set)); } else if (attributename == "category") { - xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); + xml_attribute_to_marker_category(attribute, errors, state, &(this->category), &(this->category_is_set)); } else if (attributename == "color") { - xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); + xml_attribute_to_color(attribute, errors, state, &(this->color), &(this->color_is_set)); } else if (attributename == "bhcolor") { - xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); + xml_attribute_to_color(attribute, errors, state, &(this->color), &(this->color_is_set)); } else if (attributename == "alpha") { - xml_attribute_to_float(attribute, errors, &(this->color.alpha), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.alpha), &(this->color_is_set)); } else if (attributename == "blue") { - xml_attribute_to_float(attribute, errors, &(this->color.blue), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.blue), &(this->color_is_set)); } else if (attributename == "green") { - xml_attribute_to_float(attribute, errors, &(this->color.green), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.green), &(this->color_is_set)); } else if (attributename == "red") { - xml_attribute_to_float(attribute, errors, &(this->color.red), &(this->color_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->color.red), &(this->color_is_set)); } else if (attributename == "cull") { - xml_attribute_to_cull_chirality(attribute, errors, &(this->cull_chirality), &(this->cull_chirality_is_set)); + xml_attribute_to_cull_chirality(attribute, errors, state, &(this->cull_chirality), &(this->cull_chirality_is_set)); } else if (attributename == "canfade") { - inverted_xml_attribute_to_bool(attribute, errors, &(this->disable_player_cutout), &(this->disable_player_cutout_is_set)); + inverted_xml_attribute_to_bool(attribute, errors, state, &(this->disable_player_cutout), &(this->disable_player_cutout_is_set)); } else if (attributename == "fadefar") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "distancefadeend") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "fadenear") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "distancefadestart") { - xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "festival") { - xml_attribute_to_festival_filter(attribute, errors, &(this->festival_filter), &(this->festival_filter_is_set)); + xml_attribute_to_festival_filter(attribute, errors, state, &(this->festival_filter), &(this->festival_filter_is_set)); } else if (attributename == "guid") { - xml_attribute_to_unique_id(attribute, errors, &(this->guid), &(this->guid_is_set)); + xml_attribute_to_unique_id(attribute, errors, state, &(this->guid), &(this->guid_is_set)); } else if (attributename == "iswall") { - xml_attribute_to_bool(attribute, errors, &(this->is_wall), &(this->is_wall_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->is_wall), &(this->is_wall_is_set)); } else if (attributename == "mapdisplaysize") { - xml_attribute_to_int(attribute, errors, &(this->map_display_size), &(this->map_display_size_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->map_display_size), &(this->map_display_size_is_set)); } else if (attributename == "mapid") { - xml_attribute_to_int(attribute, errors, &(this->map_id), &(this->map_id_is_set)); + xml_attribute_to_int(attribute, errors, state, &(this->map_id), &(this->map_id_is_set)); } else if (attributename == "maptype") { - xml_attribute_to_map_type_filter(attribute, errors, &(this->map_type_filter), &(this->map_type_filter_is_set)); + xml_attribute_to_map_type_filter(attribute, errors, state, &(this->map_type_filter), &(this->map_type_filter_is_set)); } else if (attributename == "mount") { - xml_attribute_to_mount_filter(attribute, errors, &(this->mount_filter), &(this->mount_filter_is_set)); + xml_attribute_to_mount_filter(attribute, errors, state, &(this->mount_filter), &(this->mount_filter_is_set)); } else if (attributename == "profession") { - xml_attribute_to_profession_filter(attribute, errors, &(this->profession_filter), &(this->profession_filter_is_set)); + xml_attribute_to_profession_filter(attribute, errors, state, &(this->profession_filter), &(this->profession_filter_is_set)); } else if (attributename == "ingamevisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "bhingamevisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "mapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "bhmapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "minimapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "bhminimapvisibility") { - xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); + xml_attribute_to_bool(attribute, errors, state, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "schedule") { - xml_attribute_to_string(attribute, errors, &(this->schedule), &(this->schedule_is_set)); + xml_attribute_to_string(attribute, errors, state, &(this->schedule), &(this->schedule_is_set)); } else if (attributename == "scheduleduration") { - xml_attribute_to_float(attribute, errors, &(this->schedule_duration), &(this->schedule_duration_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->schedule_duration), &(this->schedule_duration_is_set)); } else if (attributename == "specialization") { - xml_attribute_to_specialization_filter(attribute, errors, &(this->specialization_filter), &(this->specialization_filter_is_set)); + xml_attribute_to_specialization_filter(attribute, errors, state, &(this->specialization_filter), &(this->specialization_filter_is_set)); } else if (attributename == "race") { - xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); + xml_attribute_to_species_filter(attribute, errors, state, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "species") { - xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); + xml_attribute_to_species_filter(attribute, errors, state, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "texture") { - xml_attribute_to_image(attribute, errors, &(this->texture), &(this->texture_is_set)); + xml_attribute_to_image(attribute, errors, state, &(this->texture), &(this->texture_is_set)); } else if (attributename == "traildata") { - xml_attribute_to_trail_data(attribute, errors, base_dir, &(this->trail_data), &(this->trail_data_is_set), &(this->map_id), &(this->map_id_is_set)); + xml_attribute_to_trail_data(attribute, errors, state, &(this->trail_data), &(this->trail_data_is_set), &(this->map_id), &(this->map_id_is_set)); } else if (attributename == "trailscale") { - xml_attribute_to_float(attribute, errors, &(this->trail_scale), &(this->trail_scale_is_set)); + xml_attribute_to_float(attribute, errors, state, &(this->trail_scale), &(this->trail_scale_is_set)); } else { return false; diff --git a/xml_converter/src/trail_gen.hpp b/xml_converter/src/trail_gen.hpp index a020a2a3..22c373e2 100644 --- a/xml_converter/src/trail_gen.hpp +++ b/xml_converter/src/trail_gen.hpp @@ -18,6 +18,7 @@ #include "attribute/unique_id.hpp" #include "parseable.hpp" #include "rapidxml-1.13/rapidxml.hpp" +#include "state_structs/xml_parse_state.hpp" #include "waypoint.pb.h" class XMLError; @@ -80,7 +81,7 @@ class Trail : public Parseable { bool trail_scale_is_set = false; virtual std::vector as_xml() const; virtual std::string classname(); - bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, std::string base_dir = ""); + bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector* errors, XMLParseState* state); waypoint::Trail as_protobuf() const; void parse_protobuf(waypoint::Trail proto_trail); bool validate_attributes_of_type_marker_category();