Working on parser
This commit is contained in:
@ -8,4 +8,5 @@ target_sources(vnscenetool
|
||||
PRIVATE
|
||||
VNPositionEventParser.cpp
|
||||
VNTextEventParser.cpp
|
||||
VNSetEventParser.cpp
|
||||
)
|
45
src/dawntools/vnscenetool/events/VNSetEventParser.cpp
Normal file
45
src/dawntools/vnscenetool/events/VNSetEventParser.cpp
Normal 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;
|
||||
}
|
30
src/dawntools/vnscenetool/events/VNSetEventParser.hpp
Normal file
30
src/dawntools/vnscenetool/events/VNSetEventParser.hpp
Normal 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;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user