From 7cba9b84962f1a0b046610295b0a9c12461d9fa2 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 4 Jul 2011 16:24:48 +1000 Subject: [PATCH] Json now parses from slurped strings, not mmap mmap was a debatable choice in the first place, and is annoying under Windows, so we may as well remove it. --- json.cpp.rl | 12 ++++++------ json.hpp | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/json.cpp.rl b/json.cpp.rl index 3435483f..eff3755d 100644 --- a/json.cpp.rl +++ b/json.cpp.rl @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -236,13 +235,14 @@ struct parse_context { namespace json { json::node * - parse (const boost::filesystem::path &path) { - mapped_file file(path); - return parse ((const char *)file.data (), - (const char *)file.data () + file.size ()); - } + parse (const boost::filesystem::path &path) + { return parse ((const char *)slurp (path)); } + json::node * + parse (const std::string &path) + { return parse (path.c_str (), path.c_str () + path.size ()); } + node * parse (const char *start, const char *stop) { diff --git a/json.hpp b/json.hpp index a2191a6e..061089e5 100644 --- a/json.hpp +++ b/json.hpp @@ -40,6 +40,7 @@ namespace json { extern node* parse (const boost::filesystem::path &path); extern node* parse (const char *start, const char *stop); extern node* parse (const char *start); + extern node* parse (const std::string&); /// Abstract base for all JSON values class node {