Skip to content

Commit

Permalink
Merge branch 'xml_converter' into command_line_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
klingbolt authored Jan 19, 2025
2 parents 6804c9a + 728a70b commit 1873987
Show file tree
Hide file tree
Showing 95 changed files with 935 additions and 792 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
- name: Install gtest
run: sudo apt-get install libgtest-dev

- name: Install libzip
run: sudo apt-get install libzip-dev

- name: Install cpplint
run: |
pip3 install cpplint==1.6.1
Expand Down
6 changes: 3 additions & 3 deletions xml_converter/generators/cpp_templates/attribute_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ void xml_attribute_to_{{attribute_name}}(
{{class_name}}* value,
bool* is_set);

std::string {{attribute_name}}_to_xml_attribute(
const std::string& attribute_name,
void {{attribute_name}}_to_xml_attribute(
XMLWriterState* state,
const {{class_name}}* value);
const {{class_name}}* value,
std::function<void(std::string)> setter);
{% if exclude_from_protobuf == false %}

void proto_to_{{attribute_name}}(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ void xml_attribute_to_{{attribute_name}}(
*is_set = true;
}
{% if xml_bundled_components != [] %}
string {{attribute_name}}_to_xml_attribute(
const std::string& attribute_name,
void {{attribute_name}}_to_xml_attribute(
XMLWriterState*,
const {{class_name}}* value) {
const {{class_name}}* value,
std::function<void(std::string)> setter) {
string output;
{% for n, attribute_component in enumerate(attribute_components) %}
{% if attribute_component.attribute_name in xml_bundled_components %}
Expand All @@ -48,7 +48,7 @@ void xml_attribute_to_{{attribute_name}}(
{% endif %}
{% endif %}
{% endfor %}
return " " + attribute_name + "=\"" + output + "\"";
setter(output);
}
{% endif %}
{% if exclude_from_protobuf == false %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,24 @@ void xml_attribute_to_{{attribute_name}}(
*is_set = true;
}

string {{attribute_name}}_to_xml_attribute(
const std::string& attribute_name,
void {{attribute_name}}_to_xml_attribute(
XMLWriterState*,
const {{class_name}}* value) {
const {{class_name}}* value,
std::function<void(std::string)> setter) {
{% for n, attribute_component in enumerate(attribute_components) %}
{% for i, value in enumerate(attribute_component.xml_fields) %}
{%-if i == 0 and n == 0:%}
if (*value == {{class_name}}::{{attribute_component.attribute_name}}) {
{% else %}
else if (*value == {{class_name}}::{{attribute_component.attribute_name}}) {
{% endif %}
return " " + attribute_name + "=\"" + "{{value}}" + "\"";
setter("{{value}}");
return;
}
{% endfor %}
{% endfor %}
else {
return " " + attribute_name + "=\"" + "{{class_name}}::{{attribute_components[0].xml_fields[0]}}" + "\"";
setter("{{class_name}}::{{attribute_components[0].xml_fields[0]}}");
}
}
{% if exclude_from_protobuf == false %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ void xml_attribute_to_{{attribute_name}}(
*is_set = true;
}

string {{attribute_name}}_to_xml_attribute(
const std::string& attribute_name,
void {{attribute_name}}_to_xml_attribute(
XMLWriterState*,
const {{class_name}}* value) {
const {{class_name}}* value,
std::function<void(std::string)> setter) {
vector<string> flag_values;
{% for n, attribute_component in enumerate(attribute_components) %}
if (value->{{attribute_component.attribute_name}} == true) {
flag_values.push_back("{{attribute_component.xml_fields[0]}}");
}
{% endfor %}
string output = join(flag_values, ",");
return " " + attribute_name + "=\"" + output + "\"";
setter(output);
}
{% if exclude_from_protobuf == false %}

Expand Down
23 changes: 7 additions & 16 deletions xml_converter/generators/cpp_templates/class_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,24 @@ bool {{cpp_class}}::init_xml_attribute(rapidxml::xml_attribute<>* attribute, vec
}
{% endif %}

vector<string> {{cpp_class}}::as_xml(XMLWriterState* state) const {
vector<string> xml_node_contents;
xml_node_contents.push_back("<{{xml_class_name}} ");
rapidxml::xml_node<char>* {{cpp_class}}::as_xml(XMLWriterState* state) const {
rapidxml::xml_node<char>* xml_node = state->doc->allocate_node(rapidxml::node_element, "{{xml_class_name}}");

{% for attribute_variable in attribute_variables %}
{% if attribute_variable.xml_info.write_to_xml == true %}
if (this->{{attribute_variable.attribute_flag_name}}) {
xml_node_contents.push_back({{attribute_variable.xml_info.serialize_xml_function}}("{{attribute_variable.xml_info.default_xml_field}}", state, &this->{{attribute_variable.attribute_name}}{% for side_effect in attribute_variable.xml_info.serialize_xml_side_effects %}, &(this->{{side_effect}}){% endfor %}));
std::function<void(std::string)> setter = [xml_node, state](std::string val) { xml_node->append_attribute(state->doc->allocate_attribute("{{attribute_variable.xml_info.default_xml_field}}", state->doc->allocate_string(val.c_str()))); };
{{attribute_variable.xml_info.serialize_xml_function}}(state, &this->{{attribute_variable.attribute_name}}{% for side_effect in attribute_variable.xml_info.serialize_xml_side_effects %}, &(this->{{side_effect}}){% endfor %}, setter);
}
{% endif %}
{% endfor %}
{% if cpp_class == "Category" %}
xml_node_contents.push_back(">\n");

for (const auto& [key, val] : this->children) {
string text;
for (const auto& s : val.as_xml(state)) {
text += s;
}

xml_node_contents.push_back("\t" + text);
xml_node->append_node(val.as_xml(state));
}

xml_node_contents.push_back("</MarkerCategory>\n");
{% else %}
xml_node_contents.push_back("/>");
{% endif %}
return xml_node_contents;
return xml_node;
}

// The following attributes are not yet supported in Burrito
Expand Down
2 changes: 1 addition & 1 deletion xml_converter/generators/cpp_templates/class_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class {{cpp_class}} : public Parseable {

void init_from_xml(rapidxml::xml_node<>* node, std::vector<XMLError*>* errors, XMLReaderState* state);
{% endif %}
virtual std::vector<std::string> as_xml(XMLWriterState* state) const;
virtual rapidxml::xml_node<char>* as_xml(XMLWriterState* state) const;
virtual std::string classname();
bool init_xml_attribute(rapidxml::xml_attribute<>* attribute, std::vector<XMLError*>* errors, XMLReaderState* state);
guildpoint::{{cpp_class}} as_protobuf(ProtoWriterState* state) const;
Expand Down
5 changes: 5 additions & 0 deletions xml_converter/generators/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

cd "$(dirname "$0")"
source ../venv/bin/activate
python main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<OverlayData>
<MarkerCategory DisplayName="MyCategory" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
<MarkerCategory DisplayName="MyCategory" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002" IngameVisibility="false"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail Type="mycategory" IngameVisibility="false"/>
<Trail Type="mycategory"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002" IngameVisibility="false"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail Type="mycategory" IngameVisibility="false"/>
<Trail Type="mycategory"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002" MapVisibility="false"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail Type="mycategory" MapVisibility="false"/>
<Trail Type="mycategory"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002" MapVisibility="false"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail Type="mycategory" MapVisibility="false"/>
<Trail Type="mycategory"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002" MinimapVisibility="false"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail Type="mycategory" MinimapVisibility="false"/>
<Trail Type="mycategory"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002" MinimapVisibility="false"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail Type="mycategory" MinimapVisibility="false"/>
<Trail Type="mycategory"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<MarkerCategory DisplayName="Nested Level One" ID="LJKn7WpADjo=" Name="nestedlevelone">
<MarkerCategory DisplayName="Nested Level Two" ID="uJrcuLd4as8=" Name="nestedleveltwo">
<MarkerCategory DisplayName="Nested Level Three" ID="cCxU1IXfiKQ=" Name="nestedlevelthree">
</MarkerCategory>
</MarkerCategory>
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone.nestedleveltwo" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone.nestedleveltwo.nestedlevelthree" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<MarkerCategory DisplayName="Nested Level One" ID="LJKn7WpADjo=" Name="nestedlevelone">
<MarkerCategory DisplayName="Nested Level Two" ID="uJrcuLd4as8=" Name="nestedleveltwo">
<MarkerCategory DisplayName="Nested Level Three" ID="cCxU1IXfiKQ=" Name="nestedlevelthree"/>
</MarkerCategory>
</MarkerCategory>
<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone.nestedleveltwo" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone.nestedleveltwo.nestedlevelthree" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI AchievementBit="0" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementBit="5" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementBit="2147483647" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail AchievementBit="5" Type="mycategory"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI AchievementBit="0" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementBit="5" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementBit="2147483647" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail AchievementBit="5" Type="mycategory"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI AchievementId="0" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="1" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="5" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="2147483647" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="-2147483648" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="-5" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail AchievementId="5" Type="mycategory"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI AchievementId="0" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="1" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="5" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="2147483647" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="-2147483648" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI AchievementId="-5" Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<Trail AchievementId="5" Type="mycategory"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<Trail AnimSpeed="0.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="1.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="0.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="1.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<Trail AnimSpeed="0.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="1.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="0.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="1.000000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-3.140000" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
<Trail AnimSpeed="-123.456001" Type="mycategory" MapID="50" TrailData="037aa160e392f1c8.trl"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<POIs>
<POI Type="mycategory" CanFade="false" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" CanFade="false" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" CanFade="true" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" CanFade="true" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory"/>
<POIs>
<POI Type="mycategory" CanFade="false" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" CanFade="false" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" CanFade="true" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="mycategory" CanFade="true" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>

Loading

0 comments on commit 1873987

Please sign in to comment.