This commit is contained in:
2023-03-09 22:52:22 -08:00
parent c3ade0936a
commit 7e09b1760e
17 changed files with 453 additions and 423 deletions

View File

@ -0,0 +1,57 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "UIGen.hpp"
using namespace Dawn;
std::vector<std::string> UIGen::getRequiredFlags() {
return std::vector<std::string>{ "input", "output" };
}
int32_t UIGen::start() {
// Open input file.
File file(flags["input"]);
std::string buffer;
if(!file.readString(&buffer)) {
std::cout << "Failed to read " << file.filename << std::endl;
return 1;
}
// Parse XML
Xml xml = Xml::load(buffer);
std::string error;
struct RootInformation info;
auto ret = (RootParser()).parse(&xml, &info, &error);
if(ret != 0) {
std::cout << error << std::endl;
return ret;
}
// std::vector<std::string> lines;
// RootGen::generate(&lines, &info, "");
// // Generate buffer
// std::string bufferOut;
// auto itLine = lines.begin();
// while(itLine != lines.end()) {
// bufferOut += *itLine + "\n";
// ++itLine;
// }
// // Finished with XML data, now we can write data out.
File fileOut(flags["output"] + ".hpp");
if(!fileOut.mkdirp()) {
std::cout << "Failed to make ui output dir" << std::endl;
return 1;
}
// if(!fileOut.writeString(bufferOut)) {
// std::cout << "Failed to generate scene " << fileOut.filename << std::endl;
// return 1;
// }
return 0;
}