67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#pragma once
|
|
#include "parse/include.hpp"
|
|
#include "parse/character.hpp"
|
|
#include "parse/scene.hpp"
|
|
#include "parse/asset.hpp"
|
|
|
|
namespace Dawn {
|
|
struct HeaderInformation {
|
|
std::vector<std::string> includes;
|
|
std::vector<struct CharacterInformation> characters;
|
|
std::vector<struct AssetInformation> assets;
|
|
std::map<std::string, std::map<std::string, std::string>> languages;
|
|
struct SceneInformation scene;
|
|
};
|
|
|
|
class HeaderParser : public XmlParser<struct HeaderInformation> {
|
|
protected:
|
|
std::vector<std::string> getRequiredAttributes() {
|
|
return std::vector<std::string>();
|
|
}
|
|
|
|
std::map<std::string, std::string> getOptionalAttributes() {
|
|
return std::map<std::string, std::string>();
|
|
}
|
|
|
|
int32_t onParse(
|
|
Xml *node,
|
|
std::map<std::string, std::string> values,
|
|
struct HeaderInformation *out,
|
|
std::string *error
|
|
) {
|
|
int32_t ret = 0;
|
|
auto itChildren = node->children.begin();
|
|
while(itChildren != node->children.end()) {
|
|
auto c = *itChildren;
|
|
|
|
if(c->node == "include") {
|
|
ret = (IncludeParser()).parse(c, &out->includes, error);
|
|
|
|
} else if (c->node == "character") {
|
|
struct CharacterInformation character;
|
|
ret = (CharacterParser()).parse(c, &character, error);
|
|
if(ret != 0) return ret;
|
|
out->characters.push_back(character);
|
|
|
|
} else if(c->node == "asset") {
|
|
struct AssetInformation asset;
|
|
ret = (AssetParser()).parse(c, &asset, error);
|
|
if(ret != 0) return ret;
|
|
out->assets.push_back(asset);
|
|
|
|
} else if(c->node == "scene") {
|
|
ret = (SceneParser()).parse(c, &out->scene, error);
|
|
}
|
|
|
|
if(ret != 0) return ret;
|
|
++itChildren;
|
|
}
|
|
return ret;
|
|
}
|
|
};
|
|
} |