Just breaking stuff
This commit is contained in:
59
archive/vnscenegen/parse/include.hpp
Normal file
59
archive/vnscenegen/parse/include.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "util/XmlParser.hpp"
|
||||
#include "util/CodeGen.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
typedef std::vector<std::string> include_t;
|
||||
|
||||
class IncludeParser : public XmlParser<include_t> {
|
||||
protected:
|
||||
std::vector<std::string> getRequiredAttributes() {
|
||||
return std::vector<std::string>{
|
||||
"path"
|
||||
};
|
||||
}
|
||||
|
||||
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,
|
||||
include_t *out,
|
||||
std::string *error
|
||||
) {
|
||||
if(values["path"].size() == 0) {
|
||||
*error = "";
|
||||
return 1;
|
||||
}
|
||||
|
||||
out->push_back(values["path"]);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class IncludeGen : public CodeGen {
|
||||
public:
|
||||
static void generate(
|
||||
std::vector<std::string> *out,
|
||||
include_t includes,
|
||||
std::string tabs
|
||||
) {
|
||||
std::vector<std::string> generated;
|
||||
auto it = includes.begin();
|
||||
while(it != includes.end()) {
|
||||
if(std::find(generated.begin(), generated.end(), *it) == generated.end()) {
|
||||
line(out, "#include \"" + *it + "\"", tabs);
|
||||
generated.push_back(*it);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user