// 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 SceneCodeParser::getRequiredAttributes() { return { "type" }; } std::map SceneCodeParser::getOptionalAttributes() { return {}; } int32_t SceneCodeParser::onParse( Xml *node, std::map 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; }