Working on parser

This commit is contained in:
2023-04-23 18:46:03 -07:00
parent c269841236
commit 3be64a40e7
12 changed files with 232 additions and 5 deletions

View File

@ -8,4 +8,5 @@ target_sources(vnscenetool
PRIVATE
VNPositionEventParser.cpp
VNTextEventParser.cpp
VNSetEventParser.cpp
)

View File

@ -0,0 +1,45 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNSetEventParser.hpp"
using namespace Dawn;
std::vector<std::string> VNSetEventParser::getRequiredAttributes() {
return { "property", "type" };
}
std::map<std::string, std::string> VNSetEventParser::getOptionalAttributes() {
return {
{ "to", "" },
{ "value", "" },
{ "from", "" },
{ "duration", "" },
{ "curve", "" }
};
}
int32_t VNSetEventParser::onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNSetEvent *out,
std::string *error
) {
if(values["to"] != "") {
out->to = values["to"];
} else if(values["value"] != "") {
out->to = values["value"];
} else {
*error = "Either 'to' or 'value' must be specified";
return -1;
}
out->type = values["type"];
out->property = values["property"];
out->from = values["from"];
out->duration = values["duration"];
out->curve = values["curve"];
return 0;
}

View File

@ -0,0 +1,30 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "util/XmlParser.hpp"
namespace Dawn {
struct VNSetEvent {
std::string property = "";
std::string to = "";
std::string from = "";
std::string duration = "";
std::string curve = "";
std::string type = "";
};
class VNSetEventParser : public XmlParser<struct VNSetEvent> {
protected:
std::vector<std::string> getRequiredAttributes() override;
std::map<std::string, std::string> getOptionalAttributes() override;
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNSetEvent *out,
std::string *error
) override;
};
}