// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "VnSceneGen.hpp" using namespace Dawn; std::vector VnSceneGen::getRequiredFlags() { return std::vector{ "input", "output", "language-out" }; } int32_t VnSceneGen::start() { // Open input file. File file(flags["input"]); std::string buffer; if(!file.readString(&buffer)) { std::cout << "Failed to read scene " << 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 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 scene output dir" << std::endl; return 1; } if(!fileOut.writeString(bufferOut)) { std::cout << "Failed to generate scene " << fileOut.filename << std::endl; return 1; } // Now dump out the language strings to be picked up later. ret = languageSaveStrings(flags["language-out"], info.strings); if(ret != 0) return ret; return 0; }