- Treballant en el deserialitzador

This commit is contained in:
2025-11-25 13:42:31 +01:00
parent d727a88aa7
commit 39906bc01d
3 changed files with 168 additions and 5 deletions

View File

@@ -1,9 +1,20 @@
#include <iostream>
#include "yamal.hpp"
std::string readFileToString(const std::string& filename) {
std::ifstream ifs(filename);
if (!ifs) {
throw std::runtime_error("Cannot open file: " + filename);
}
std::ostringstream oss;
oss << ifs.rdbuf(); // dump the whole stream buffer into oss
return oss.str();
}
int main(int argc, char* argv[]) {
yamal root;
root["room"]["name"] = "THE JAIL";
yamal root = yamal_parser::parse(readFileToString("test.yaml"));
/*root["room"]["name"] = "THE JAIL";
root["room"]["name"].setQuoted(true);
root["room"]["bgColor"] = "bright_blue";
root["room"]["connections"]["up"] = "null";
@@ -40,7 +51,7 @@ int main(int argc, char* argv[]) {
root["room"].setBlankLine(false);
root["tilemap"].setComment("Tilemap: 16 filas x 32 columnas (256x192 píxeles @ 8px/tile)");
root["tilemap"].appendComment("Índices de tiles (-1 = vacío)");
root["room"]["bgColor"].setInlineComment("Azul oscuro");
root["room"]["bgColor"].setInlineComment("Azul oscuro");*/
std::cout << root.serialize() << std::endl;
return 0;