refactor json_value into separate header and reduce include
bloat
This commit is contained in:
parent
b5b6548a81
commit
7affd45511
6 changed files with 70 additions and 64 deletions
|
@ -26,7 +26,7 @@
|
||||||
#include <mapnik/value/types.hpp>
|
#include <mapnik/value/types.hpp>
|
||||||
#include <mapnik/util/variant.hpp>
|
#include <mapnik/util/variant.hpp>
|
||||||
#include <mapnik/json/value_converters.hpp>
|
#include <mapnik/json/value_converters.hpp>
|
||||||
|
#include <mapnik/json/json_value.hpp>
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/include/qi.hpp>
|
||||||
|
@ -43,35 +43,6 @@ namespace standard = boost::spirit::standard;
|
||||||
namespace phoenix = boost::phoenix;
|
namespace phoenix = boost::phoenix;
|
||||||
using space_type = standard::space_type;
|
using space_type = standard::space_type;
|
||||||
|
|
||||||
struct json_value;
|
|
||||||
|
|
||||||
using json_array = std::vector<json_value>;
|
|
||||||
using json_object_element = std::pair<std::string, json_value>;
|
|
||||||
using json_object = std::vector<json_object_element>;
|
|
||||||
using json_value_base = mapnik::util::variant<value_null,
|
|
||||||
value_bool,
|
|
||||||
value_integer,
|
|
||||||
value_double,
|
|
||||||
std::string,
|
|
||||||
json_array,
|
|
||||||
json_object>;
|
|
||||||
struct json_value : json_value_base
|
|
||||||
{
|
|
||||||
#if __cpp_inheriting_constructors >= 200802
|
|
||||||
|
|
||||||
using json_value_base::json_value_base;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
json_value() = default;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
json_value(T && val)
|
|
||||||
: json_value_base(std::forward<T>(val)) {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
using uchar = std::uint32_t; // a unicode code point
|
using uchar = std::uint32_t; // a unicode code point
|
||||||
|
|
||||||
// unicode string grammar via boost/libs/spirit/example/qi/json/json/parser/grammar.hpp
|
// unicode string grammar via boost/libs/spirit/example/qi/json/json/parser/grammar.hpp
|
||||||
|
|
|
@ -23,9 +23,7 @@
|
||||||
#ifndef MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP
|
#ifndef MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP
|
||||||
#define MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP
|
#define MAPNIK_JSON_GENERIC_JSON_GRAMMAR_X3_HPP
|
||||||
|
|
||||||
#include <mapnik/value/types.hpp>
|
#include <mapnik/json/json_value.hpp>
|
||||||
#include <mapnik/util/variant.hpp>
|
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
#include <boost/spirit/home/x3.hpp>
|
#include <boost/spirit/home/x3.hpp>
|
||||||
|
@ -37,35 +35,6 @@ namespace mapnik { namespace json {
|
||||||
|
|
||||||
namespace x3 = boost::spirit::x3;
|
namespace x3 = boost::spirit::x3;
|
||||||
|
|
||||||
struct json_value;
|
|
||||||
|
|
||||||
using json_array = std::vector<json_value>;
|
|
||||||
using json_object_element = std::pair<std::string, json_value>;
|
|
||||||
using json_object = std::vector<json_object_element>;
|
|
||||||
using json_value_base = mapnik::util::variant<value_null,
|
|
||||||
value_bool,
|
|
||||||
value_integer,
|
|
||||||
value_double,
|
|
||||||
std::string,
|
|
||||||
json_array,
|
|
||||||
json_object>;
|
|
||||||
struct json_value : json_value_base
|
|
||||||
{
|
|
||||||
#if __cpp_inheriting_constructors >= 200802
|
|
||||||
|
|
||||||
using json_value_base::json_value_base;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
json_value() = default;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
json_value(T && val)
|
|
||||||
: json_value_base(std::forward<T>(val)) {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace grammar {
|
namespace grammar {
|
||||||
|
|
||||||
using generic_json_grammar_type = x3::rule<class generic_json_tag, json_value>;
|
using generic_json_grammar_type = x3::rule<class generic_json_tag, json_value>;
|
||||||
|
|
65
include/mapnik/json/json_value.hpp
Normal file
65
include/mapnik/json/json_value.hpp
Normal file
|
@ -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 <mapnik/value/types.hpp>
|
||||||
|
#include <mapnik/util/variant.hpp>
|
||||||
|
// stl
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace mapnik { namespace json {
|
||||||
|
|
||||||
|
struct json_value;
|
||||||
|
|
||||||
|
using json_array = std::vector<json_value>;
|
||||||
|
using json_object_element = std::pair<std::string, json_value>;
|
||||||
|
using json_object = std::vector<json_object_element>;
|
||||||
|
using json_value_base = mapnik::util::variant<value_null,
|
||||||
|
value_bool,
|
||||||
|
value_integer,
|
||||||
|
value_double,
|
||||||
|
std::string,
|
||||||
|
json_array,
|
||||||
|
json_object>;
|
||||||
|
struct json_value : json_value_base
|
||||||
|
{
|
||||||
|
#if __cpp_inheriting_constructors >= 200802
|
||||||
|
|
||||||
|
using json_value_base::json_value_base;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
json_value() = default;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
json_value(T && val)
|
||||||
|
: json_value_base(std::forward<T>(val)) {}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // MAPNIK_JSON_JSON_VALUE_HPP
|
|
@ -24,7 +24,7 @@
|
||||||
#define MAPNIK_JSON_STRINGIFIER_HPP
|
#define MAPNIK_JSON_STRINGIFIER_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/json/generic_json.hpp>
|
#include <mapnik/json/json_value.hpp>
|
||||||
#include <mapnik/util/conversions.hpp>
|
#include <mapnik/util/conversions.hpp>
|
||||||
#include <mapnik/util/variant.hpp>
|
#include <mapnik/util/variant.hpp>
|
||||||
// stl
|
// stl
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/json/error_handler.hpp>
|
#include <mapnik/json/error_handler.hpp>
|
||||||
#include <mapnik/json/topology.hpp>
|
#include <mapnik/json/topology.hpp>
|
||||||
|
#include <mapnik/json/generic_json.hpp>
|
||||||
#include <mapnik/json/value_converters.hpp>
|
#include <mapnik/json/value_converters.hpp>
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef MAPNIK_TOPOLOGY_HPP
|
#ifndef MAPNIK_TOPOLOGY_HPP
|
||||||
#define MAPNIK_TOPOLOGY_HPP
|
#define MAPNIK_TOPOLOGY_HPP
|
||||||
|
|
||||||
#include <mapnik/json/generic_json.hpp>
|
#include <mapnik/json/json_value.hpp>
|
||||||
#include <mapnik/util/variant.hpp>
|
#include <mapnik/util/variant.hpp>
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
|
Loading…
Reference in a new issue