From 505ed38a501ac121d5692fed0be5d8fa64f9d3f4 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sat, 28 Apr 2012 14:58:49 +0200 Subject: [PATCH] Include basic embed code generation in the HTTP connector. Closes #23, #24 and #25. --- util/json.cpp | 11 +++++++++++ util/json.h | 1 + 2 files changed, 12 insertions(+) diff --git a/util/json.cpp b/util/json.cpp index d4b3efc4..e8e12641 100644 --- a/util/json.cpp +++ b/util/json.cpp @@ -2,6 +2,7 @@ #include "json.h" #include +#include int JSON::Value::c2hex(int c){ if (c >= '0' && c <= '9') return c - '0'; @@ -423,3 +424,13 @@ JSON::Value JSON::fromString(std::string json){ std::istringstream is(json); return JSON::Value(is); } + +/// Converts a file to a JSON::Value. +JSON::Value JSON::fromFile(std::string filename){ + std::string Result; + std::ifstream File; + File.open(filename.c_str()); + while (File.good()){Result += File.get();} + File.close( ); + return fromString(Result); +} diff --git a/util/json.h b/util/json.h index 8de01e11..047178cd 100644 --- a/util/json.h +++ b/util/json.h @@ -69,5 +69,6 @@ namespace JSON{ }; Value fromString(std::string json); + Value fromFile(std::string filename); };