From 2f66447d7dfa1ad9cbd035bc06f1ff25d4e16493 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Mon, 30 Oct 2023 02:13:40 -0500 Subject: [PATCH] migrating xml attribute reading code --- .../cpp_templates/attribute_template.hpp | 6 +- .../cpp_templates/class_template.cpp | 4 +- .../cpp_templates/compoundvalue.cpp | 9 +- .../generators/cpp_templates/enum.cpp | 9 +- .../cpp_templates/multiflagvalue.cpp | 9 +- xml_converter/src/attribute/bool.cpp | 13 +- xml_converter/src/attribute/bool.hpp | 6 +- xml_converter/src/attribute/color.cpp | 9 +- xml_converter/src/attribute/color.hpp | 6 +- .../src/attribute/cull_chirality_gen.cpp | 9 +- .../src/attribute/cull_chirality_gen.hpp | 6 +- .../src/attribute/euler_rotation_gen.cpp | 9 +- .../src/attribute/euler_rotation_gen.hpp | 6 +- .../src/attribute/festival_filter_gen.cpp | 9 +- .../src/attribute/festival_filter_gen.hpp | 6 +- xml_converter/src/attribute/float.cpp | 9 +- xml_converter/src/attribute/float.hpp | 6 +- xml_converter/src/attribute/image.cpp | 11 +- xml_converter/src/attribute/image.hpp | 6 +- xml_converter/src/attribute/int.cpp | 12 +- xml_converter/src/attribute/int.hpp | 6 +- .../src/attribute/map_type_filter_gen.cpp | 9 +- .../src/attribute/map_type_filter_gen.hpp | 6 +- .../src/attribute/marker_category.cpp | 11 +- .../src/attribute/marker_category.hpp | 6 +- .../src/attribute/mount_filter_gen.cpp | 9 +- .../src/attribute/mount_filter_gen.hpp | 6 +- xml_converter/src/attribute/position_gen.cpp | 9 +- xml_converter/src/attribute/position_gen.hpp | 6 +- .../src/attribute/profession_filter_gen.cpp | 9 +- .../src/attribute/profession_filter_gen.hpp | 6 +- .../src/attribute/reset_behavior_gen.cpp | 9 +- .../src/attribute/reset_behavior_gen.hpp | 6 +- .../attribute/specialization_filter_gen.cpp | 9 +- .../attribute/specialization_filter_gen.hpp | 6 +- .../src/attribute/species_filter_gen.cpp | 9 +- .../src/attribute/species_filter_gen.hpp | 6 +- xml_converter/src/attribute/string.cpp | 11 +- xml_converter/src/attribute/string.hpp | 6 +- xml_converter/src/attribute/trail_data.cpp | 16 +- xml_converter/src/attribute/trail_data.hpp | 7 +- xml_converter/src/attribute/unique_id.cpp | 11 +- xml_converter/src/attribute/unique_id.hpp | 6 +- xml_converter/src/category_gen.cpp | 15 +- xml_converter/src/icon_gen.cpp | 216 ++++++------------ xml_converter/src/trail_gen.cpp | 121 ++++------ 46 files changed, 383 insertions(+), 314 deletions(-) diff --git a/xml_converter/generators/cpp_templates/attribute_template.hpp b/xml_converter/generators/cpp_templates/attribute_template.hpp index 78c32ad1..33d219d7 100644 --- a/xml_converter/generators/cpp_templates/attribute_template.hpp +++ b/xml_converter/generators/cpp_templates/attribute_template.hpp @@ -31,7 +31,11 @@ } }; {% endif %} -{{class_name}} parse_{{attribute_name}}(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_{{attribute_name}}( + rapidxml::xml_attribute<>* input, + std::vector* errors, + {{class_name}}* value, + bool* is_set); std::string {{attribute_name}}_to_xml_attribute(const std::string& attribute_name, const {{class_name}}* value); {% if type == "Enum":%} waypoint::{{class_name}} to_proto_{{attribute_name}}({{class_name}} attribute_value); diff --git a/xml_converter/generators/cpp_templates/class_template.cpp b/xml_converter/generators/cpp_templates/class_template.cpp index bef2821a..2c3dda84 100644 --- a/xml_converter/generators/cpp_templates/class_template.cpp +++ b/xml_converter/generators/cpp_templates/class_template.cpp @@ -40,9 +40,9 @@ bool {{cpp_class}}::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vec {% 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}}") { - this->{{attribute_variable.attribute_name}} = parse_{{attribute_variable.class_name}}({{", ".join(attribute_variable.args)}}); - this->{{attribute_variable.attribute_flag_name}} = true; + xml_attribute_to_{{attribute_variable.class_name}}({{", ".join(attribute_variable.args)}}, &(this->{{attribute_variable.attribute_name}}), &(this->{{attribute_variable.attribute_flag_name}})); {% for side_effect in attribute_variable.side_effects %} + // TOOD: this side effects should be passed into the parse function this->{{side_effect}} = this->{{attribute_variable.class_name}}.side_effect_{{side_effect}}; this->{{side_effect}}_is_set = true; {% endfor %} diff --git a/xml_converter/generators/cpp_templates/compoundvalue.cpp b/xml_converter/generators/cpp_templates/compoundvalue.cpp index e69c54dd..aef45764 100644 --- a/xml_converter/generators/cpp_templates/compoundvalue.cpp +++ b/xml_converter/generators/cpp_templates/compoundvalue.cpp @@ -11,7 +11,11 @@ using namespace std; -{{class_name}} parse_{{attribute_name}}(rapidxml::xml_attribute<>* input, vector*) { +void xml_attribute_to_{{attribute_name}}( + rapidxml::xml_attribute<>* input, + std::vector* errors, + {{class_name}}* value, + bool* is_set) { {{class_name}} {{attribute_name}}; vector compound_values; string attributename; @@ -25,7 +29,8 @@ using namespace std; {{attribute_name}}.{{attribute_variable.attribute_name}} = std::stof(compound_values[{{n}}]); {% endfor %} } - return {{attribute_name}}; + *value = {{attribute_name}}; + *is_set = true; } {% if xml_bundled_components != [] %} string {{attribute_name}}_to_xml_attribute(const std::string& attribute_name, const {{class_name}}* value) { diff --git a/xml_converter/generators/cpp_templates/enum.cpp b/xml_converter/generators/cpp_templates/enum.cpp index 83de9dd0..c094494f 100644 --- a/xml_converter/generators/cpp_templates/enum.cpp +++ b/xml_converter/generators/cpp_templates/enum.cpp @@ -12,7 +12,11 @@ using namespace std; -{{class_name}} parse_{{attribute_name}}(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_{{attribute_name}}( + rapidxml::xml_attribute<>* input, + std::vector* errors, + {{class_name}}* value, + bool* is_set) { {{class_name}} {{attribute_name}}; string normalized_value = normalize(get_attribute_value(input)); {% for n, attribute_variable in enumerate(attribute_variables) %} @@ -32,7 +36,8 @@ using namespace std; errors->push_back(new XMLAttributeValueError("Found an invalid value that was not in the Enum {{class_name}}", input)); {{attribute_name}} = {{class_name}}::{{attribute_variables[0].attribute_name}}; } - return {{attribute_name}}; + *value = {{attribute_name}}; + *is_set = true; } string {{attribute_name}}_to_xml_attribute(const std::string& attribute_name, const {{class_name}}* value) { diff --git a/xml_converter/generators/cpp_templates/multiflagvalue.cpp b/xml_converter/generators/cpp_templates/multiflagvalue.cpp index ad2303b1..7f8593d4 100644 --- a/xml_converter/generators/cpp_templates/multiflagvalue.cpp +++ b/xml_converter/generators/cpp_templates/multiflagvalue.cpp @@ -12,7 +12,11 @@ using namespace std; -{{class_name}} parse_{{attribute_name}}(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_{{attribute_name}}( + rapidxml::xml_attribute<>* input, + std::vector* errors, + {{class_name}}* value, + bool* is_set) { {{class_name}} {{attribute_name}}; vector flag_values; flag_values = split(get_attribute_value(input), ","); @@ -40,7 +44,8 @@ using namespace std; continue; } } - return {{attribute_name}}; + *value = {{attribute_name}}; + *is_set = true; } string {{attribute_name}}_to_xml_attribute(const std::string& attribute_name, const {{class_name}}* value) { diff --git a/xml_converter/src/attribute/bool.cpp b/xml_converter/src/attribute/bool.cpp index ea9a4a7c..1e63b310 100644 --- a/xml_converter/src/attribute/bool.cpp +++ b/xml_converter/src/attribute/bool.cpp @@ -16,16 +16,21 @@ using namespace std; // evaluated as `true`. 'false' or '0' are evaluated as `false`. Everything is // is also evaluated as false but appends an error to the errors vector. //////////////////////////////////////////////////////////////////////////////// -bool parse_bool(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_bool( + rapidxml::xml_attribute<>* input, + std::vector* errors, + bool* value, + bool* is_set) { if (get_attribute_value(input) == "0" || get_attribute_value(input) == "false") { - return false; + *value = false; + *is_set = true; } else if (get_attribute_value(input) == "1" || get_attribute_value(input) == "true") { - return true; + *value = true; + *is_set = true; } else { errors->push_back(new XMLAttributeValueError("Found a boolean value that was not a '1', '0', 'true', or 'false'", input)); - return false; } } diff --git a/xml_converter/src/attribute/bool.hpp b/xml_converter/src/attribute/bool.hpp index 701316d9..68733216 100644 --- a/xml_converter/src/attribute/bool.hpp +++ b/xml_converter/src/attribute/bool.hpp @@ -7,7 +7,11 @@ class XMLError; -bool parse_bool(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_bool( + rapidxml::xml_attribute<>* input, + std::vector* errors, + bool* value, + bool* is_set); std::string bool_to_xml_attribute(const std::string& attribute_name, const bool* value); diff --git a/xml_converter/src/attribute/color.cpp b/xml_converter/src/attribute/color.cpp index 18d7be57..c8d04e84 100644 --- a/xml_converter/src/attribute/color.cpp +++ b/xml_converter/src/attribute/color.cpp @@ -48,7 +48,11 @@ int convert_color_channel_float_to_int(float input) { // // Parses a Color from the value of a rapidxml::xml_attribute. //////////////////////////////////////////////////////////////////////////////// -Color parse_color(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_color( + rapidxml::xml_attribute<>* input, + std::vector* errors, + Color* value, + bool* is_set) { Color color; std::string input_string = get_attribute_value(input); std::string hex_string; @@ -82,7 +86,8 @@ Color parse_color(rapidxml::xml_attribute<>* input, vector* errors) { else { errors->push_back(new XMLAttributeValueError("Found a color value not in hex format", input)); } - return color; + *value = color; + *is_set = true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/xml_converter/src/attribute/color.hpp b/xml_converter/src/attribute/color.hpp index b92ff3c4..7f5df754 100644 --- a/xml_converter/src/attribute/color.hpp +++ b/xml_converter/src/attribute/color.hpp @@ -18,7 +18,11 @@ class Color { float alpha; }; -Color parse_color(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_color( + rapidxml::xml_attribute<>* input, + std::vector* errors, + Color* value, + bool* is_set); std::string color_to_xml_attribute(const std::string& attribute_name, const Color* value); diff --git a/xml_converter/src/attribute/cull_chirality_gen.cpp b/xml_converter/src/attribute/cull_chirality_gen.cpp index 1cbc5538..cc180b87 100644 --- a/xml_converter/src/attribute/cull_chirality_gen.cpp +++ b/xml_converter/src/attribute/cull_chirality_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -CullChirality parse_cull_chirality(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_cull_chirality( + rapidxml::xml_attribute<>* input, + std::vector* errors, + CullChirality* value, + bool* is_set) { CullChirality cull_chirality; string normalized_value = normalize(get_attribute_value(input)); if (normalized_value == "none") { @@ -28,7 +32,8 @@ CullChirality parse_cull_chirality(rapidxml::xml_attribute<>* input, vectorpush_back(new XMLAttributeValueError("Found an invalid value that was not in the Enum CullChirality", input)); cull_chirality = CullChirality::none; } - return cull_chirality; + *value = cull_chirality; + *is_set = true; } string cull_chirality_to_xml_attribute(const std::string& attribute_name, const CullChirality* value) { diff --git a/xml_converter/src/attribute/cull_chirality_gen.hpp b/xml_converter/src/attribute/cull_chirality_gen.hpp index d47dbfc1..c03ef38b 100644 --- a/xml_converter/src/attribute/cull_chirality_gen.hpp +++ b/xml_converter/src/attribute/cull_chirality_gen.hpp @@ -13,7 +13,11 @@ enum CullChirality { counter_clockwise, none, }; -CullChirality parse_cull_chirality(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_cull_chirality( + rapidxml::xml_attribute<>* input, + std::vector* errors, + CullChirality* value, + bool* is_set); std::string cull_chirality_to_xml_attribute(const std::string& attribute_name, const CullChirality* value); waypoint::CullChirality to_proto_cull_chirality(CullChirality attribute_value); CullChirality from_proto_cull_chirality(waypoint::CullChirality proto_cull_chirality); diff --git a/xml_converter/src/attribute/euler_rotation_gen.cpp b/xml_converter/src/attribute/euler_rotation_gen.cpp index 8b9a353d..63e587f7 100644 --- a/xml_converter/src/attribute/euler_rotation_gen.cpp +++ b/xml_converter/src/attribute/euler_rotation_gen.cpp @@ -11,7 +11,11 @@ using namespace std; -EulerRotation parse_euler_rotation(rapidxml::xml_attribute<>* input, vector*) { +void xml_attribute_to_euler_rotation( + rapidxml::xml_attribute<>* input, + std::vector* errors, + EulerRotation* value, + bool* is_set) { EulerRotation euler_rotation; vector compound_values; string attributename; @@ -25,7 +29,8 @@ EulerRotation parse_euler_rotation(rapidxml::xml_attribute<>* input, vector* input, std::vector* errors); +void xml_attribute_to_euler_rotation( + rapidxml::xml_attribute<>* input, + std::vector* errors, + EulerRotation* value, + bool* is_set); std::string euler_rotation_to_xml_attribute(const std::string& attribute_name, const EulerRotation* value); waypoint::EulerRotation* to_proto_euler_rotation(EulerRotation attribute_value); EulerRotation from_proto_euler_rotation(waypoint::EulerRotation proto_euler_rotation); diff --git a/xml_converter/src/attribute/festival_filter_gen.cpp b/xml_converter/src/attribute/festival_filter_gen.cpp index 29b15014..747ade9e 100644 --- a/xml_converter/src/attribute/festival_filter_gen.cpp +++ b/xml_converter/src/attribute/festival_filter_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -FestivalFilter parse_festival_filter(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_festival_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + FestivalFilter* value, + bool* is_set) { FestivalFilter festival_filter; vector flag_values; flag_values = split(get_attribute_value(input), ","); @@ -55,7 +59,8 @@ FestivalFilter parse_festival_filter(rapidxml::xml_attribute<>* input, vector* input, std::vector* errors); +void xml_attribute_to_festival_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + FestivalFilter* value, + bool* is_set); std::string festival_filter_to_xml_attribute(const std::string& attribute_name, const FestivalFilter* value); waypoint::FestivalFilter* to_proto_festival_filter(FestivalFilter attribute_value); FestivalFilter from_proto_festival_filter(waypoint::FestivalFilter proto_festival_filter); diff --git a/xml_converter/src/attribute/float.cpp b/xml_converter/src/attribute/float.cpp index f15be56c..e2d3f5f8 100644 --- a/xml_converter/src/attribute/float.cpp +++ b/xml_converter/src/attribute/float.cpp @@ -12,8 +12,13 @@ using namespace std; // // Parses a float from the value of a rapidxml::xml_attribute. //////////////////////////////////////////////////////////////////////////////// -float parse_float(rapidxml::xml_attribute<>* input, std::vector*) { - return std::stof(get_attribute_value(input)); +void xml_attribute_to_float( + rapidxml::xml_attribute<>* input, + std::vector* errors, + float* value, + bool* is_set) { + *value = std::stof(get_attribute_value(input)); + *is_set = true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/xml_converter/src/attribute/float.hpp b/xml_converter/src/attribute/float.hpp index d4fec324..b7186755 100644 --- a/xml_converter/src/attribute/float.hpp +++ b/xml_converter/src/attribute/float.hpp @@ -7,7 +7,11 @@ class XMLError; -float parse_float(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_float( + rapidxml::xml_attribute<>* input, + std::vector* errors, + float* value, + bool* is_set); std::string float_to_xml_attribute(const std::string& attribute_name, const float* value); diff --git a/xml_converter/src/attribute/image.cpp b/xml_converter/src/attribute/image.cpp index 31055d7f..efbe26ae 100644 --- a/xml_converter/src/attribute/image.cpp +++ b/xml_converter/src/attribute/image.cpp @@ -15,10 +15,13 @@ using namespace std; // // Parses the path to an image from the value of a rapidxml::xml_attribute. //////////////////////////////////////////////////////////////////////////////// -Image parse_image(rapidxml::xml_attribute<>* input, vector*) { - Image image; - image.path = get_attribute_value(input); - return image; +void xml_attribute_to_image( + rapidxml::xml_attribute<>* input, + std::vector* errors, + Image* value, + bool* is_set) { + value->path = get_attribute_value(input); + *is_set = true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/xml_converter/src/attribute/image.hpp b/xml_converter/src/attribute/image.hpp index e71ba15e..c2083d38 100644 --- a/xml_converter/src/attribute/image.hpp +++ b/xml_converter/src/attribute/image.hpp @@ -15,7 +15,11 @@ class Image { std::string path; }; -Image parse_image(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_image( + rapidxml::xml_attribute<>* input, + std::vector* errors, + Image* value, + bool* is_set); std::string image_to_xml_attribute(const std::string& attribute_name, const Image* value); diff --git a/xml_converter/src/attribute/int.cpp b/xml_converter/src/attribute/int.cpp index b5923bad..d9564f8e 100644 --- a/xml_converter/src/attribute/int.cpp +++ b/xml_converter/src/attribute/int.cpp @@ -11,18 +11,22 @@ using namespace std; //////////////////////////////////////////////////////////////////////////////// -// parse_int +// xml_attribute_to_int // // Parses an int from the value of a rapidxml::xml_attribute. Adds an error // if the value cannot be parsed properly. //////////////////////////////////////////////////////////////////////////////// -int parse_int(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_int( + rapidxml::xml_attribute<>* input, + std::vector* errors, + int* value, + bool* is_set) { try { - return stoi(get_attribute_value(input)); + *value = stoi(get_attribute_value(input)); + *is_set = true; } catch (std::invalid_argument const& exception) { errors->push_back(new XMLAttributeValueError("Invalid integer value", input)); - return 0; } // TODO(#99): Do we need an out_of_range exception catch when parsing integers? // catch(std::out_of_range const& exception) { diff --git a/xml_converter/src/attribute/int.hpp b/xml_converter/src/attribute/int.hpp index 4d0d8b41..9ba2f69f 100644 --- a/xml_converter/src/attribute/int.hpp +++ b/xml_converter/src/attribute/int.hpp @@ -7,7 +7,11 @@ class XMLError; -int parse_int(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_int( + rapidxml::xml_attribute<>* input, + std::vector* errors, + int* value, + bool* is_set); std::string int_to_xml_attribute(const std::string& attribute_name, const int* value); diff --git a/xml_converter/src/attribute/map_type_filter_gen.cpp b/xml_converter/src/attribute/map_type_filter_gen.cpp index bd4a36f8..fee22ef1 100644 --- a/xml_converter/src/attribute/map_type_filter_gen.cpp +++ b/xml_converter/src/attribute/map_type_filter_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -MapTypeFilter parse_map_type_filter(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_map_type_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + MapTypeFilter* value, + bool* is_set) { MapTypeFilter map_type_filter; vector flag_values; flag_values = split(get_attribute_value(input), ","); @@ -120,7 +124,8 @@ MapTypeFilter parse_map_type_filter(rapidxml::xml_attribute<>* input, vector* input, std::vector* errors); +void xml_attribute_to_map_type_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + MapTypeFilter* value, + bool* is_set); std::string map_type_filter_to_xml_attribute(const std::string& attribute_name, const MapTypeFilter* value); waypoint::MapTypeFilter* to_proto_map_type_filter(MapTypeFilter attribute_value); MapTypeFilter from_proto_map_type_filter(waypoint::MapTypeFilter proto_map_type_filter); diff --git a/xml_converter/src/attribute/marker_category.cpp b/xml_converter/src/attribute/marker_category.cpp index 32e73c1c..8e664857 100644 --- a/xml_converter/src/attribute/marker_category.cpp +++ b/xml_converter/src/attribute/marker_category.cpp @@ -12,10 +12,13 @@ // // Parses a MarkerCategory from the value of a rapidxml::xml_attribute. //////////////////////////////////////////////////////////////////////////////// -MarkerCategory parse_marker_category(rapidxml::xml_attribute<>* input, std::vector*) { - MarkerCategory marker_category; - marker_category.category = get_attribute_value(input); - return marker_category; +void xml_attribute_to_marker_category( + rapidxml::xml_attribute<>* input, + std::vector* errors, + MarkerCategory* value, + bool* is_set) { + value->category = get_attribute_value(input); + *is_set = true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/xml_converter/src/attribute/marker_category.hpp b/xml_converter/src/attribute/marker_category.hpp index 018f06db..a2a57f36 100644 --- a/xml_converter/src/attribute/marker_category.hpp +++ b/xml_converter/src/attribute/marker_category.hpp @@ -15,7 +15,11 @@ class MarkerCategory { std::string category; }; -MarkerCategory parse_marker_category(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_marker_category( + rapidxml::xml_attribute<>* input, + std::vector* errors, + MarkerCategory* value, + bool* is_set); std::string marker_category_to_xml_attribute(const std::string& attribute_name, const MarkerCategory* value); diff --git a/xml_converter/src/attribute/mount_filter_gen.cpp b/xml_converter/src/attribute/mount_filter_gen.cpp index 3907c15d..4a0e4a5d 100644 --- a/xml_converter/src/attribute/mount_filter_gen.cpp +++ b/xml_converter/src/attribute/mount_filter_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -MountFilter parse_mount_filter(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_mount_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + MountFilter* value, + bool* is_set) { MountFilter mount_filter; vector flag_values; flag_values = split(get_attribute_value(input), ","); @@ -64,7 +68,8 @@ MountFilter parse_mount_filter(rapidxml::xml_attribute<>* input, vector* input, std::vector* errors); +void xml_attribute_to_mount_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + MountFilter* value, + bool* is_set); std::string mount_filter_to_xml_attribute(const std::string& attribute_name, const MountFilter* value); waypoint::MountFilter* to_proto_mount_filter(MountFilter attribute_value); MountFilter from_proto_mount_filter(waypoint::MountFilter proto_mount_filter); diff --git a/xml_converter/src/attribute/position_gen.cpp b/xml_converter/src/attribute/position_gen.cpp index 5cc086b8..4a19ea16 100644 --- a/xml_converter/src/attribute/position_gen.cpp +++ b/xml_converter/src/attribute/position_gen.cpp @@ -11,7 +11,11 @@ using namespace std; -Position parse_position(rapidxml::xml_attribute<>* input, vector*) { +void xml_attribute_to_position( + rapidxml::xml_attribute<>* input, + std::vector* errors, + Position* value, + bool* is_set) { Position position; vector compound_values; string attributename; @@ -25,7 +29,8 @@ Position parse_position(rapidxml::xml_attribute<>* input, vector*) { position.y_position = std::stof(compound_values[1]); position.z_position = std::stof(compound_values[2]); } - return position; + *value = position; + *is_set = true; } waypoint::Position* to_proto_position(Position attribute_value) { diff --git a/xml_converter/src/attribute/position_gen.hpp b/xml_converter/src/attribute/position_gen.hpp index 2525e1de..952e0529 100644 --- a/xml_converter/src/attribute/position_gen.hpp +++ b/xml_converter/src/attribute/position_gen.hpp @@ -19,7 +19,11 @@ class Position { return "Position"; } }; -Position parse_position(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_position( + rapidxml::xml_attribute<>* input, + std::vector* errors, + Position* value, + bool* is_set); std::string position_to_xml_attribute(const std::string& attribute_name, const Position* value); waypoint::Position* to_proto_position(Position attribute_value); Position from_proto_position(waypoint::Position proto_position); diff --git a/xml_converter/src/attribute/profession_filter_gen.cpp b/xml_converter/src/attribute/profession_filter_gen.cpp index 9f9d989d..7eeb9ae2 100644 --- a/xml_converter/src/attribute/profession_filter_gen.cpp +++ b/xml_converter/src/attribute/profession_filter_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -ProfessionFilter parse_profession_filter(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_profession_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + ProfessionFilter* value, + bool* is_set) { ProfessionFilter profession_filter; vector flag_values; flag_values = split(get_attribute_value(input), ","); @@ -60,7 +64,8 @@ ProfessionFilter parse_profession_filter(rapidxml::xml_attribute<>* input, vecto continue; } } - return profession_filter; + *value = profession_filter; + *is_set = true; } string profession_filter_to_xml_attribute(const std::string& attribute_name, const ProfessionFilter* value) { diff --git a/xml_converter/src/attribute/profession_filter_gen.hpp b/xml_converter/src/attribute/profession_filter_gen.hpp index 4baff30e..89358d30 100644 --- a/xml_converter/src/attribute/profession_filter_gen.hpp +++ b/xml_converter/src/attribute/profession_filter_gen.hpp @@ -25,7 +25,11 @@ class ProfessionFilter { return "ProfessionFilter"; } }; -ProfessionFilter parse_profession_filter(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_profession_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + ProfessionFilter* value, + bool* is_set); std::string profession_filter_to_xml_attribute(const std::string& attribute_name, const ProfessionFilter* value); waypoint::ProfessionFilter* to_proto_profession_filter(ProfessionFilter attribute_value); ProfessionFilter from_proto_profession_filter(waypoint::ProfessionFilter proto_profession_filter); diff --git a/xml_converter/src/attribute/reset_behavior_gen.cpp b/xml_converter/src/attribute/reset_behavior_gen.cpp index 819c34ea..03af6714 100644 --- a/xml_converter/src/attribute/reset_behavior_gen.cpp +++ b/xml_converter/src/attribute/reset_behavior_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -ResetBehavior parse_reset_behavior(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_reset_behavior( + rapidxml::xml_attribute<>* input, + std::vector* errors, + ResetBehavior* value, + bool* is_set) { ResetBehavior reset_behavior; string normalized_value = normalize(get_attribute_value(input)); if (normalized_value == "0") { @@ -73,7 +77,8 @@ ResetBehavior parse_reset_behavior(rapidxml::xml_attribute<>* input, vectorpush_back(new XMLAttributeValueError("Found an invalid value that was not in the Enum ResetBehavior", input)); reset_behavior = ResetBehavior::always_visible; } - return reset_behavior; + *value = reset_behavior; + *is_set = true; } string reset_behavior_to_xml_attribute(const std::string& attribute_name, const ResetBehavior* value) { diff --git a/xml_converter/src/attribute/reset_behavior_gen.hpp b/xml_converter/src/attribute/reset_behavior_gen.hpp index 85f35078..fb340f64 100644 --- a/xml_converter/src/attribute/reset_behavior_gen.hpp +++ b/xml_converter/src/attribute/reset_behavior_gen.hpp @@ -19,7 +19,11 @@ enum ResetBehavior { timer, weekly_reset, }; -ResetBehavior parse_reset_behavior(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_reset_behavior( + rapidxml::xml_attribute<>* input, + std::vector* errors, + ResetBehavior* value, + bool* is_set); std::string reset_behavior_to_xml_attribute(const std::string& attribute_name, const ResetBehavior* value); waypoint::ResetBehavior to_proto_reset_behavior(ResetBehavior attribute_value); ResetBehavior from_proto_reset_behavior(waypoint::ResetBehavior proto_reset_behavior); diff --git a/xml_converter/src/attribute/specialization_filter_gen.cpp b/xml_converter/src/attribute/specialization_filter_gen.cpp index 584acb24..a6435619 100644 --- a/xml_converter/src/attribute/specialization_filter_gen.cpp +++ b/xml_converter/src/attribute/specialization_filter_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -SpecializationFilter parse_specialization_filter(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_specialization_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + SpecializationFilter* value, + bool* is_set) { SpecializationFilter specialization_filter; vector flag_values; flag_values = split(get_attribute_value(input), ","); @@ -393,7 +397,8 @@ SpecializationFilter parse_specialization_filter(rapidxml::xml_attribute<>* inpu continue; } } - return specialization_filter; + *value = specialization_filter; + *is_set = true; } string specialization_filter_to_xml_attribute(const std::string& attribute_name, const SpecializationFilter* value) { diff --git a/xml_converter/src/attribute/specialization_filter_gen.hpp b/xml_converter/src/attribute/specialization_filter_gen.hpp index be3438e5..2abd7515 100644 --- a/xml_converter/src/attribute/specialization_filter_gen.hpp +++ b/xml_converter/src/attribute/specialization_filter_gen.hpp @@ -88,7 +88,11 @@ class SpecializationFilter { return "SpecializationFilter"; } }; -SpecializationFilter parse_specialization_filter(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_specialization_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + SpecializationFilter* value, + bool* is_set); std::string specialization_filter_to_xml_attribute(const std::string& attribute_name, const SpecializationFilter* value); waypoint::SpecializationFilter* to_proto_specialization_filter(SpecializationFilter attribute_value); SpecializationFilter from_proto_specialization_filter(waypoint::SpecializationFilter proto_specialization_filter); diff --git a/xml_converter/src/attribute/species_filter_gen.cpp b/xml_converter/src/attribute/species_filter_gen.cpp index 43898691..af68e1f2 100644 --- a/xml_converter/src/attribute/species_filter_gen.cpp +++ b/xml_converter/src/attribute/species_filter_gen.cpp @@ -12,7 +12,11 @@ using namespace std; -SpeciesFilter parse_species_filter(rapidxml::xml_attribute<>* input, vector* errors) { +void xml_attribute_to_species_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + SpeciesFilter* value, + bool* is_set) { SpeciesFilter species_filter; vector flag_values; flag_values = split(get_attribute_value(input), ","); @@ -44,7 +48,8 @@ SpeciesFilter parse_species_filter(rapidxml::xml_attribute<>* input, vector* input, std::vector* errors); +void xml_attribute_to_species_filter( + rapidxml::xml_attribute<>* input, + std::vector* errors, + SpeciesFilter* value, + bool* is_set); std::string species_filter_to_xml_attribute(const std::string& attribute_name, const SpeciesFilter* value); waypoint::SpeciesFilter* to_proto_species_filter(SpeciesFilter attribute_value); SpeciesFilter from_proto_species_filter(waypoint::SpeciesFilter proto_species_filter); diff --git a/xml_converter/src/attribute/string.cpp b/xml_converter/src/attribute/string.cpp index 5f3a0202..14095d1a 100644 --- a/xml_converter/src/attribute/string.cpp +++ b/xml_converter/src/attribute/string.cpp @@ -10,12 +10,17 @@ using namespace std; //////////////////////////////////////////////////////////////////////////////// -// parse_string +// xml_attribute_to_string // // Parses a string from the value of a rapidxml::xml_attribute. //////////////////////////////////////////////////////////////////////////////// -string parse_string(rapidxml::xml_attribute<>* input, vector*) { - return get_attribute_value(input); +void xml_attribute_to_string( + rapidxml::xml_attribute<>* input, + std::vector* errors, + string* value, + bool* is_set) { + *value = get_attribute_value(input); + *is_set = true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/xml_converter/src/attribute/string.hpp b/xml_converter/src/attribute/string.hpp index 381ccc40..96dc45b5 100644 --- a/xml_converter/src/attribute/string.hpp +++ b/xml_converter/src/attribute/string.hpp @@ -7,7 +7,11 @@ class XMLError; -std::string parse_string(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_string( + rapidxml::xml_attribute<>* input, + std::vector* errors, + std::string* value, + bool* is_set); std::string string_to_xml_attribute(const std::string& attribute_name, const std::string* value); diff --git a/xml_converter/src/attribute/trail_data.cpp b/xml_converter/src/attribute/trail_data.cpp index a58f5333..92a7de10 100644 --- a/xml_converter/src/attribute/trail_data.cpp +++ b/xml_converter/src/attribute/trail_data.cpp @@ -18,7 +18,12 @@ using namespace std; // // Parses a TrailData from the value of a rapidxml::xml_attribute. //////////////////////////////////////////////////////////////////////////////// -TrailData parse_trail_data(rapidxml::xml_attribute<>* input, vector* errors, string base_dir) { +void xml_attribute_to_trail_data( + rapidxml::xml_attribute<>* input, + vector* errors, + string base_dir, + TrailData* value, + bool* is_set) { TrailData trail_data; string trail_data_relative_path = get_attribute_value(input); if (base_dir == "") { @@ -26,7 +31,7 @@ TrailData parse_trail_data(rapidxml::xml_attribute<>* input, vector* } if (trail_data_relative_path == "") { errors->push_back(new XMLAttributeValueError("Path to trail file is empty", input)); - return trail_data; + return; } ifstream trail_data_file; @@ -34,14 +39,14 @@ TrailData parse_trail_data(rapidxml::xml_attribute<>* input, vector* 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)); - return trail_data; + return; } char version[4]; trail_data_file.read(version, 4); // Validate the version number. Currently supports versions [0] if (!(*reinterpret_cast(version) == 0)) { errors->push_back(new XMLAttributeValueError("Unsupported version for trail data at " + trail_path, input)); - return trail_data; + return; } char map_id_char[4]; @@ -67,7 +72,8 @@ TrailData parse_trail_data(rapidxml::xml_attribute<>* input, vector* trail_data_file.close(); - return trail_data; + *value = trail_data; + *is_set = true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/xml_converter/src/attribute/trail_data.hpp b/xml_converter/src/attribute/trail_data.hpp index 517eabd0..5bc55a6f 100644 --- a/xml_converter/src/attribute/trail_data.hpp +++ b/xml_converter/src/attribute/trail_data.hpp @@ -18,7 +18,12 @@ class TrailData { std::vector points_z; }; -TrailData parse_trail_data(rapidxml::xml_attribute<>* input, std::vector* errors, std::string base_dir); +void xml_attribute_to_trail_data( + rapidxml::xml_attribute<>* input, + std::vector* errors, + std::string base_dir, + TrailData* value, + bool* is_set); std::string trail_data_to_xml_attribute(const std::string& attribute_name, const TrailData* value); diff --git a/xml_converter/src/attribute/unique_id.cpp b/xml_converter/src/attribute/unique_id.cpp index 6e136be4..e5217527 100644 --- a/xml_converter/src/attribute/unique_id.cpp +++ b/xml_converter/src/attribute/unique_id.cpp @@ -12,13 +12,16 @@ using namespace std; -UniqueId parse_unique_id(rapidxml::xml_attribute<>* input, vector*) { - UniqueId unique_id; +void xml_attribute_to_unique_id( + rapidxml::xml_attribute<>* input, + std::vector* errors, + UniqueId* value, + bool* is_set) { string base64; base64 = get_attribute_value(input); std::vector guid = base64_decode(base64); - unique_id.guid = guid; - return unique_id; + value->guid = guid; + *is_set = true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/xml_converter/src/attribute/unique_id.hpp b/xml_converter/src/attribute/unique_id.hpp index 0e58771b..1c39a6a1 100644 --- a/xml_converter/src/attribute/unique_id.hpp +++ b/xml_converter/src/attribute/unique_id.hpp @@ -16,7 +16,11 @@ class UniqueId { std::vector guid; }; -UniqueId parse_unique_id(rapidxml::xml_attribute<>* input, std::vector* errors); +void xml_attribute_to_unique_id( + rapidxml::xml_attribute<>* input, + std::vector* errors, + UniqueId* value, + bool* is_set); std::string unique_id_to_xml_attribute(const std::string& attribute_name, const UniqueId* value); diff --git a/xml_converter/src/category_gen.cpp b/xml_converter/src/category_gen.cpp index e6dbab6f..b76f6000 100644 --- a/xml_converter/src/category_gen.cpp +++ b/xml_converter/src/category_gen.cpp @@ -37,24 +37,19 @@ bool Category::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vectordefault_visibility = parse_bool(attribute, errors); - this->default_visibility_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->default_visibility), &(this->default_visibility_is_set)); } else if (attributename == "displayname") { - this->display_name = parse_string(attribute, errors); - this->display_name_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->display_name), &(this->display_name_is_set)); } else if (attributename == "isseparator") { - this->is_separator = parse_bool(attribute, errors); - this->is_separator_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->is_separator), &(this->is_separator_is_set)); } else if (attributename == "name") { - this->name = parse_string(attribute, errors); - this->name_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->name), &(this->name_is_set)); } else if (attributename == "tipdescription") { - this->tooltip_description = parse_string(attribute, errors); - this->tooltip_description_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->tooltip_description), &(this->tooltip_description_is_set)); } else { return false; diff --git a/xml_converter/src/icon_gen.cpp b/xml_converter/src/icon_gen.cpp index 46b278e0..cf5f0f80 100644 --- a/xml_converter/src/icon_gen.cpp +++ b/xml_converter/src/icon_gen.cpp @@ -23,292 +23,220 @@ bool Icon::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vectorachievement_bitmask = parse_int(attribute, errors); - this->achievement_bitmask_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->achievement_bitmask), &(this->achievement_bitmask_is_set)); } else if (attributename == "achievementid") { - this->achievement_id = parse_int(attribute, errors); - this->achievement_id_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->achievement_id), &(this->achievement_id_is_set)); } else if (attributename == "autotrigger") { - this->auto_trigger = parse_bool(attribute, errors); - this->auto_trigger_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->auto_trigger), &(this->auto_trigger_is_set)); } else if (attributename == "bouncedelay") { - this->bounce_delay = parse_float(attribute, errors); - this->bounce_delay_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->bounce_delay), &(this->bounce_delay_is_set)); } else if (attributename == "bounceduration") { - this->bounce_duration = parse_float(attribute, errors); - this->bounce_duration_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->bounce_duration), &(this->bounce_duration_is_set)); } else if (attributename == "bounceheight") { - this->bounce_height = parse_float(attribute, errors); - this->bounce_height_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->bounce_height), &(this->bounce_height_is_set)); } else if (attributename == "canfade") { - this->can_fade = parse_bool(attribute, errors); - this->can_fade_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->can_fade), &(this->can_fade_is_set)); } else if (attributename == "type") { - this->category = parse_marker_category(attribute, errors); - this->category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); } else if (attributename == "category") { - this->category = parse_marker_category(attribute, errors); - this->category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); } else if (attributename == "color") { - this->color = parse_color(attribute, errors); - this->color_is_set = true; + xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); } else if (attributename == "bhcolor") { - this->color = parse_color(attribute, errors); - this->color_is_set = true; + xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); } else if (attributename == "alpha") { - this->color.alpha = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.alpha), &(this->color_is_set)); } else if (attributename == "blue") { - this->color.blue = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.blue), &(this->color_is_set)); } else if (attributename == "green") { - this->color.green = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.green), &(this->color_is_set)); } else if (attributename == "red") { - this->color.red = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.red), &(this->color_is_set)); } else if (attributename == "copy") { - this->copy_clipboard = parse_string(attribute, errors); - this->copy_clipboard_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->copy_clipboard), &(this->copy_clipboard_is_set)); } else if (attributename == "copyclipboard") { - this->copy_clipboard = parse_string(attribute, errors); - this->copy_clipboard_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->copy_clipboard), &(this->copy_clipboard_is_set)); } else if (attributename == "copymessage") { - this->copy_message = parse_string(attribute, errors); - this->copy_message_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->copy_message), &(this->copy_message_is_set)); } else if (attributename == "cull") { - this->cull_chirality = parse_cull_chirality(attribute, errors); - this->cull_chirality_is_set = true; + xml_attribute_to_cull_chirality(attribute, errors, &(this->cull_chirality), &(this->cull_chirality_is_set)); } else if (attributename == "fadefar") { - this->distance_fade_end = parse_float(attribute, errors); - this->distance_fade_end_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "distancefadeend") { - this->distance_fade_end = parse_float(attribute, errors); - this->distance_fade_end_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "fadenear") { - this->distance_fade_start = parse_float(attribute, errors); - this->distance_fade_start_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "distancefadestart") { - this->distance_fade_start = parse_float(attribute, errors); - this->distance_fade_start_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "rotate") { - this->euler_rotation = parse_euler_rotation(attribute, errors); - this->euler_rotation_is_set = true; + xml_attribute_to_euler_rotation(attribute, errors, &(this->euler_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "rotatex") { - this->euler_rotation.x_rotation = parse_float(attribute, errors); - this->euler_rotation_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->euler_rotation.x_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "rotatey") { - this->euler_rotation.y_rotation = parse_float(attribute, errors); - this->euler_rotation_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->euler_rotation.y_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "rotatez") { - this->euler_rotation.z_rotation = parse_float(attribute, errors); - this->euler_rotation_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->euler_rotation.z_rotation), &(this->euler_rotation_is_set)); } else if (attributename == "festival") { - this->festival_filter = parse_festival_filter(attribute, errors); - this->festival_filter_is_set = true; + xml_attribute_to_festival_filter(attribute, errors, &(this->festival_filter), &(this->festival_filter_is_set)); } else if (attributename == "guid") { - this->guid = parse_unique_id(attribute, errors); - this->guid_is_set = true; + xml_attribute_to_unique_id(attribute, errors, &(this->guid), &(this->guid_is_set)); } else if (attributename == "hascountdown") { - this->has_countdown = parse_bool(attribute, errors); - this->has_countdown_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->has_countdown), &(this->has_countdown_is_set)); } else if (attributename == "heightoffset") { - this->height_offset = parse_float(attribute, errors); - this->height_offset_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->height_offset), &(this->height_offset_is_set)); } else if (attributename == "bhheightoffset") { - this->height_offset = parse_float(attribute, errors); - this->height_offset_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->height_offset), &(this->height_offset_is_set)); } else if (attributename == "hide") { - this->hide_category = parse_marker_category(attribute, errors); - this->hide_category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->hide_category), &(this->hide_category_is_set)); } else if (attributename == "iconfile") { - this->icon = parse_image(attribute, errors); - this->icon_is_set = true; + xml_attribute_to_image(attribute, errors, &(this->icon), &(this->icon_is_set)); } else if (attributename == "iconsize") { - this->icon_size = parse_float(attribute, errors); - this->icon_size_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->icon_size), &(this->icon_size_is_set)); } else if (attributename == "info") { - this->info_message = parse_string(attribute, errors); - this->info_message_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->info_message), &(this->info_message_is_set)); } else if (attributename == "invertbehavior") { - this->invert_visibility = parse_bool(attribute, errors); - this->invert_visibility_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->invert_visibility), &(this->invert_visibility_is_set)); } else if (attributename == "mapdisplaysize") { - this->map_display_size = parse_int(attribute, errors); - this->map_display_size_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->map_display_size), &(this->map_display_size_is_set)); } else if (attributename == "mapid") { - this->map_id = parse_int(attribute, errors); - this->map_id_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->map_id), &(this->map_id_is_set)); } else if (attributename == "maptype") { - this->map_type_filter = parse_map_type_filter(attribute, errors); - this->map_type_filter_is_set = true; + xml_attribute_to_map_type_filter(attribute, errors, &(this->map_type_filter), &(this->map_type_filter_is_set)); } else if (attributename == "maxsize") { - this->maximum_size_on_screen = parse_int(attribute, errors); - this->maximum_size_on_screen_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->maximum_size_on_screen), &(this->maximum_size_on_screen_is_set)); } else if (attributename == "minsize") { - this->minimum_size_on_screen = parse_int(attribute, errors); - this->minimum_size_on_screen_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->minimum_size_on_screen), &(this->minimum_size_on_screen_is_set)); } else if (attributename == "mount") { - this->mount_filter = parse_mount_filter(attribute, errors); - this->mount_filter_is_set = true; + xml_attribute_to_mount_filter(attribute, errors, &(this->mount_filter), &(this->mount_filter_is_set)); } else if (attributename == "position") { - this->position = parse_position(attribute, errors); - this->position_is_set = true; + xml_attribute_to_position(attribute, errors, &(this->position), &(this->position_is_set)); } else if (attributename == "xpos") { - this->position.x_position = parse_float(attribute, errors); - this->position_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->position.x_position), &(this->position_is_set)); } else if (attributename == "positionx") { - this->position.x_position = parse_float(attribute, errors); - this->position_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->position.x_position), &(this->position_is_set)); } else if (attributename == "ypos") { - this->position.y_position = parse_float(attribute, errors); - this->position_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->position.y_position), &(this->position_is_set)); } else if (attributename == "positiony") { - this->position.y_position = parse_float(attribute, errors); - this->position_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->position.y_position), &(this->position_is_set)); } else if (attributename == "zpos") { - this->position.z_position = parse_float(attribute, errors); - this->position_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->position.z_position), &(this->position_is_set)); } else if (attributename == "positionz") { - this->position.z_position = parse_float(attribute, errors); - this->position_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->position.z_position), &(this->position_is_set)); } else if (attributename == "profession") { - this->profession_filter = parse_profession_filter(attribute, errors); - this->profession_filter_is_set = true; + xml_attribute_to_profession_filter(attribute, errors, &(this->profession_filter), &(this->profession_filter_is_set)); } else if (attributename == "ingamevisibility") { - this->render_ingame = parse_bool(attribute, errors); - this->render_ingame_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "bhingamevisibility") { - this->render_ingame = parse_bool(attribute, errors); - this->render_ingame_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "mapvisibility") { - this->render_on_map = parse_bool(attribute, errors); - this->render_on_map_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "bhmapvisibility") { - this->render_on_map = parse_bool(attribute, errors); - this->render_on_map_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "minimapvisibility") { - this->render_on_minimap = parse_bool(attribute, errors); - this->render_on_minimap_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "bhminimapvisibility") { - this->render_on_minimap = parse_bool(attribute, errors); - this->render_on_minimap_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "behavior") { - this->reset_behavior = parse_reset_behavior(attribute, errors); - this->reset_behavior_is_set = true; + xml_attribute_to_reset_behavior(attribute, errors, &(this->reset_behavior), &(this->reset_behavior_is_set)); } else if (attributename == "resetlength") { - this->reset_length = parse_float(attribute, errors); - this->reset_length_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->reset_length), &(this->reset_length_is_set)); } else if (attributename == "scaleonmapwithzoom") { - this->scale_on_map_with_zoom = parse_bool(attribute, errors); - this->scale_on_map_with_zoom_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->scale_on_map_with_zoom), &(this->scale_on_map_with_zoom_is_set)); } else if (attributename == "schedule") { - this->schedule = parse_string(attribute, errors); - this->schedule_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->schedule), &(this->schedule_is_set)); } else if (attributename == "scheduleduration") { - this->schedule_duration = parse_float(attribute, errors); - this->schedule_duration_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->schedule_duration), &(this->schedule_duration_is_set)); } else if (attributename == "show") { - this->show_category = parse_marker_category(attribute, errors); - this->show_category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->show_category), &(this->show_category_is_set)); } else if (attributename == "specialization") { - this->specialization_filter = parse_specialization_filter(attribute, errors); - this->specialization_filter_is_set = true; + xml_attribute_to_specialization_filter(attribute, errors, &(this->specialization_filter), &(this->specialization_filter_is_set)); } else if (attributename == "race") { - this->species_filter = parse_species_filter(attribute, errors); - this->species_filter_is_set = true; + xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "species") { - this->species_filter = parse_species_filter(attribute, errors); - this->species_filter_is_set = true; + xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "toggle") { - this->toggle_category = parse_marker_category(attribute, errors); - this->toggle_category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->toggle_category), &(this->toggle_category_is_set)); } else if (attributename == "togglecategory") { - this->toggle_category = parse_marker_category(attribute, errors); - this->toggle_category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->toggle_category), &(this->toggle_category_is_set)); } else if (attributename == "tipdescription") { - this->tooltip_description = parse_string(attribute, errors); - this->tooltip_description_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->tooltip_description), &(this->tooltip_description_is_set)); } else if (attributename == "tipname") { - this->tooltip_name = parse_string(attribute, errors); - this->tooltip_name_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->tooltip_name), &(this->tooltip_name_is_set)); } else if (attributename == "triggerrange") { - this->trigger_range = parse_float(attribute, errors); - this->trigger_range_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->trigger_range), &(this->trigger_range_is_set)); } else if (attributename == "inforange") { - this->trigger_range = parse_float(attribute, errors); - this->trigger_range_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->trigger_range), &(this->trigger_range_is_set)); } else { return false; diff --git a/xml_converter/src/trail_gen.cpp b/xml_converter/src/trail_gen.cpp index ffca5ab9..5df6d70d 100644 --- a/xml_converter/src/trail_gen.cpp +++ b/xml_converter/src/trail_gen.cpp @@ -23,166 +23,127 @@ bool Trail::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vectorachievement_bitmask = parse_int(attribute, errors); - this->achievement_bitmask_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->achievement_bitmask), &(this->achievement_bitmask_is_set)); } else if (attributename == "achievementid") { - this->achievement_id = parse_int(attribute, errors); - this->achievement_id_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->achievement_id), &(this->achievement_id_is_set)); } else if (attributename == "animspeed") { - this->animation_speed = parse_float(attribute, errors); - this->animation_speed_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->animation_speed), &(this->animation_speed_is_set)); } else if (attributename == "animationspeed") { - this->animation_speed = parse_float(attribute, errors); - this->animation_speed_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->animation_speed), &(this->animation_speed_is_set)); } else if (attributename == "canfade") { - this->can_fade = parse_bool(attribute, errors); - this->can_fade_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->can_fade), &(this->can_fade_is_set)); } else if (attributename == "type") { - this->category = parse_marker_category(attribute, errors); - this->category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); } else if (attributename == "category") { - this->category = parse_marker_category(attribute, errors); - this->category_is_set = true; + xml_attribute_to_marker_category(attribute, errors, &(this->category), &(this->category_is_set)); } else if (attributename == "color") { - this->color = parse_color(attribute, errors); - this->color_is_set = true; + xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); } else if (attributename == "bhcolor") { - this->color = parse_color(attribute, errors); - this->color_is_set = true; + xml_attribute_to_color(attribute, errors, &(this->color), &(this->color_is_set)); } else if (attributename == "alpha") { - this->color.alpha = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.alpha), &(this->color_is_set)); } else if (attributename == "blue") { - this->color.blue = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.blue), &(this->color_is_set)); } else if (attributename == "green") { - this->color.green = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.green), &(this->color_is_set)); } else if (attributename == "red") { - this->color.red = parse_float(attribute, errors); - this->color_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->color.red), &(this->color_is_set)); } else if (attributename == "cull") { - this->cull_chirality = parse_cull_chirality(attribute, errors); - this->cull_chirality_is_set = true; + xml_attribute_to_cull_chirality(attribute, errors, &(this->cull_chirality), &(this->cull_chirality_is_set)); } else if (attributename == "fadefar") { - this->distance_fade_end = parse_float(attribute, errors); - this->distance_fade_end_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "distancefadeend") { - this->distance_fade_end = parse_float(attribute, errors); - this->distance_fade_end_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_end), &(this->distance_fade_end_is_set)); } else if (attributename == "fadenear") { - this->distance_fade_start = parse_float(attribute, errors); - this->distance_fade_start_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "distancefadestart") { - this->distance_fade_start = parse_float(attribute, errors); - this->distance_fade_start_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->distance_fade_start), &(this->distance_fade_start_is_set)); } else if (attributename == "festival") { - this->festival_filter = parse_festival_filter(attribute, errors); - this->festival_filter_is_set = true; + xml_attribute_to_festival_filter(attribute, errors, &(this->festival_filter), &(this->festival_filter_is_set)); } else if (attributename == "guid") { - this->guid = parse_unique_id(attribute, errors); - this->guid_is_set = true; + xml_attribute_to_unique_id(attribute, errors, &(this->guid), &(this->guid_is_set)); } else if (attributename == "iswall") { - this->is_wall = parse_bool(attribute, errors); - this->is_wall_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->is_wall), &(this->is_wall_is_set)); } else if (attributename == "mapdisplaysize") { - this->map_display_size = parse_int(attribute, errors); - this->map_display_size_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->map_display_size), &(this->map_display_size_is_set)); } else if (attributename == "mapid") { - this->map_id = parse_int(attribute, errors); - this->map_id_is_set = true; + xml_attribute_to_int(attribute, errors, &(this->map_id), &(this->map_id_is_set)); } else if (attributename == "maptype") { - this->map_type_filter = parse_map_type_filter(attribute, errors); - this->map_type_filter_is_set = true; + xml_attribute_to_map_type_filter(attribute, errors, &(this->map_type_filter), &(this->map_type_filter_is_set)); } else if (attributename == "mount") { - this->mount_filter = parse_mount_filter(attribute, errors); - this->mount_filter_is_set = true; + xml_attribute_to_mount_filter(attribute, errors, &(this->mount_filter), &(this->mount_filter_is_set)); } else if (attributename == "profession") { - this->profession_filter = parse_profession_filter(attribute, errors); - this->profession_filter_is_set = true; + xml_attribute_to_profession_filter(attribute, errors, &(this->profession_filter), &(this->profession_filter_is_set)); } else if (attributename == "ingamevisibility") { - this->render_ingame = parse_bool(attribute, errors); - this->render_ingame_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "bhingamevisibility") { - this->render_ingame = parse_bool(attribute, errors); - this->render_ingame_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_ingame), &(this->render_ingame_is_set)); } else if (attributename == "mapvisibility") { - this->render_on_map = parse_bool(attribute, errors); - this->render_on_map_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "bhmapvisibility") { - this->render_on_map = parse_bool(attribute, errors); - this->render_on_map_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_map), &(this->render_on_map_is_set)); } else if (attributename == "minimapvisibility") { - this->render_on_minimap = parse_bool(attribute, errors); - this->render_on_minimap_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "bhminimapvisibility") { - this->render_on_minimap = parse_bool(attribute, errors); - this->render_on_minimap_is_set = true; + xml_attribute_to_bool(attribute, errors, &(this->render_on_minimap), &(this->render_on_minimap_is_set)); } else if (attributename == "schedule") { - this->schedule = parse_string(attribute, errors); - this->schedule_is_set = true; + xml_attribute_to_string(attribute, errors, &(this->schedule), &(this->schedule_is_set)); } else if (attributename == "scheduleduration") { - this->schedule_duration = parse_float(attribute, errors); - this->schedule_duration_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->schedule_duration), &(this->schedule_duration_is_set)); } else if (attributename == "specialization") { - this->specialization_filter = parse_specialization_filter(attribute, errors); - this->specialization_filter_is_set = true; + xml_attribute_to_specialization_filter(attribute, errors, &(this->specialization_filter), &(this->specialization_filter_is_set)); } else if (attributename == "race") { - this->species_filter = parse_species_filter(attribute, errors); - this->species_filter_is_set = true; + xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "species") { - this->species_filter = parse_species_filter(attribute, errors); - this->species_filter_is_set = true; + xml_attribute_to_species_filter(attribute, errors, &(this->species_filter), &(this->species_filter_is_set)); } else if (attributename == "texture") { - this->texture = parse_image(attribute, errors); - this->texture_is_set = true; + xml_attribute_to_image(attribute, errors, &(this->texture), &(this->texture_is_set)); } else if (attributename == "traildata") { - this->trail_data = parse_trail_data(attribute, errors, base_dir); - this->trail_data_is_set = true; + xml_attribute_to_trail_data(attribute, errors, base_dir, &(this->trail_data), &(this->trail_data_is_set)); + // TOOD: this side effects should be passed into the parse function this->map_id = this->trail_data.side_effect_map_id; this->map_id_is_set = true; } else if (attributename == "trailscale") { - this->trail_scale = parse_float(attribute, errors); - this->trail_scale_is_set = true; + xml_attribute_to_float(attribute, errors, &(this->trail_scale), &(this->trail_scale_is_set)); } else { return false;