Add missing #includes and remove usage of json_parser_error type for boost property_trees

This commit is contained in:
Tristan Penman 2016-08-06 21:24:16 -07:00
parent b6854612a4
commit 3d3f76df10
4 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,9 @@
#ifndef __VALIJSON_INTERNAL_JSON_POINTER_HPP
#define __VALIJSON_INTERNAL_JSON_POINTER_HPP
#include <algorithm>
#include <cerrno>
#include <cstddef>
#include <stdexcept>
#include <string>
@ -202,13 +204,13 @@ inline AdapterType resolveJsonPointer(
"out of bounds; actual token: " + referenceToken);
}
if (index > static_cast<uint64_t>(std::numeric_limits<ptrdiff_t>::max())) {
if (index > static_cast<uint64_t>(std::numeric_limits<std::ptrdiff_t>::max())) {
throw std::runtime_error("Array index out of bounds; hard "
"limit is " + std::to_string(
std::numeric_limits<ptrdiff_t>::max()));
std::numeric_limits<std::ptrdiff_t>::max()));
}
itr.advance(static_cast<ptrdiff_t>(index));
itr.advance(static_cast<std::ptrdiff_t>(index));
// Recursively process the remaining tokens
return resolveJsonPointer(*itr, jsonPointer, jsonPointerNext);

View File

@ -3,6 +3,7 @@
#define __VALIJSON_FILE_UTILS_HPP
#include <fstream>
#include <limits>
namespace valijson {
namespace utils {

View File

@ -16,8 +16,6 @@
# include <boost/property_tree/json_parser.hpp>
#endif
#include <boost/property_tree/detail/json_parser_error.hpp>
#include <valijson/utils/file_utils.hpp>
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;

View File

@ -1,3 +1,4 @@
#include <memory>
#include <gtest/gtest.h>