Dawn/archive/dawntools/vnscenetool/events/VNMarkerParser.cpp
2023-10-31 21:15:03 -05:00

32 lines
811 B
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNMarkerParser.hpp"
using namespace Dawn;
std::vector<std::string> VNMarkerParser::getRequiredAttributes() {
return { "name" };
}
std::map<std::string, std::string> VNMarkerParser::getOptionalAttributes() {
return {};
}
int32_t VNMarkerParser::onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNMarker *out,
std::string *error
) {
// Ensure name only contains letters, and numbers, no spaces or symbols
if(!std::regex_match(values["name"], std::regex("^[a-zA-Z0-9]+$"))) {
*error = "Marker name " + values["name"] + " must only contain letters and numbers.";
return -1;
}
out->name = values["name"];
return 0;
}