From 3d3f76df10d0403bd377218bb69be40a3e669bd7 Mon Sep 17 00:00:00 2001 From: Tristan Penman Date: Sat, 6 Aug 2016 21:24:16 -0700 Subject: [PATCH] Add missing #includes and remove usage of json_parser_error type for boost property_trees --- include/valijson/internal/json_pointer.hpp | 8 +++++--- include/valijson/utils/file_utils.hpp | 1 + include/valijson/utils/property_tree_utils.hpp | 4 +--- tests/test_json_pointer.cpp | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/valijson/internal/json_pointer.hpp b/include/valijson/internal/json_pointer.hpp index 77f1c2d..fcb6b4e 100644 --- a/include/valijson/internal/json_pointer.hpp +++ b/include/valijson/internal/json_pointer.hpp @@ -2,7 +2,9 @@ #ifndef __VALIJSON_INTERNAL_JSON_POINTER_HPP #define __VALIJSON_INTERNAL_JSON_POINTER_HPP +#include #include +#include #include #include @@ -202,13 +204,13 @@ inline AdapterType resolveJsonPointer( "out of bounds; actual token: " + referenceToken); } - if (index > static_cast(std::numeric_limits::max())) { + if (index > static_cast(std::numeric_limits::max())) { throw std::runtime_error("Array index out of bounds; hard " "limit is " + std::to_string( - std::numeric_limits::max())); + std::numeric_limits::max())); } - itr.advance(static_cast(index)); + itr.advance(static_cast(index)); // Recursively process the remaining tokens return resolveJsonPointer(*itr, jsonPointer, jsonPointerNext); diff --git a/include/valijson/utils/file_utils.hpp b/include/valijson/utils/file_utils.hpp index 4fd3c9d..2a9f724 100644 --- a/include/valijson/utils/file_utils.hpp +++ b/include/valijson/utils/file_utils.hpp @@ -3,6 +3,7 @@ #define __VALIJSON_FILE_UTILS_HPP #include +#include namespace valijson { namespace utils { diff --git a/include/valijson/utils/property_tree_utils.hpp b/include/valijson/utils/property_tree_utils.hpp index fdbe4cb..8b987e0 100644 --- a/include/valijson/utils/property_tree_utils.hpp +++ b/include/valijson/utils/property_tree_utils.hpp @@ -16,8 +16,6 @@ # include #endif -#include - #include namespace valijson { @@ -27,7 +25,7 @@ inline bool loadDocument(const std::string &path, boost::property_tree::ptree &d { try { boost::property_tree::read_json(path, document); - } catch (boost::property_tree::json_parser::json_parser_error &e) { + } catch (std::exception &e) { std::cerr << "Boost Property Tree JSON parser failed to parse the document:" << std::endl; std::cerr << e.what() << std::endl; return false; diff --git a/tests/test_json_pointer.cpp b/tests/test_json_pointer.cpp index c7f5079..47a7d63 100644 --- a/tests/test_json_pointer.cpp +++ b/tests/test_json_pointer.cpp @@ -1,3 +1,4 @@ +#include #include