1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Added a new json constructor to read from a file.

This commit is contained in:
Frank Zago
2011-08-20 01:04:59 +00:00
parent 8054c85091
commit f6c39eed0c
2 changed files with 14 additions and 2 deletions

View File

@@ -4,6 +4,7 @@
#include <assert.h>
#include <fstream>
#include <sstream>
#include <iostream>
const JsonNode JsonNode::nullNode;
@@ -19,6 +20,15 @@ JsonNode::JsonNode(std::string input):
JsonParser parser(input, *this);
}
JsonNode::JsonNode(const char *filename)
{
std::ifstream file(filename);
std::string str((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
JsonParser parser(str, *this);
}
JsonNode::JsonNode(const JsonNode &copy):
type(DATA_NULL)
{