From 26907d1f17cf1e489f255ec275207afc9ccded37 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Mon, 22 Jan 2024 01:14:41 -0600 Subject: [PATCH 1/3] Adding category id and auto-populating it if it is missing --- .../cpp_templates/class_template.hpp | 1 + .../output_proto/markers.bin | Bin 153 -> 163 bytes .../output_xml/xml_file.xml | 2 +- .../achievement_id/output_proto/markers.bin | 4 +- .../achievement_id/output_xml/xml_file.xml | 2 +- .../animation_speed/output_proto/markers.bin | Bin 642 -> 652 bytes .../animation_speed/output_xml/xml_file.xml | 2 +- .../canfade_invalid/output_proto/markers.bin | 4 +- .../canfade_invalid/output_xml/xml_file.xml | 2 +- .../canfade_valid/output_proto/markers.bin | 4 +- .../canfade_valid/output_xml/xml_file.xml | 2 +- .../category_name/output_proto/markers.bin | 4 +- .../category_name/output_xml/xml_file.xml | 2 +- .../output_xml/xml_file.xml | 4 +- .../cull_chirality/output_proto/markers.bin | 4 +- .../cull_chirality/output_xml/xml_file.xml | 2 +- .../fade_distance/output_proto/markers.bin | Bin 255 -> 265 bytes .../fade_distance/output_xml/xml_file.xml | 2 +- .../festival_filter/output_proto/markers.bin | 4 +- .../festival_filter/output_xml/xml_file.xml | 2 +- .../is_wall/output_proto/markers.bin | 4 +- .../is_wall/output_xml/xml_file.xml | 2 +- .../map_id/output_proto/markers.bin | 4 +- .../test_cases/map_id/output_xml/xml_file.xml | 2 +- .../map_type_filter/output_proto/markers.bin | 4 +- .../map_type_filter/output_xml/xml_file.xml | 2 +- .../output_proto/markers.bin | 4 +- .../output_xml/xml_file.xml | 2 +- .../output_proto/markers.bin | 4 +- .../mountfilter_valid/output_xml/xml_file.xml | 2 +- .../output_proto/markers.bin | 4 +- .../profession_filter/output_xml/xml_file.xml | 2 +- .../output_proto/markers.bin | 4 +- .../output_xml/xml_file.xml | 2 +- .../species_filter/output_proto/markers.bin | 4 +- .../species_filter/output_xml/xml_file.xml | 2 +- .../texture/output_proto/markers.bin | Bin 105 -> 115 bytes .../texture/output_xml/xml_file.xml | 2 +- xml_converter/proto/waypoint.proto | 1 + xml_converter/src/category_gen.cpp | 24 ++++++++++ xml_converter/src/category_gen.hpp | 4 ++ xml_converter/src/hash_helpers.cpp | 17 ++++++- xml_converter/src/hash_helpers.hpp | 3 +- xml_converter/src/packaging_xml.cpp | 43 ++++++++++++++++-- xml_converter/src/string_helper.cpp | 2 +- 45 files changed, 136 insertions(+), 55 deletions(-) diff --git a/xml_converter/generators/cpp_templates/class_template.hpp b/xml_converter/generators/cpp_templates/class_template.hpp index d509d9d7..f5294cc1 100644 --- a/xml_converter/generators/cpp_templates/class_template.hpp +++ b/xml_converter/generators/cpp_templates/class_template.hpp @@ -28,6 +28,7 @@ class {{cpp_class}} : public Parseable { std::map children; Icon default_icon; Trail default_trail; + Category* parent; void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, XMLReaderState* state); {% endif %} diff --git a/xml_converter/integration_tests/test_cases/achievement_bitmask_valid/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/achievement_bitmask_valid/output_proto/markers.bin index 6145a43afd1d9d981f575b7f3af3c14346c58450..a78bad0809d339dc9aa675ae823c39978ece2fd4 100644 GIT binary patch delta 21 dcmbQqxR{ZNYr#aO>0C}68ZXYU9hw|B4FE^_2b2H+ delta 10 RcmZ3?IFpfyYuZGn=>QNU0}B8E diff --git a/xml_converter/integration_tests/test_cases/achievement_bitmask_valid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/achievement_bitmask_valid/output_xml/xml_file.xml index 7535e6e6..b07e3ef9 100644 --- a/xml_converter/integration_tests/test_cases/achievement_bitmask_valid/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/achievement_bitmask_valid/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/achievement_id/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/achievement_id/output_proto/markers.bin index a5b458eb..df6a9bb5 100644 --- a/xml_converter/integration_tests/test_cases/achievement_id/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/achievement_id/output_proto/markers.bin @@ -1,3 +1,3 @@ - - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC" \ No newline at end of file + + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC"B(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/achievement_id/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/achievement_id/output_xml/xml_file.xml index 00cfc8cc..7da09fb4 100644 --- a/xml_converter/integration_tests/test_cases/achievement_id/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/achievement_id/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/animation_speed/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/animation_speed/output_proto/markers.bin index 269c512cc66e9454650f74aeff886b3e17a900fa..6306612065dc28e9cf1ad665e9b4de791ebe57d3 100644 GIT binary patch delta 23 ecmZo-?O|o+>SW!>T+hVi#G&!x4BMf}ank@vSO;hT delta 12 TcmeBSZDM8S`p>eFxt<9C7EJ?Q diff --git a/xml_converter/integration_tests/test_cases/animation_speed/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/animation_speed/output_xml/xml_file.xml index d3c71cf6..ff5aa933 100644 --- a/xml_converter/integration_tests/test_cases/animation_speed/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/animation_speed/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/canfade_invalid/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/canfade_invalid/output_proto/markers.bin index c32cb0ef..9adc8734 100644 --- a/xml_converter/integration_tests/test_cases/canfade_invalid/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/canfade_invalid/output_proto/markers.bin @@ -1,3 +1,3 @@ -7 - My Category 2B \)CfRC{WC 2B \)CfRC{WC \ No newline at end of file +A + My Category 2B \)CfRC{WC 2B \)CfRC{WCB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/canfade_invalid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/canfade_invalid/output_xml/xml_file.xml index 56b79ea1..b164fa46 100644 --- a/xml_converter/integration_tests/test_cases/canfade_invalid/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/canfade_invalid/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/canfade_valid/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/canfade_valid/output_proto/markers.bin index a1e1c437..a900d117 100644 --- a/xml_converter/integration_tests/test_cases/canfade_valid/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/canfade_valid/output_proto/markers.bin @@ -1,3 +1,3 @@ -g - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC \ No newline at end of file +q + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WCB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/canfade_valid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/canfade_valid/output_xml/xml_file.xml index 2850f7f7..6e16afe3 100644 --- a/xml_converter/integration_tests/test_cases/canfade_valid/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/canfade_valid/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/category_name/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/category_name/output_proto/markers.bin index a89a9d4a..27e2fe03 100644 --- a/xml_converter/integration_tests/test_cases/category_name/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/category_name/output_proto/markers.bin @@ -1,3 +1,3 @@ -L - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC \ No newline at end of file +V + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WCB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/category_name/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/category_name/output_xml/xml_file.xml index 0a23d2a0..daab7542 100644 --- a/xml_converter/integration_tests/test_cases/category_name/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/category_name/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/category_name_invalid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/category_name_invalid/output_xml/xml_file.xml index d6de0503..e9f72087 100644 --- a/xml_converter/integration_tests/test_cases/category_name_invalid/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/category_name_invalid/output_xml/xml_file.xml @@ -1,8 +1,8 @@ - + - + diff --git a/xml_converter/integration_tests/test_cases/cull_chirality/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/cull_chirality/output_proto/markers.bin index 0c984e70..480cc9ab 100644 --- a/xml_converter/integration_tests/test_cases/cull_chirality/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/cull_chirality/output_proto/markers.bin @@ -1,3 +1,3 @@ -R - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC \ No newline at end of file +\ + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WCB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/cull_chirality/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/cull_chirality/output_xml/xml_file.xml index d9a87c98..f9793d06 100644 --- a/xml_converter/integration_tests/test_cases/cull_chirality/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/cull_chirality/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/fade_distance/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/fade_distance/output_proto/markers.bin index 68ae59c38b05ed84d8f3f6628ed87c2e1c12a750..d69ff8710e4d62cd89e64b067e49d9225901ef70 100644 GIT binary patch delta 22 ecmey**vZ7q)y6cD`45*9hsKLDY= - + diff --git a/xml_converter/integration_tests/test_cases/festival_filter/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/festival_filter/output_proto/markers.bin index 57f60e15..ca65d1f0 100644 --- a/xml_converter/integration_tests/test_cases/festival_filter/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/festival_filter/output_proto/markers.bin @@ -1,3 +1,3 @@ -y - My Category 2B \)CfRC{WC 2B \)CfRC{WC( 2B \)CfRC{WC( 2B \)CfRC{WC  \ No newline at end of file + + My Category 2B \)CfRC{WC 2B \)CfRC{WC( 2B \)CfRC{WC( 2B \)CfRC{WC B(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/festival_filter/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/festival_filter/output_xml/xml_file.xml index 23d92fd3..70310c54 100644 --- a/xml_converter/integration_tests/test_cases/festival_filter/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/festival_filter/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/is_wall/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/is_wall/output_proto/markers.bin index 8984f382..da32a101 100644 --- a/xml_converter/integration_tests/test_cases/is_wall/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/is_wall/output_proto/markers.bin @@ -1,3 +1,3 @@ -# - My Category" 2" 2" 2" 2 \ No newline at end of file +- + My Category" 2" 2" 2" 2B(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/is_wall/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/is_wall/output_xml/xml_file.xml index caabb11a..5cbc4149 100644 --- a/xml_converter/integration_tests/test_cases/is_wall/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/is_wall/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/map_id/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/map_id/output_proto/markers.bin index cdc94a2a..24fdb7f4 100644 --- a/xml_converter/integration_tests/test_cases/map_id/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/map_id/output_proto/markers.bin @@ -1,3 +1,3 @@ -x - My CategoryB \)CfRC{WC B \)CfRC{WC B \)CfRC{WC B \)CfRC{WC 2B \)CfRC{WC \ No newline at end of file + + My CategoryB \)CfRC{WC B \)CfRC{WC B \)CfRC{WC B \)CfRC{WC 2B \)CfRC{WCB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/map_id/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/map_id/output_xml/xml_file.xml index 7cd7d10b..40133f47 100644 --- a/xml_converter/integration_tests/test_cases/map_id/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/map_id/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/map_type_filter/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/map_type_filter/output_proto/markers.bin index 416391e4..9cdd92bd 100644 --- a/xml_converter/integration_tests/test_cases/map_type_filter/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/map_type_filter/output_proto/markers.bin @@ -1,3 +1,3 @@ - - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WCO 2B \)CfRC{WC9 (08@HPX`hpx \ No newline at end of file + + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WCO 2B \)CfRC{WC9 (08@HPX`hpxB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/map_type_filter/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/map_type_filter/output_xml/xml_file.xml index 41115909..71c21475 100644 --- a/xml_converter/integration_tests/test_cases/map_type_filter/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/map_type_filter/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_proto/markers.bin index 3e5a1112..0e68e64b 100644 --- a/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_proto/markers.bin @@ -1,3 +1,3 @@ -o - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC \ No newline at end of file +y + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WCB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_xml/xml_file.xml index 53b34efe..14caab92 100644 --- a/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/mount_filter_invalid/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/mountfilter_valid/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/mountfilter_valid/output_proto/markers.bin index 4236a31f..7df59e89 100644 --- a/xml_converter/integration_tests/test_cases/mountfilter_valid/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/mountfilter_valid/output_proto/markers.bin @@ -1,3 +1,3 @@ - - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC* 2B \)CfRC{WC (08@HP \ No newline at end of file + + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC* 2B \)CfRC{WC (08@HPB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/mountfilter_valid/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/mountfilter_valid/output_xml/xml_file.xml index 38abbed2..35527920 100644 --- a/xml_converter/integration_tests/test_cases/mountfilter_valid/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/mountfilter_valid/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/profession_filter/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/profession_filter/output_proto/markers.bin index 0847dc80..46fbad2c 100644 --- a/xml_converter/integration_tests/test_cases/profession_filter/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/profession_filter/output_proto/markers.bin @@ -1,3 +1,3 @@ - - My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC( 2B \)CfRC{WC (08@H \ No newline at end of file + + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC( 2B \)CfRC{WC (08@HB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/profession_filter/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/profession_filter/output_xml/xml_file.xml index ecf54043..a81f4c58 100644 --- a/xml_converter/integration_tests/test_cases/profession_filter/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/profession_filter/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/specialization_filter/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/specialization_filter/output_proto/markers.bin index 8fdc192e..cffd4543 100644 --- a/xml_converter/integration_tests/test_cases/specialization_filter/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/specialization_filter/output_proto/markers.bin @@ -1,3 +1,3 @@ - - My Category 2B \)CfRC{WC` 2B \)CfRC{WCH 2B \)CfRC{WCX 2B \)CfRC{WC 2B \)CfRC{WC (08@HPX`hpxX 2B \)CfRC{WCB (08@HPX`hpx \ No newline at end of file + + My Category 2B \)CfRC{WC` 2B \)CfRC{WCH 2B \)CfRC{WCX 2B \)CfRC{WC 2B \)CfRC{WC (08@HPX`hpxX 2B \)CfRC{WCB (08@HPX`hpxB(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/specialization_filter/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/specialization_filter/output_xml/xml_file.xml index 05f8f905..46415be0 100644 --- a/xml_converter/integration_tests/test_cases/specialization_filter/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/specialization_filter/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/species_filter/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/species_filter/output_proto/markers.bin index 15f18c1b..efe60a25 100644 --- a/xml_converter/integration_tests/test_cases/species_filter/output_proto/markers.bin +++ b/xml_converter/integration_tests/test_cases/species_filter/output_proto/markers.bin @@ -1,5 +1,5 @@ - + My Category 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC  2B \)CfRC{WC  ( 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC 2B \)CfRC{WC  2B \)CfRC{WC - ( \ No newline at end of file + (B(“^ \ No newline at end of file diff --git a/xml_converter/integration_tests/test_cases/species_filter/output_xml/xml_file.xml b/xml_converter/integration_tests/test_cases/species_filter/output_xml/xml_file.xml index b2719c10..5d6e93c2 100644 --- a/xml_converter/integration_tests/test_cases/species_filter/output_xml/xml_file.xml +++ b/xml_converter/integration_tests/test_cases/species_filter/output_xml/xml_file.xml @@ -1,5 +1,5 @@ - + diff --git a/xml_converter/integration_tests/test_cases/texture/output_proto/markers.bin b/xml_converter/integration_tests/test_cases/texture/output_proto/markers.bin index ef56f99965e4e270aadd3d20ff1d553c01503e9f..075d211766ee2275192b9b90f632d64e74d7c8e3 100644 GIT binary patch delta 22 ecmc~SX5!MH$fU~U#G&!x4BMf}anmNMI{^SlMh8g% delta 11 ScmXTUWa3ht$fP>a& - + diff --git a/xml_converter/proto/waypoint.proto b/xml_converter/proto/waypoint.proto index 71c50d16..53b50e79 100644 --- a/xml_converter/proto/waypoint.proto +++ b/xml_converter/proto/waypoint.proto @@ -23,6 +23,7 @@ message Category { bool is_separator = 5; bool default_visibility = 6; string tip_description = 7; + bytes id = 8; } message Icon { diff --git a/xml_converter/src/category_gen.cpp b/xml_converter/src/category_gen.cpp index 39495ffc..c2674d65 100644 --- a/xml_converter/src/category_gen.cpp +++ b/xml_converter/src/category_gen.cpp @@ -45,6 +45,12 @@ bool Category::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vectoris_separator), &(this->is_separator_is_set)); } + else if (attributename == "id") { + xml_attribute_to_unique_id(attribute, errors, state, &(this->menu_id), &(this->menu_id_is_set)); + } + else if (attributename == "menuid") { + xml_attribute_to_unique_id(attribute, errors, state, &(this->menu_id), &(this->menu_id_is_set)); + } else if (attributename == "name") { xml_attribute_to_string(attribute, errors, state, &(this->name), &(this->name_is_set)); } @@ -69,6 +75,9 @@ vector Category::as_xml(XMLWriterState* state) const { if (this->is_separator_is_set) { xml_node_contents.push_back(bool_to_xml_attribute("IsSeparator", state, &this->is_separator)); } + if (this->menu_id_is_set) { + xml_node_contents.push_back(unique_id_to_xml_attribute("ID", state, &this->menu_id)); + } if (this->name_is_set) { xml_node_contents.push_back(string_to_xml_attribute("Name", state, &this->name)); } @@ -104,6 +113,10 @@ waypoint::Category Category::as_protobuf(ProtoWriterState* state) const { std::function setter = [&proto_category](bool val) { proto_category.set_is_separator(val); }; bool_to_proto(this->is_separator, state, setter); } + if (this->menu_id_is_set) { + std::function setter = [&proto_category](std::string val) { proto_category.set_id(val); }; + unique_id_to_proto(this->menu_id, state, setter); + } if (this->name_is_set) { std::function setter = [&proto_category](std::string val) { proto_category.set_name(val); }; do_nothing(this->name, state, setter); @@ -125,6 +138,9 @@ void Category::parse_protobuf(waypoint::Category proto_category, ProtoReaderStat if (proto_category.is_separator() != 0) { proto_to_bool(proto_category.is_separator(), state, &(this->is_separator), &(this->is_separator_is_set)); } + if (proto_category.id() != "") { + proto_to_unique_id(proto_category.id(), state, &(this->menu_id), &(this->menu_id_is_set)); + } if (proto_category.name() != "") { do_nothing(proto_category.name(), state, &(this->name), &(this->name_is_set)); } @@ -152,6 +168,10 @@ void Category::apply_underlay(const Category& underlay) { this->is_separator = underlay.is_separator; this->is_separator_is_set = true; } + if (!this->menu_id_is_set && underlay.menu_id_is_set) { + this->menu_id = underlay.menu_id; + this->menu_id_is_set = true; + } if (!this->name_is_set && underlay.name_is_set) { this->name = underlay.name; this->name_is_set = true; @@ -184,6 +204,10 @@ void Category::apply_overlay(const Category& overlay) { this->is_separator = overlay.is_separator; this->is_separator_is_set = true; } + if (overlay.menu_id_is_set) { + this->menu_id = overlay.menu_id; + this->menu_id_is_set = true; + } if (overlay.name_is_set) { this->name = overlay.name; this->name_is_set = true; diff --git a/xml_converter/src/category_gen.hpp b/xml_converter/src/category_gen.hpp index 4a6ecf91..840ee16a 100644 --- a/xml_converter/src/category_gen.hpp +++ b/xml_converter/src/category_gen.hpp @@ -5,6 +5,7 @@ #include #include +#include "attribute/unique_id.hpp" #include "icon_gen.hpp" #include "parseable.hpp" #include "rapidxml-1.13/rapidxml.hpp" @@ -19,16 +20,19 @@ class Category : public Parseable { bool default_visibility; std::string display_name; bool is_separator; + UniqueId menu_id; std::string name; std::string tooltip_description; bool default_visibility_is_set = false; bool display_name_is_set = false; bool is_separator_is_set = false; + bool menu_id_is_set = false; bool name_is_set = false; bool tooltip_description_is_set = false; std::map children; Icon default_icon; Trail default_trail; + Category* parent; void init_from_xml(rapidxml::xml_node<>* node, std::vector* errors, XMLReaderState* state); virtual std::vector as_xml(XMLWriterState* state) const; diff --git a/xml_converter/src/hash_helpers.cpp b/xml_converter/src/hash_helpers.cpp index 1c7ad3b9..7e54317e 100644 --- a/xml_converter/src/hash_helpers.cpp +++ b/xml_converter/src/hash_helpers.cpp @@ -1,7 +1,7 @@ // Hashing #include "hash_helpers.hpp" -const char* hex_chars = "0123456789abcdef"; +static const char* hex_chars = "0123456789abcdef"; Hash64::Hash64() { this->hash = 0b0000010010000001001101100111001011100111010110000100001101011110; @@ -81,3 +81,18 @@ std::string Hash128::hex() const { return hex_string; } + +UniqueId Hash128::unique_id() const { + UniqueId unique_id; + unique_id.guid = { + (unsigned char)((this->upper >> 0) & 0xFF), + (unsigned char)((this->upper >> 8) & 0xFF), + (unsigned char)((this->upper >> 16) & 0xFF), + (unsigned char)((this->upper >> 24) & 0xFF), + (unsigned char)((this->lower >> 0) & 0xFF), + (unsigned char)((this->lower >> 8) & 0xFF), + (unsigned char)((this->lower >> 16) & 0xFF), + (unsigned char)((this->lower >> 24) & 0xFF), + }; + return unique_id; +} \ No newline at end of file diff --git a/xml_converter/src/hash_helpers.hpp b/xml_converter/src/hash_helpers.hpp index 6ce2c40c..82e4af6c 100644 --- a/xml_converter/src/hash_helpers.hpp +++ b/xml_converter/src/hash_helpers.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include "attribute/unique_id.hpp" class Hash64 { private: @@ -25,5 +26,5 @@ class Hash128 { void update(const unsigned char* str, size_t length); void update(const std::string& str); std::string hex() const; - std::string base64() const; + UniqueId unique_id() const; }; diff --git a/xml_converter/src/packaging_xml.cpp b/xml_converter/src/packaging_xml.cpp index b5dddf16..945cbe3d 100644 --- a/xml_converter/src/packaging_xml.cpp +++ b/xml_converter/src/packaging_xml.cpp @@ -6,6 +6,7 @@ #include "rapidxml-1.13/rapidxml.hpp" #include "rapidxml-1.13/rapidxml_utils.hpp" #include "string_helper.hpp" +#include "hash_helpers.hpp" using namespace std; @@ -14,7 +15,13 @@ using namespace std; //////////////////////////////////////////////////////////////////////////////// unsigned int UNKNOWN_CATEGORY_COUNTER = 0; -void parse_marker_categories(rapidxml::xml_node<>* node, map* marker_categories, vector* errors, string base_dir, int depth = 0) { +void parse_marker_categories( + rapidxml::xml_node<>* node, + map* marker_categories, + Category* parent, + vector* errors, + string base_dir, + int depth = 0) { if (get_node_name(node) == "MarkerCategory") { XMLReaderState state = { base_dir, @@ -41,11 +48,39 @@ void parse_marker_categories(rapidxml::xml_node<>* node, map* name = lowercase(new_category.name); } - Category* existing_category = &(*marker_categories)[name]; + // If this category itself, without any cascading values, does not have + // an id then create a new one for it based on the hashes of its name + // and its parents names. + if (!new_category.menu_id_is_set) { + Hash128 new_id; + new_id.update(name); + + Category* next_node = parent; + while (next_node != nullptr) { + new_id.update(next_node->name); + next_node = next_node->parent; + } + new_category.menu_id = new_id.unique_id(); + new_category.menu_id_is_set = true; + } + + // Create and initialize a new category if this one does not exist + Category* existing_category; + auto existing_category_search = marker_categories->find(name); + if (existing_category_search == marker_categories->end()) { + existing_category = &(*marker_categories)[name]; + existing_category->parent = parent; + } + else { + existing_category = &existing_category_search->second; + if (existing_category->parent != parent) { + errors->push_back(new XMLNodeNameError("Category somehow has a different parent then it used to. This might be a bug in xml_converter", node)); + } + } existing_category->apply_overlay(new_category); for (rapidxml::xml_node<>* child_node = node->first_node(); child_node; child_node = child_node->next_sibling()) { - parse_marker_categories(child_node, &(existing_category->children), errors, base_dir, depth + 1); + parse_marker_categories(child_node, &(existing_category->children), existing_category, errors, base_dir, depth + 1); } } else { @@ -161,7 +196,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, base_dir); + parse_marker_categories(node, marker_categories, nullptr, &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/string_helper.cpp b/xml_converter/src/string_helper.cpp index e6b082e5..a8c7ca32 100644 --- a/xml_converter/src/string_helper.cpp +++ b/xml_converter/src/string_helper.cpp @@ -301,7 +301,7 @@ string join_file_paths(const string& path_a, const string& path_b) { // // A helper function that converts an 8 byte long into a 16 byte hex string. //////////////////////////////////////////////////////////////////////////////// -const char* hex_chars = "0123456789abcdef"; +static const char* hex_chars = "0123456789abcdef"; std::string long_to_hex_string(uint64_t number) { std::string hex_string(16, '0'); From b8862df0349a8c701a3864a5fef421f7db00b4d9 Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Mon, 22 Jan 2024 01:17:34 -0600 Subject: [PATCH 2/3] linter fixes --- xml_converter/src/hash_helpers.cpp | 2 +- xml_converter/src/hash_helpers.hpp | 1 + xml_converter/src/packaging_xml.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/xml_converter/src/hash_helpers.cpp b/xml_converter/src/hash_helpers.cpp index 7e54317e..2401d204 100644 --- a/xml_converter/src/hash_helpers.cpp +++ b/xml_converter/src/hash_helpers.cpp @@ -95,4 +95,4 @@ UniqueId Hash128::unique_id() const { (unsigned char)((this->lower >> 24) & 0xFF), }; return unique_id; -} \ No newline at end of file +} diff --git a/xml_converter/src/hash_helpers.hpp b/xml_converter/src/hash_helpers.hpp index 82e4af6c..9f982918 100644 --- a/xml_converter/src/hash_helpers.hpp +++ b/xml_converter/src/hash_helpers.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include "attribute/unique_id.hpp" class Hash64 { diff --git a/xml_converter/src/packaging_xml.cpp b/xml_converter/src/packaging_xml.cpp index 945cbe3d..56b0e68e 100644 --- a/xml_converter/src/packaging_xml.cpp +++ b/xml_converter/src/packaging_xml.cpp @@ -2,11 +2,11 @@ #include +#include "hash_helpers.hpp" #include "rapid_helpers.hpp" #include "rapidxml-1.13/rapidxml.hpp" #include "rapidxml-1.13/rapidxml_utils.hpp" #include "string_helper.hpp" -#include "hash_helpers.hpp" using namespace std; From 540152d546f6b2d541f3bbb0e0139ced90c5cb4a Mon Sep 17 00:00:00 2001 From: Asher Glick Date: Tue, 23 Jan 2024 01:51:17 -0600 Subject: [PATCH 3/3] adding doc file --- xml_converter/doc/menu/menu_id.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 xml_converter/doc/menu/menu_id.md diff --git a/xml_converter/doc/menu/menu_id.md b/xml_converter/doc/menu/menu_id.md new file mode 100644 index 00000000..ae312b8a --- /dev/null +++ b/xml_converter/doc/menu/menu_id.md @@ -0,0 +1,15 @@ +--- +name: Menu ID +type: Custom +class: UniqueId +xml_fields: [ID, MenuID] +applies_to: [Category] +protobuf_field: id +--- + +Notes +===== + +A 128bit long Unique ID. + +If the ID is not present when converting from XML, the ID is created as a hash of the category's "name" and the names of the categories parents.