From 7affd45511cfa7965f24cfc71025be1140d97ff3 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 15 Dec 2016 11:29:29 +0100 Subject: [PATCH] refactor json_value into separate header and reduce `include` bloat --- include/mapnik/json/generic_json.hpp | 31 +-------- .../mapnik/json/generic_json_grammar_x3.hpp | 33 +--------- include/mapnik/json/json_value.hpp | 65 +++++++++++++++++++ include/mapnik/json/stringifier.hpp | 2 +- include/mapnik/json/topojson_grammar.hpp | 1 + include/mapnik/json/topology.hpp | 2 +- 6 files changed, 70 insertions(+), 64 deletions(-) create mode 100644 include/mapnik/json/json_value.hpp diff --git a/include/mapnik/json/generic_json.hpp b/include/mapnik/json/generic_json.hpp index 9a70237bc..eea6dd993 100644 --- a/include/mapnik/json/generic_json.hpp +++ b/include/mapnik/json/generic_json.hpp @@ -26,7 +26,7 @@ #include #include #include - +#include #pragma GCC diagnostic push #include #include @@ -43,35 +43,6 @@ namespace standard = boost::spirit::standard; namespace phoenix = boost::phoenix; using space_type = standard::space_type; -struct json_value; - -using json_array = std::vector; -using json_object_element = std::pair; -using json_object = std::vector; -using json_value_base = mapnik::util::variant; -struct json_value : json_value_base -{ -#if __cpp_inheriting_constructors >= 200802 - - using json_value_base::json_value_base; - -#else - - json_value() = default; - - template - json_value(T && val) - : json_value_base(std::forward(val)) {} - -#endif -}; - using uchar = std::uint32_t; // a unicode code point // unicode string grammar via boost/libs/spirit/example/qi/json/json/parser/grammar.hpp diff --git a/include/mapnik/json/generic_json_grammar_x3.hpp b/include/mapnik/json/generic_json_grammar_x3.hpp index 4d633cf9e..a1064bdeb 100644 --- a/include/mapnik/json/generic_json_grammar_x3.hpp +++ b/include/mapnik/json/generic_json_grammar_x3.hpp @@ -23,9 +23,7 @@ #ifndef MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP #define MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP -#include -#include - +#include #pragma GCC diagnostic push #include #include @@ -37,35 +35,6 @@ namespace mapnik { namespace json { namespace x3 = boost::spirit::x3; -struct json_value; - -using json_array = std::vector; -using json_object_element = std::pair; -using json_object = std::vector; -using json_value_base = mapnik::util::variant; -struct json_value : json_value_base -{ -#if __cpp_inheriting_constructors >= 200802 - - using json_value_base::json_value_base; - -#else - - json_value() = default; - - template - json_value(T && val) - : json_value_base(std::forward(val)) {} - -#endif -}; - namespace grammar { using generic_json_grammar_type = x3::rule; diff --git a/include/mapnik/json/json_value.hpp b/include/mapnik/json/json_value.hpp new file mode 100644 index 000000000..8d6c1b09a --- /dev/null +++ b/include/mapnik/json/json_value.hpp @@ -0,0 +1,65 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2016 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_JSON_JSON_VALUE_HPP +#define MAPNIK_JSON_JSON_VALUE_HPP + +// mapnik +#include +#include +// stl +#include +#include + +namespace mapnik { namespace json { + +struct json_value; + +using json_array = std::vector; +using json_object_element = std::pair; +using json_object = std::vector; +using json_value_base = mapnik::util::variant; +struct json_value : json_value_base +{ +#if __cpp_inheriting_constructors >= 200802 + + using json_value_base::json_value_base; + +#else + + json_value() = default; + + template + json_value(T && val) + : json_value_base(std::forward(val)) {} + +#endif +}; +}} + +#endif // MAPNIK_JSON_JSON_VALUE_HPP diff --git a/include/mapnik/json/stringifier.hpp b/include/mapnik/json/stringifier.hpp index 44b9425d8..af5a39778 100644 --- a/include/mapnik/json/stringifier.hpp +++ b/include/mapnik/json/stringifier.hpp @@ -24,7 +24,7 @@ #define MAPNIK_JSON_STRINGIFIER_HPP // mapnik -#include +#include #include #include // stl diff --git a/include/mapnik/json/topojson_grammar.hpp b/include/mapnik/json/topojson_grammar.hpp index 1317fd3a9..5139b5c6c 100644 --- a/include/mapnik/json/topojson_grammar.hpp +++ b/include/mapnik/json/topojson_grammar.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include #pragma GCC diagnostic push diff --git a/include/mapnik/json/topology.hpp b/include/mapnik/json/topology.hpp index 048c85528..b45789b9e 100644 --- a/include/mapnik/json/topology.hpp +++ b/include/mapnik/json/topology.hpp @@ -23,7 +23,7 @@ #ifndef MAPNIK_TOPOLOGY_HPP #define MAPNIK_TOPOLOGY_HPP -#include +#include #include #pragma GCC diagnostic push