From: Ranjeeth Dasineni Date: Fri, 1 Aug 2014 03:01:24 +0000 (-0700) Subject: rfc: move folly::json::ParseError type to folly/json.h X-Git-Tag: v0.22.0~422 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9633f4758812c7d964df15e5437a603e74c8ec35;p=folly.git rfc: move folly::json::ParseError type to folly/json.h Summary: I don't know why this was in the cpp but seems pretty safe to move it to the .h There are a few files that directly include json.cpp to get around this: https://fburl.com/30544625. I need it for something else and if you dont see a problem I want to move it. Test Plan: unittests Reviewed By: pgriess@fb.com Subscribers: simpkins, doug FB internal diff: D1471958 Tasks: 3623725 --- diff --git a/folly/json.cpp b/folly/json.cpp index cd83b5ad..ddd0afbe 100644 --- a/folly/json.cpp +++ b/folly/json.cpp @@ -256,26 +256,6 @@ private: serialization_opts const& opts_; }; -////////////////////////////////////////////////////////////////////// - -struct ParseError : std::runtime_error { - explicit ParseError(int line) - : std::runtime_error(to("json parse error on line ", line)) - {} - - explicit ParseError(int line, std::string const& context, - std::string const& expected) - : std::runtime_error(to("json parse error on line ", line, - !context.empty() ? to(" near `", context, '\'') - : "", - ": ", expected)) - {} - - explicit ParseError(std::string const& what) - : std::runtime_error("json parse error: " + what) - {} -}; - // Wraps our input buffer with some helper functions. struct Input { explicit Input(StringPiece range, json::serialization_opts const* opts) diff --git a/folly/json.h b/folly/json.h index 89d3b068..5610e1cd 100644 --- a/folly/json.h +++ b/folly/json.h @@ -51,6 +51,27 @@ namespace folly { namespace json { + ////////////////////////////////////////////////////////////////////// + + struct ParseError : std::runtime_error { + explicit ParseError(int line) + : std::runtime_error(to("json parse error on line ", line)) + {} + + explicit ParseError(int line, std::string const& context, + std::string const& expected) + : std::runtime_error(to("json parse error on line ", line, + !context.empty() ? to(" near `", context, '\'') + : "", + ": ", expected)) + {} + + explicit ParseError(std::string const& msg) + : std::runtime_error("json parse error: " + msg) + {} + }; + + struct serialization_opts { explicit serialization_opts() : allow_non_string_keys(false)