From 79b9bdf7ce2771e002c1b3073749642ab2683a72 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 18 Feb 2015 10:46:40 +0100 Subject: [PATCH] rename JSON namespace to osrm::json to avoid namespace clash with V8 --- algorithms/polyline_formatter.cpp | 10 +++--- algorithms/polyline_formatter.hpp | 4 +-- descriptors/description_factory.cpp | 2 +- descriptors/description_factory.hpp | 2 +- descriptors/descriptor_base.hpp | 2 +- descriptors/gpx_descriptor.hpp | 16 ++++----- descriptors/json_descriptor.hpp | 55 +++++++++++++++-------------- extract.cpp | 2 ++ include/osrm/json_container.hpp | 12 ++++--- library/osrm.hpp | 7 ++-- library/osrm_impl.cpp | 4 +-- library/osrm_impl.hpp | 2 +- plugins/distance_table.hpp | 8 ++--- plugins/hello_world.hpp | 10 +++--- plugins/locate.hpp | 4 +-- plugins/nearest.hpp | 10 +++--- plugins/plugin_base.hpp | 17 +++++---- plugins/timestamp.hpp | 2 +- plugins/viaroute.hpp | 2 +- server/request_handler.cpp | 12 +++---- tools/simpleclient.cpp | 4 +-- util/json_renderer.hpp | 10 +++--- util/string_util.hpp | 2 +- util/xml_renderer.hpp | 8 +++-- 24 files changed, 109 insertions(+), 98 deletions(-) diff --git a/algorithms/polyline_formatter.cpp b/algorithms/polyline_formatter.cpp index 22a1df369..b5dad6c78 100644 --- a/algorithms/polyline_formatter.cpp +++ b/algorithms/polyline_formatter.cpp @@ -32,21 +32,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -JSON::String +osrm::json::String PolylineFormatter::printEncodedString(const std::vector &polyline) const { - return JSON::String(PolylineCompressor().get_encoded_string(polyline)); + return osrm::json::String(PolylineCompressor().get_encoded_string(polyline)); } -JSON::Array +osrm::json::Array PolylineFormatter::printUnencodedString(const std::vector &polyline) const { - JSON::Array json_geometry_array; + osrm::json::Array json_geometry_array; for (const auto &segment : polyline) { if (segment.necessary) { - JSON::Array json_coordinate; + osrm::json::Array json_coordinate; json_coordinate.values.push_back(segment.location.lat / COORDINATE_PRECISION); json_coordinate.values.push_back(segment.location.lon / COORDINATE_PRECISION); json_geometry_array.values.push_back(json_coordinate); diff --git a/algorithms/polyline_formatter.hpp b/algorithms/polyline_formatter.hpp index e4018154d..181a0cf15 100644 --- a/algorithms/polyline_formatter.hpp +++ b/algorithms/polyline_formatter.hpp @@ -37,9 +37,9 @@ struct SegmentInformation; struct PolylineFormatter { - JSON::String printEncodedString(const std::vector &polyline) const; + osrm::json::String printEncodedString(const std::vector &polyline) const; - JSON::Array printUnencodedString(const std::vector &polyline) const; + osrm::json::Array printUnencodedString(const std::vector &polyline) const; }; #endif /* POLYLINE_FORMATTER_HPP */ diff --git a/descriptors/description_factory.cpp b/descriptors/description_factory.cpp index 034dc88ae..4d9918759 100644 --- a/descriptors/description_factory.cpp +++ b/descriptors/description_factory.cpp @@ -98,7 +98,7 @@ void DescriptionFactory::AppendSegment(const FixedPointCoordinate &coordinate, turn, path_point.travel_mode); } -JSON::Value DescriptionFactory::AppendGeometryString(const bool return_encoded) +osrm::json::Value DescriptionFactory::AppendGeometryString(const bool return_encoded) { if (return_encoded) { diff --git a/descriptors/description_factory.hpp b/descriptors/description_factory.hpp index 2b377f687..7f975e030 100644 --- a/descriptors/description_factory.hpp +++ b/descriptors/description_factory.hpp @@ -85,7 +85,7 @@ class DescriptionFactory void SetEndSegment(const PhantomNode &start_phantom, const bool traversed_in_reverse, const bool is_via_location = false); - JSON::Value AppendGeometryString(const bool return_encoded); + osrm::json::Value AppendGeometryString(const bool return_encoded); std::vector const &GetViaIndices() const; double get_entire_length() const { return entire_length; } diff --git a/descriptors/descriptor_base.hpp b/descriptors/descriptor_base.hpp index 815b1d5af..0526047fe 100644 --- a/descriptors/descriptor_base.hpp +++ b/descriptors/descriptor_base.hpp @@ -78,7 +78,7 @@ template class BaseDescriptor BaseDescriptor() {} // Maybe someone can explain the pure virtual destructor thing to me (dennis) virtual ~BaseDescriptor() {} - virtual void Run(const InternalRouteResult &raw_route, JSON::Object &json_result) = 0; + virtual void Run(const InternalRouteResult &raw_route, osrm::json::Object &json_result) = 0; virtual void SetConfig(const DescriptorConfig &c) = 0; }; diff --git a/descriptors/gpx_descriptor.hpp b/descriptors/gpx_descriptor.hpp index 384d2c2e9..deda9c52f 100644 --- a/descriptors/gpx_descriptor.hpp +++ b/descriptors/gpx_descriptor.hpp @@ -41,11 +41,11 @@ template class GPXDescriptor final : public BaseDescriptor class GPXDescriptor final : public BaseDescriptor class GPXDescriptor final : public BaseDescriptor class GPXDescriptor final : public BaseDescriptor class JSONDescriptor final : public BaseDescriptor< return added_element_count; } - virtual void Run(const InternalRouteResult &raw_route, JSON::Object &json_result) override final + virtual void Run(const InternalRouteResult &raw_route, + osrm::json::Object &json_result) override final { if (INVALID_EDGE_WEIGHT == raw_route.shortest_path_length) { // We do not need to do much, if there is no route ;-) json_result.values["status"] = 207; json_result.values["status_message"] = "Cannot find route between points"; - // JSON::render(reply.content, json_result); + // osrm::json::render(reply.content, json_result); return; } @@ -139,20 +140,20 @@ template class JSONDescriptor final : public BaseDescriptor< if (config.geometry) { - JSON::Value route_geometry = + osrm::json::Value route_geometry = description_factory.AppendGeometryString(config.encode_geometry); json_result.values["route_geometry"] = route_geometry; } if (config.instructions) { - JSON::Array json_route_instructions; + osrm::json::Array json_route_instructions; BuildTextualDescription(description_factory, json_route_instructions, raw_route.shortest_path_length, shortest_path_segments); json_result.values["route_instructions"] = json_route_instructions; } description_factory.BuildRouteSummary(description_factory.get_entire_length(), raw_route.shortest_path_length); - JSON::Object json_route_summary; + osrm::json::Object json_route_summary; json_route_summary.values["total_distance"] = description_factory.summary.distance; json_route_summary.values["total_time"] = description_factory.summary.duration; json_route_summary.values["start_point"] = @@ -163,8 +164,8 @@ template class JSONDescriptor final : public BaseDescriptor< BOOST_ASSERT(!raw_route.segment_end_coordinates.empty()); - JSON::Array json_via_points_array; - JSON::Array json_first_coordinate; + osrm::json::Array json_via_points_array; + osrm::json::Array json_first_coordinate; json_first_coordinate.values.push_back( raw_route.segment_end_coordinates.front().source_phantom.location.lat / COORDINATE_PRECISION); @@ -175,7 +176,7 @@ template class JSONDescriptor final : public BaseDescriptor< for (const PhantomNodes &nodes : raw_route.segment_end_coordinates) { std::string tmp; - JSON::Array json_coordinate; + osrm::json::Array json_coordinate; json_coordinate.values.push_back(nodes.target_phantom.location.lat / COORDINATE_PRECISION); json_coordinate.values.push_back(nodes.target_phantom.location.lon / @@ -184,7 +185,7 @@ template class JSONDescriptor final : public BaseDescriptor< } json_result.values["via_points"] = json_via_points_array; - JSON::Array json_via_indices_array; + osrm::json::Array json_via_indices_array; std::vector const &shortest_leg_end_indices = description_factory.GetViaIndices(); json_via_indices_array.values.insert(json_via_indices_array.values.end(), @@ -195,7 +196,7 @@ template class JSONDescriptor final : public BaseDescriptor< // only one alternative route is computed at this time, so this is hardcoded if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length) { - json_result.values["found_alternative"] = JSON::True(); + json_result.values["found_alternative"] = osrm::json::True(); BOOST_ASSERT(!raw_route.alt_source_traversed_in_reverse.empty()); alternate_description_factory.SetStartSegment( raw_route.segment_end_coordinates.front().source_phantom, @@ -213,15 +214,15 @@ template class JSONDescriptor final : public BaseDescriptor< if (config.geometry) { - JSON::Value alternate_geometry_string = + osrm::json::Value alternate_geometry_string = alternate_description_factory.AppendGeometryString(config.encode_geometry); - JSON::Array json_alternate_geometries_array; + osrm::json::Array json_alternate_geometries_array; json_alternate_geometries_array.values.push_back(alternate_geometry_string); json_result.values["alternative_geometries"] = json_alternate_geometries_array; } // Generate instructions for each alternative (simulated here) - JSON::Array json_alt_instructions; - JSON::Array json_current_alt_instructions; + osrm::json::Array json_alt_instructions; + osrm::json::Array json_current_alt_instructions; if (config.instructions) { BuildTextualDescription( @@ -234,8 +235,8 @@ template class JSONDescriptor final : public BaseDescriptor< alternate_description_factory.get_entire_length(), raw_route.alternative_path_length); - JSON::Object json_alternate_route_summary; - JSON::Array json_alternate_route_summary_array; + osrm::json::Object json_alternate_route_summary; + osrm::json::Array json_alternate_route_summary_array; json_alternate_route_summary.values["total_distance"] = alternate_description_factory.summary.distance; json_alternate_route_summary.values["total_time"] = @@ -249,7 +250,7 @@ template class JSONDescriptor final : public BaseDescriptor< std::vector const &alternate_leg_end_indices = alternate_description_factory.GetViaIndices(); - JSON::Array json_altenative_indices_array; + osrm::json::Array json_altenative_indices_array; json_altenative_indices_array.values.insert(json_altenative_indices_array.values.end(), alternate_leg_end_indices.begin(), alternate_leg_end_indices.end()); @@ -257,30 +258,30 @@ template class JSONDescriptor final : public BaseDescriptor< } else { - json_result.values["found_alternative"] = JSON::False(); + json_result.values["found_alternative"] = osrm::json::False(); } // Get Names for both routes RouteNames route_names = GenerateRouteNames(shortest_path_segments, alternative_path_segments, facade); - JSON::Array json_route_names; + osrm::json::Array json_route_names; json_route_names.values.push_back(route_names.shortest_path_name_1); json_route_names.values.push_back(route_names.shortest_path_name_2); json_result.values["route_name"] = json_route_names; if (INVALID_EDGE_WEIGHT != raw_route.alternative_path_length) { - JSON::Array json_alternate_names_array; - JSON::Array json_alternate_names; + osrm::json::Array json_alternate_names_array; + osrm::json::Array json_alternate_names; json_alternate_names.values.push_back(route_names.alternative_path_name_1); json_alternate_names.values.push_back(route_names.alternative_path_name_2); json_alternate_names_array.values.push_back(json_alternate_names); json_result.values["alternative_names"] = json_alternate_names_array; } - JSON::Object json_hint_object; + osrm::json::Object json_hint_object; json_hint_object.values["checksum"] = facade->GetCheckSum(); - JSON::Array json_location_hint_array; + osrm::json::Array json_location_hint_array; std::string hint; for (const auto i : osrm::irange(0, raw_route.segment_end_coordinates.size())) { @@ -296,14 +297,14 @@ template class JSONDescriptor final : public BaseDescriptor< // render the content to the output array // TIMER_START(route_render); - // JSON::render(reply.content, json_result); + // osrm::json::render(reply.content, json_result); // TIMER_STOP(route_render); // SimpleLogger().Write(logDEBUG) << "rendering took: " << TIMER_MSEC(route_render); } // TODO: reorder parameters inline void BuildTextualDescription(DescriptionFactory &description_factory, - JSON::Array &json_instruction_array, + osrm::json::Array &json_instruction_array, const int route_length, std::vector &route_segments_list) { @@ -317,7 +318,7 @@ template class JSONDescriptor final : public BaseDescriptor< // Fetch data from Factory and generate a string from it. for (const SegmentInformation &segment : description_factory.path_description) { - JSON::Array json_instruction_row; + osrm::json::Array json_instruction_row; TurnInstruction current_instruction = segment.turn_instruction; entered_restricted_area_count += (current_instruction != segment.turn_instruction); if (TurnInstructionsClass::TurnIsNecessary(current_instruction)) @@ -377,7 +378,7 @@ template class JSONDescriptor final : public BaseDescriptor< } } - JSON::Array json_last_instruction_row; + osrm::json::Array json_last_instruction_row; temp_instruction = cast::integral_to_string( cast::enum_to_underlying(TurnInstruction::ReachedYourDestination)); json_last_instruction_row.values.push_back(temp_instruction); diff --git a/extract.cpp b/extract.cpp index b1f30a6ad..cb953a566 100644 --- a/extract.cpp +++ b/extract.cpp @@ -31,6 +31,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include + int main(int argc, char *argv[]) { try diff --git a/include/osrm/json_container.hpp b/include/osrm/json_container.hpp index 9bbbec433..4ec164965 100644 --- a/include/osrm/json_container.hpp +++ b/include/osrm/json_container.hpp @@ -28,8 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // based on // https://svn.apache.org/repos/asf/mesos/tags/release-0.9.0-incubating-RC0/src/common/json.hpp -#ifndef JSON_CONTAINER_H -#define JSON_CONTAINER_H +#ifndef JSON_CONTAINER_HPP +#define JSON_CONTAINER_HPP #include @@ -38,7 +38,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -namespace JSON +namespace osrm +{ +namespace json { struct Object; @@ -90,5 +92,5 @@ struct Array }; } // namespace JSON - -#endif // JSON_CONTAINER_H +} // namespace osrm +#endif // JSON_CONTAINER_HPP diff --git a/library/osrm.hpp b/library/osrm.hpp index 571297d06..dd7ffd749 100644 --- a/library/osrm.hpp +++ b/library/osrm.hpp @@ -35,10 +35,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class OSRM_impl; struct RouteParameters; -namespace JSON +namespace osrm +{ +namespace json { struct Object; } +} class OSRM { @@ -48,7 +51,7 @@ class OSRM public: explicit OSRM(libosrm_config &lib_config); ~OSRM(); - int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result); + int RunQuery(RouteParameters &route_parameters, osrm::json::Object &json_result); }; #endif // OSRM_HPP diff --git a/library/osrm_impl.cpp b/library/osrm_impl.cpp index aea85a44c..0aec3f15c 100644 --- a/library/osrm_impl.cpp +++ b/library/osrm_impl.cpp @@ -104,7 +104,7 @@ void OSRM_impl::RegisterPlugin(BasePlugin *plugin) plugin_map.emplace(plugin->GetDescriptor(), plugin); } -int OSRM_impl::RunQuery(RouteParameters &route_parameters, JSON::Object &json_result) +int OSRM_impl::RunQuery(RouteParameters &route_parameters, osrm::json::Object &json_result) { const auto &plugin_iterator = plugin_map.find(route_parameters.service); @@ -172,7 +172,7 @@ OSRM::OSRM(libosrm_config &lib_config) : OSRM_pimpl_(osrm::make_uniqueRunQuery(route_parameters, json_result); } diff --git a/library/osrm_impl.hpp b/library/osrm_impl.hpp index 55674c84b..3f235f6ec 100644 --- a/library/osrm_impl.hpp +++ b/library/osrm_impl.hpp @@ -52,7 +52,7 @@ class OSRM_impl OSRM_impl(libosrm_config &lib_config); OSRM_impl(const OSRM_impl &) = delete; virtual ~OSRM_impl(); - int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result); + int RunQuery(RouteParameters &route_parameters, osrm::json::Object &json_result); private: void RegisterPlugin(BasePlugin *plugin); diff --git a/plugins/distance_table.hpp b/plugins/distance_table.hpp index 0a8912640..d4dfdc322 100644 --- a/plugins/distance_table.hpp +++ b/plugins/distance_table.hpp @@ -68,7 +68,7 @@ template class DistanceTablePlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } int HandleRequest(const RouteParameters &route_parameters, - JSON::Object &json_result) override final + osrm::json::Object &json_result) override final { if (!check_all_coordinates(route_parameters.coordinates)) { @@ -110,18 +110,18 @@ template class DistanceTablePlugin final : public BasePlugin return 400; } - JSON::Array json_array; + osrm::json::Array json_array; const auto number_of_locations = phantom_node_vector.size(); for (const auto row : osrm::irange(0, number_of_locations)) { - JSON::Array json_row; + osrm::json::Array json_row; auto row_begin_iterator = result_table->begin() + (row * number_of_locations); auto row_end_iterator = result_table->begin() + ((row + 1) * number_of_locations); json_row.values.insert(json_row.values.end(), row_begin_iterator, row_end_iterator); json_array.values.push_back(json_row); } json_result.values["distance_table"] = json_array; - // JSON::render(reply.content, json_object); + // osrm::json::render(reply.content, json_object); return 200; } diff --git a/plugins/hello_world.hpp b/plugins/hello_world.hpp index 5b08663db..269441715 100644 --- a/plugins/hello_world.hpp +++ b/plugins/hello_world.hpp @@ -48,7 +48,7 @@ class HelloWorldPlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } int HandleRequest(const RouteParameters &routeParameters, - JSON::Object &json_result) override final + osrm::json::Object &json_result) override final { std::string temp_string; json_result.values["title"] = "Hello World"; @@ -71,12 +71,12 @@ class HelloWorldPlugin final : public BasePlugin temp_string = cast::integral_to_string(routeParameters.coordinates.size()); json_result.values["location_count"] = temp_string; - JSON::Array json_locations; + osrm::json::Array json_locations; unsigned counter = 0; for (const FixedPointCoordinate &coordinate : routeParameters.coordinates) { - JSON::Object json_location; - JSON::Array json_coordinates; + osrm::json::Object json_location; + osrm::json::Array json_coordinates; json_coordinates.values.push_back( static_cast(coordinate.lat / COORDINATE_PRECISION)); @@ -89,7 +89,7 @@ class HelloWorldPlugin final : public BasePlugin json_result.values["locations"] = json_locations; json_result.values["hint_count"] = routeParameters.hints.size(); - JSON::Array json_hints; + osrm::json::Array json_hints; counter = 0; for (const std::string ¤t_hint : routeParameters.hints) { diff --git a/plugins/locate.hpp b/plugins/locate.hpp index 260361462..397bde649 100644 --- a/plugins/locate.hpp +++ b/plugins/locate.hpp @@ -45,7 +45,7 @@ template class LocatePlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } int HandleRequest(const RouteParameters &route_parameters, - JSON::Object &json_result) override final + osrm::json::Object &json_result) override final { // check number of parameters if (route_parameters.coordinates.empty() || @@ -63,7 +63,7 @@ template class LocatePlugin final : public BasePlugin else { json_result.values["status"] = 0; - JSON::Array json_coordinate; + osrm::json::Array json_coordinate; json_coordinate.values.push_back(result.lat / COORDINATE_PRECISION); json_coordinate.values.push_back(result.lon / COORDINATE_PRECISION); json_result.values["mapped_coordinate"] = json_coordinate; diff --git a/plugins/nearest.hpp b/plugins/nearest.hpp index 6221fcfb3..fc4e98046 100644 --- a/plugins/nearest.hpp +++ b/plugins/nearest.hpp @@ -50,7 +50,7 @@ template class NearestPlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } int HandleRequest(const RouteParameters &route_parameters, - JSON::Object &json_result) override final + osrm::json::Object &json_result) override final { // check number of parameters if (route_parameters.coordinates.empty() || @@ -75,14 +75,14 @@ template class NearestPlugin final : public BasePlugin if (number_of_results > 1) { - JSON::Array results; + osrm::json::Array results; auto vector_length = phantom_node_vector.size(); for (const auto i : osrm::irange(0, std::min(number_of_results, vector_length))) { - JSON::Array json_coordinate; - JSON::Object result; + osrm::json::Array json_coordinate; + osrm::json::Object result; json_coordinate.values.push_back(phantom_node_vector.at(i).location.lat / COORDINATE_PRECISION); json_coordinate.values.push_back(phantom_node_vector.at(i).location.lon / @@ -97,7 +97,7 @@ template class NearestPlugin final : public BasePlugin } else { - JSON::Array json_coordinate; + osrm::json::Array json_coordinate; json_coordinate.values.push_back(phantom_node_vector.front().location.lat / COORDINATE_PRECISION); json_coordinate.values.push_back(phantom_node_vector.front().location.lon / diff --git a/plugins/plugin_base.hpp b/plugins/plugin_base.hpp index 37d32b5b2..9b839016c 100644 --- a/plugins/plugin_base.hpp +++ b/plugins/plugin_base.hpp @@ -42,16 +42,15 @@ class BasePlugin // Maybe someone can explain the pure virtual destructor thing to me (dennis) virtual ~BasePlugin() {} virtual const std::string GetDescriptor() const = 0; - virtual int HandleRequest(const RouteParameters &, JSON::Object &) = 0; - virtual bool check_all_coordinates(const std::vector &coordinates) const final + virtual int HandleRequest(const RouteParameters &, osrm::json::Object &) = 0; + virtual bool + check_all_coordinates(const std::vector &coordinates) const final { - if (2 > coordinates.size() || - std::any_of(std::begin(coordinates), - std::end(coordinates), - [](const FixedPointCoordinate &coordinate) - { - return !coordinate.is_valid(); - })) + if (2 > coordinates.size() || std::any_of(std::begin(coordinates), std::end(coordinates), + [](const FixedPointCoordinate &coordinate) + { + return !coordinate.is_valid(); + })) { return false; } diff --git a/plugins/timestamp.hpp b/plugins/timestamp.hpp index db265ec47..59a8f56f9 100644 --- a/plugins/timestamp.hpp +++ b/plugins/timestamp.hpp @@ -45,7 +45,7 @@ template class TimestampPlugin final : public BasePlugin } const std::string GetDescriptor() const override final { return descriptor_string; } int HandleRequest(const RouteParameters &route_parameters, - JSON::Object &json_result) override final + osrm::json::Object &json_result) override final { json_result.values["status"] = 0; const std::string timestamp = facade->GetTimestamp(); diff --git a/plugins/viaroute.hpp b/plugins/viaroute.hpp index 630cba579..dd5edee57 100644 --- a/plugins/viaroute.hpp +++ b/plugins/viaroute.hpp @@ -72,7 +72,7 @@ template class ViaRoutePlugin final : public BasePlugin const std::string GetDescriptor() const override final { return descriptor_string; } int HandleRequest(const RouteParameters &route_parameters, - JSON::Object &json_result) override final + osrm::json::Object &json_result) override final { if (!check_all_coordinates(route_parameters.coordinates)) { diff --git a/server/request_handler.cpp b/server/request_handler.cpp index 464ba5b94..25637c3ad 100644 --- a/server/request_handler.cpp +++ b/server/request_handler.cpp @@ -92,7 +92,7 @@ void RequestHandler::handle_request(const http::request ¤t_request, const bool result = boost::spirit::qi::parse(api_iterator, request_string.end(), api_parser); - JSON::Object json_result; + osrm::json::Object json_result; // check if the was an error with the request if (!result || (api_iterator != request_string.end())) { @@ -104,7 +104,7 @@ void RequestHandler::handle_request(const http::request ¤t_request, std::string message = "Query string malformed close to position "; message += cast::integral_to_string(position); json_result.values["status_message"] = message; - JSON::render(current_reply.content, json_result); + osrm::json::render(current_reply.content, json_result); return; } @@ -124,7 +124,7 @@ void RequestHandler::handle_request(const http::request ¤t_request, json_result.values["status"] = 400; std::string message = "Bad Request"; json_result.values["status_message"] = message; - JSON::render(current_reply.content, json_result); + osrm::json::render(current_reply.content, json_result); return; } // set headers @@ -132,7 +132,7 @@ void RequestHandler::handle_request(const http::request ¤t_request, cast::integral_to_string(current_reply.content.size())); if ("gpx" == route_parameters.output_format) { // gpx file - JSON::gpx_render(current_reply.content, json_result.values["route"]); + osrm::json::gpx_render(current_reply.content, json_result.values["route"]); current_reply.headers.emplace_back("Content-Type", "application/gpx+xml; charset=UTF-8"); current_reply.headers.emplace_back("Content-Disposition", @@ -140,14 +140,14 @@ void RequestHandler::handle_request(const http::request ¤t_request, } else if (route_parameters.jsonp_parameter.empty()) { // json file - JSON::render(current_reply.content, json_result); + osrm::json::render(current_reply.content, json_result); current_reply.headers.emplace_back("Content-Type", "application/json; charset=UTF-8"); current_reply.headers.emplace_back("Content-Disposition", "inline; filename=\"response.json\""); } else { // jsonp - JSON::render(current_reply.content, json_result); + osrm::json::render(current_reply.content, json_result); current_reply.headers.emplace_back("Content-Type", "text/javascript; charset=UTF-8"); current_reply.headers.emplace_back("Content-Disposition", "inline; filename=\"response.js\""); diff --git a/tools/simpleclient.cpp b/tools/simpleclient.cpp index 2567b9319..0235b6bdb 100644 --- a/tools/simpleclient.cpp +++ b/tools/simpleclient.cpp @@ -81,10 +81,10 @@ int main(int argc, const char *argv[]) // target_coordinate route_parameters.coordinates.emplace_back(52.513191 * COORDINATE_PRECISION, 13.415852 * COORDINATE_PRECISION); - JSON::Object json_result; + osrm::json::Object json_result; const int result_code = routing_machine.RunQuery(route_parameters, json_result); SimpleLogger().Write() << "http code: " << result_code; - JSON::render(SimpleLogger().Write(), json_result); + osrm::json::render(SimpleLogger().Write(), json_result); } catch (std::exception ¤t_exception) { diff --git a/util/json_renderer.hpp b/util/json_renderer.hpp index adb7c544e..143066cb7 100644 --- a/util/json_renderer.hpp +++ b/util/json_renderer.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -35,7 +35,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -namespace JSON +namespace osrm +{ +namespace json { struct Renderer : mapbox::util::static_visitor<> @@ -179,6 +181,6 @@ inline void render(std::vector &out, const Object &object) mapbox::util::apply_visitor(ArrayRenderer(out), value); } -} // namespace JSON - +} // namespace json +} // namespace osrm #endif // JSON_RENDERER_HPP diff --git a/util/string_util.hpp b/util/string_util.hpp index 08af55483..92fac59c7 100644 --- a/util/string_util.hpp +++ b/util/string_util.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2013, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/util/xml_renderer.hpp b/util/xml_renderer.hpp index bbf2287e1..5783ab133 100644 --- a/util/xml_renderer.hpp +++ b/util/xml_renderer.hpp @@ -32,7 +32,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -namespace JSON +namespace osrm +{ +namespace json { struct XMLToArrayRenderer : mapbox::util::static_visitor<> @@ -135,6 +137,6 @@ template inline void gpx_render(std::vector &out, const const std::string footer{""}; out.insert(out.end(), footer.begin(), footer.end()); } -} // namespace JSON - +} // namespace json +} // namespace osrm #endif // XML_RENDERER_HPP