Moved C++ tools out
This commit is contained in:
41
archive/dawntools/util/parser/SceneCodeParser.cpp
Normal file
41
archive/dawntools/util/parser/SceneCodeParser.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "SceneCodeParser.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
std::vector<std::string> SceneCodeParser::getRequiredAttributes() {
|
||||
return { "type" };
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> SceneCodeParser::getOptionalAttributes() {
|
||||
return {};
|
||||
}
|
||||
|
||||
int32_t SceneCodeParser::onParse(
|
||||
Xml *node,
|
||||
std::map<std::string, std::string> values,
|
||||
struct SceneCode *out,
|
||||
std::string *error
|
||||
) {
|
||||
// Get the type
|
||||
std::string type = values["type"];
|
||||
if(type == "properties") {
|
||||
out->codeType = SCENE_CODE_TYPE_PROPERTIES;
|
||||
} else if(type == "init") {
|
||||
out->codeType = SCENE_CODE_TYPE_INIT;
|
||||
} else if(type == "include") {
|
||||
out->codeType = SCENE_CODE_TYPE_INCLUDE;
|
||||
} else {
|
||||
*error = "Invalid type '" + type + "' for SceneCode.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the code
|
||||
out->code = node->textContent;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user