Merge pull request #188 from Rail-Connected/pullreq1

Various cosmetic fixes.
This commit is contained in:
Tristan Penman 2024-01-07 11:27:46 +11:00 committed by GitHub
commit 6599e8b33a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 585 additions and 416 deletions

View File

@ -135,7 +135,7 @@ Valijson's JSON Reference implementation requires that two callback functions ar
## Test Suite ## Test Suite
Valijson's' test suite currently contains several hand-crafted tests and uses the standard [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) to test support for parts of the JSON Schema feature set that have been implemented. Valijson's test suite currently contains several hand-crafted tests and uses the standard [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) to test support for parts of the JSON Schema feature set that have been implemented.
### cmake ### cmake
@ -152,7 +152,7 @@ make
``` ```
## How to add this library to your cmake target ## How to add this library to your cmake target
Valijson can be integrated either as git submodule or with find_package(). Valijson can be integrated either as git submodule or with `find_package()`.
### Valijson as git submodule ### Valijson as git submodule
@ -210,7 +210,7 @@ This can then be used in your project with a single `#include`:
#include "valijson_nlohmann_bundled.hpp" #include "valijson_nlohmann_bundled.hpp"
An example can be found in [examples/valijson_nlohmann_bundled_test.cpp](examples/valijson_nlohmann_bundled_test.cpp). An example can be found in [examples/valijson\_nlohmann\_bundled\_test.cpp](examples/valijson_nlohmann_bundled_test.cpp).
Note: the bundled version of Valijson always embeds a compatibility header in place of `std::optional`. Note: the bundled version of Valijson always embeds a compatibility header in place of `std::optional`.
@ -270,7 +270,7 @@ When building the test suite, Boost 1.54, Qt 5 and Poco are optional dependencie
Valijson supports JSON documents loaded using various JSON parser libraries. It has been tested against the following versions of these libraries: Valijson supports JSON documents loaded using various JSON parser libraries. It has been tested against the following versions of these libraries:
- [boost::property_tree 1.54](http://www.boost.org/doc/libs/1_54_0/doc/html/boost_propertytree/synopsis.html) - [boost::property\_tree 1.54](http://www.boost.org/doc/libs/1_54_0/doc/html/boost_propertytree/synopsis.html)
- [Boost.JSON 1.75](https://www.boost.org/doc/libs/1_75_0/libs/json/doc/html/index.html) - [Boost.JSON 1.75](https://www.boost.org/doc/libs/1_75_0/libs/json/doc/html/index.html)
- [json11 (commit afcc8d0)](https://github.com/dropbox/json11/tree/afcc8d0d82b1ce2df587a7a0637d05ba493bf5e6) - [json11 (commit afcc8d0)](https://github.com/dropbox/json11/tree/afcc8d0d82b1ce2df587a7a0637d05ba493bf5e6)
- [jsoncpp 1.9.4](https://github.com/open-source-parsers/jsoncpp/archive/1.9.4.tar.gz) - [jsoncpp 1.9.4](https://github.com/open-source-parsers/jsoncpp/archive/1.9.4.tar.gz)

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,8 @@
// The idea and interface is based on Boost.Optional library // The idea and interface is based on Boost.Optional library
// authored by Fernando Luis Cacciola Carballal // authored by Fernando Luis Cacciola Carballal
# ifndef ___OPTIONAL_HPP___ # ifndef OPTIONAL_HPP
# define ___OPTIONAL_HPP___ # define OPTIONAL_HPP
# include <utility> # include <utility>
# include <type_traits> # include <type_traits>
@ -270,7 +270,7 @@ namespace std{
unsigned char dummy_; unsigned char dummy_;
T value_; T value_;
constexpr storage_t( trivial_init_t ) noexcept : dummy_() {}; constexpr storage_t( trivial_init_t ) noexcept : dummy_() {}
template <class... Args> template <class... Args>
constexpr storage_t( Args&&... args ) : value_(constexpr_forward<Args>(args)...) {} constexpr storage_t( Args&&... args ) : value_(constexpr_forward<Args>(args)...) {}
@ -285,7 +285,7 @@ namespace std{
unsigned char dummy_; unsigned char dummy_;
T value_; T value_;
constexpr constexpr_storage_t( trivial_init_t ) noexcept : dummy_() {}; constexpr constexpr_storage_t( trivial_init_t ) noexcept : dummy_() {}
template <class... Args> template <class... Args>
constexpr constexpr_storage_t( Args&&... args ) : value_(constexpr_forward<Args>(args)...) {} constexpr constexpr_storage_t( Args&&... args ) : value_(constexpr_forward<Args>(args)...) {}
@ -300,7 +300,7 @@ namespace std{
bool init_; bool init_;
storage_t<T> storage_; storage_t<T> storage_;
constexpr optional_base() noexcept : init_(false), storage_(trivial_init) {}; constexpr optional_base() noexcept : init_(false), storage_(trivial_init) {}
explicit constexpr optional_base(const T& v) : init_(true), storage_(v) {} explicit constexpr optional_base(const T& v) : init_(true), storage_(v) {}
@ -323,7 +323,7 @@ namespace std{
bool init_; bool init_;
constexpr_storage_t<T> storage_; constexpr_storage_t<T> storage_;
constexpr constexpr_optional_base() noexcept : init_(false), storage_(trivial_init) {}; constexpr constexpr_optional_base() noexcept : init_(false), storage_(trivial_init) {}
explicit constexpr constexpr_optional_base(const T& v) : init_(true), storage_(v) {} explicit constexpr constexpr_optional_base(const T& v) : init_(true), storage_(v) {}
@ -398,8 +398,8 @@ namespace std{
typedef T value_type; typedef T value_type;
// 20.5.5.1, constructors // 20.5.5.1, constructors
constexpr optional() noexcept : OptionalBase<T>() {}; constexpr optional() noexcept : OptionalBase<T>() {}
constexpr optional(nullopt_t) noexcept : OptionalBase<T>() {}; constexpr optional(nullopt_t) noexcept : OptionalBase<T>() {}
optional(const optional& rhs) optional(const optional& rhs)
: OptionalBase<T>() : OptionalBase<T>()
@ -1040,4 +1040,4 @@ namespace std
# undef TR2_OPTIONAL_REQUIRES # undef TR2_OPTIONAL_REQUIRES
# undef TR2_OPTIONAL_ASSERTED_EXPRESSION # undef TR2_OPTIONAL_ASSERTED_EXPRESSION
# endif //___OPTIONAL_HPP___ # endif //OPTIONAL_HPP

View File

@ -145,7 +145,7 @@ public:
{ {
result = 0; result = 0;
return true; return true;
}; }
StdStringObject asObject() const StdStringObject asObject() const
{ {
@ -181,67 +181,67 @@ public:
return new StdStringFrozenValue(m_value); return new StdStringFrozenValue(m_value);
} }
static StdStringArray getArray() VALIJSON_NORETURN static StdStringArray getArray()
{ {
throwNotSupported(); throwNotSupported();
} }
size_t getArraySize() const override VALIJSON_NORETURN size_t getArraySize() const override
{ {
throwNotSupported(); throwNotSupported();
} }
bool getArraySize(size_t &) const override VALIJSON_NORETURN bool getArraySize(size_t &) const override
{ {
throwNotSupported(); throwNotSupported();
} }
bool getBool() const override VALIJSON_NORETURN bool getBool() const override
{ {
throwNotSupported(); throwNotSupported();
} }
bool getBool(bool &) const override VALIJSON_NORETURN bool getBool(bool &) const override
{ {
throwNotSupported(); throwNotSupported();
} }
double getDouble() const override VALIJSON_NORETURN double getDouble() const override
{ {
throwNotSupported(); throwNotSupported();
} }
bool getDouble(double &) const override VALIJSON_NORETURN bool getDouble(double &) const override
{ {
throwNotSupported(); throwNotSupported();
} }
int64_t getInteger() const override VALIJSON_NORETURN int64_t getInteger() const override
{ {
throwNotSupported(); throwNotSupported();
} }
bool getInteger(int64_t &) const override VALIJSON_NORETURN bool getInteger(int64_t &) const override
{ {
throwNotSupported(); throwNotSupported();
} }
double getNumber() const override VALIJSON_NORETURN double getNumber() const override
{ {
throwNotSupported(); throwNotSupported();
} }
bool getNumber(double &) const override VALIJSON_NORETURN bool getNumber(double &) const override
{ {
throwNotSupported(); throwNotSupported();
} }
size_t getObjectSize() const override VALIJSON_NORETURN size_t getObjectSize() const override
{ {
throwNotSupported(); throwNotSupported();
} }
bool getObjectSize(size_t &) const override VALIJSON_NORETURN bool getObjectSize(size_t &) const override
{ {
throwNotSupported(); throwNotSupported();
} }
@ -360,12 +360,12 @@ public:
using pointer = StdStringAdapter*; using pointer = StdStringAdapter*;
using reference = StdStringAdapter&; using reference = StdStringAdapter&;
StdStringAdapter operator*() const VALIJSON_NORETURN StdStringAdapter operator*() const
{ {
throwNotSupported(); throwNotSupported();
} }
DerefProxy<StdStringAdapter> operator->() const VALIJSON_NORETURN DerefProxy<StdStringAdapter> operator->() const
{ {
throwNotSupported(); throwNotSupported();
} }
@ -380,22 +380,22 @@ public:
return false; return false;
} }
const StdStringArrayValueIterator& operator++() VALIJSON_NORETURN const StdStringArrayValueIterator& operator++()
{ {
throwNotSupported(); throwNotSupported();
} }
StdStringArrayValueIterator operator++(int) VALIJSON_NORETURN StdStringArrayValueIterator operator++(int)
{ {
throwNotSupported(); throwNotSupported();
} }
const StdStringArrayValueIterator& operator--() VALIJSON_NORETURN const StdStringArrayValueIterator& operator--()
{ {
throwNotSupported(); throwNotSupported();
} }
void advance(std::ptrdiff_t) VALIJSON_NORETURN void advance(std::ptrdiff_t)
{ {
throwNotSupported(); throwNotSupported();
} }
@ -420,12 +420,12 @@ public:
using pointer = StdStringObjectMember*; using pointer = StdStringObjectMember*;
using reference = StdStringObjectMember&; using reference = StdStringObjectMember&;
StdStringObjectMember operator*() const VALIJSON_NORETURN StdStringObjectMember operator*() const
{ {
throwNotSupported(); throwNotSupported();
} }
DerefProxy<StdStringObjectMember> operator->() const VALIJSON_NORETURN DerefProxy<StdStringObjectMember> operator->() const
{ {
throwNotSupported(); throwNotSupported();
} }
@ -440,17 +440,17 @@ public:
return false; return false;
} }
const StdStringObjectMemberIterator& operator++() VALIJSON_NORETURN const StdStringObjectMemberIterator& operator++()
{ {
throwNotSupported(); throwNotSupported();
} }
StdStringObjectMemberIterator operator++(int) VALIJSON_NORETURN StdStringObjectMemberIterator operator++(int)
{ {
throwNotSupported(); throwNotSupported();
} }
const StdStringObjectMemberIterator& operator--() VALIJSON_NORETURN const StdStringObjectMemberIterator& operator--()
{ {
throwNotSupported(); throwNotSupported();
} }

View File

@ -13,7 +13,6 @@ namespace json_reference {
* @brief Extract URI from JSON Reference relative to the current schema * @brief Extract URI from JSON Reference relative to the current schema
* *
* @param jsonRef JSON Reference to extract from * @param jsonRef JSON Reference to extract from
* @param schema Schema that JSON Reference URI is relative to
* *
* @return Optional string containing URI * @return Optional string containing URI
*/ */

View File

@ -338,24 +338,24 @@ private:
* those $ref nodes in the schema cache. An entry will be added to the * those $ref nodes in the schema cache. An entry will be added to the
* schema cache for each node visited on the path to the concrete node. * schema cache for each node visited on the path to the concrete node.
* *
* @param rootSchema The Schema instance, and root subschema, through * @param rootSchema The Schema instance, and root subschema, through
* which other subschemas can be created and * which other subschemas can be created and
* modified * modified
* @param rootNode Reference to the node from which JSON References * @param rootNode Reference to the node from which JSON References
* will be resolved when they refer to the current * will be resolved when they refer to the current
* document * document
* @param node Reference to the node to parse * @param node Reference to the node to parse
* @param currentScope URI for current resolution scope * @param currentScope URI for current resolution scope
* @param nodePath JSON Pointer representing path to current node * @param nodePath JSON Pointer representing path to current node
* @param fetchDoc Function to fetch remote JSON documents (optional) * @param fetchDoc Function to fetch remote JSON documents (optional)
* @param parentSchema Optional pointer to the parent schema, used to * @param parentSubschema Optional pointer to the parent schema, used to
* support required keyword in Draft 3 * support required keyword in Draft 3
* @param ownName Optional pointer to a node name, used to support * @param ownName Optional pointer to a node name, used to support
* the 'required' keyword in Draft 3 * the 'required' keyword in Draft 3
* @param docCache Cache of resolved and fetched remote documents * @param docCache Cache of resolved and fetched remote documents
* @param schemaCache Cache of populated schemas * @param schemaCache Cache of populated schemas
* @param newCacheKeys A list of keys that should be added to the cache * @param newCacheKeys A list of keys that should be added to the cache
* when recursion terminates * when recursion terminates
*/ */
template<typename AdapterType> template<typename AdapterType>
const Subschema * makeOrReuseSchema( const Subschema * makeOrReuseSchema(
@ -504,22 +504,22 @@ private:
* a concrete node, an entry will be added to the schema cache for each of * a concrete node, an entry will be added to the schema cache for each of
* the nodes in that path. * the nodes in that path.
* *
* @param rootSchema The Schema instance, and root subschema, through * @param rootSchema The Schema instance, and root subschema, through
* which other subschemas can be created and * which other subschemas can be created and
* modified * modified
* @param rootNode Reference to the node from which JSON References * @param rootNode Reference to the node from which JSON References
* will be resolved when they refer to the current * will be resolved when they refer to the current
* document * document
* @param node Reference to the node to parse * @param node Reference to the node to parse
* @param currentScope URI for current resolution scope * @param currentScope URI for current resolution scope
* @param nodePath JSON Pointer representing path to current node * @param nodePath JSON Pointer representing path to current node
* @param fetchDoc Function to fetch remote JSON documents (optional) * @param fetchDoc Function to fetch remote JSON documents (optional)
* @param parentSchema Optional pointer to the parent schema, used to * @param parentSubschema Optional pointer to the parent schema, used to
* support required keyword in Draft 3 * support required keyword in Draft 3
* @param ownName Optional pointer to a node name, used to support * @param ownName Optional pointer to a node name, used to support
* the 'required' keyword in Draft 3 * the 'required' keyword in Draft 3
* @param docCache Cache of resolved and fetched remote documents * @param docCache Cache of resolved and fetched remote documents
* @param schemaCache Cache of populated schemas * @param schemaCache Cache of populated schemas
*/ */
template<typename AdapterType> template<typename AdapterType>
const Subschema * makeOrReuseSchema( const Subschema * makeOrReuseSchema(
@ -556,7 +556,7 @@ private:
* will be resolved when they refer to the current * will be resolved when they refer to the current
* document * document
* @param node Reference to node to parse * @param node Reference to node to parse
* @param schema Reference to Schema to populate * @param subschema Reference to Schema to populate
* @param currentScope URI for current resolution scope * @param currentScope URI for current resolution scope
* @param nodePath JSON Pointer representing path to current node * @param nodePath JSON Pointer representing path to current node
* @param fetchDoc Optional function to fetch remote JSON documents * @param fetchDoc Optional function to fetch remote JSON documents
@ -1173,7 +1173,7 @@ private:
* a schema that will be used when the conditional * a schema that will be used when the conditional
* evaluates to false. * evaluates to false.
* @param currentScope URI for current resolution scope * @param currentScope URI for current resolution scope
* @param containsPath JSON Pointer representing the path to * @param nodePath JSON Pointer representing the path to
* the 'contains' node * the 'contains' node
* @param fetchDoc Function to fetch remote JSON documents * @param fetchDoc Function to fetch remote JSON documents
* (optional) * (optional)
@ -1564,14 +1564,9 @@ private:
* @param items Optional pointer to a JSON node containing * @param items Optional pointer to a JSON node containing
* an object mapping property names to * an object mapping property names to
* schemas. * schemas.
* @param additionalItems Optional pointer to a JSON node containing
* an additional properties schema or a
* boolean value.
* @param currentScope URI for current resolution scope * @param currentScope URI for current resolution scope
* @param itemsPath JSON Pointer representing the path to * @param itemsPath JSON Pointer representing the path to
* the 'items' node * the 'items' node
* @param additionalItemsPath JSON Pointer representing the path to
* the 'additionalItems' node
* @param fetchDoc Function to fetch remote JSON documents * @param fetchDoc Function to fetch remote JSON documents
* (optional) * (optional)
* @param docCache Cache of resolved and fetched remote * @param docCache Cache of resolved and fetched remote
@ -1623,13 +1618,6 @@ private:
/** /**
* @brief Make a new MaximumConstraint object (draft 3 and 4). * @brief Make a new MaximumConstraint object (draft 3 and 4).
* *
* @param rootSchema The Schema instance, and root subschema,
* through which other subschemas can be
* created and modified
* @param rootNode Reference to the node from which JSON
* References will be resolved when they refer
* to the current document; used for recursive
* parsing of schemas
* @param node JSON node containing the maximum value. * @param node JSON node containing the maximum value.
* @param exclusiveMaximum Optional pointer to a JSON boolean value that * @param exclusiveMaximum Optional pointer to a JSON boolean value that
* indicates whether maximum value is excluded * indicates whether maximum value is excluded
@ -1665,9 +1653,6 @@ private:
* *
* @param node JSON node containing an integer, representing the maximum value. * @param node JSON node containing an integer, representing the maximum value.
* *
* @param exclusive Optional pointer to a JSON boolean value that indicates whether the
* maximum value is excluded from the range of permitted values.
*
* @return pointer to a new Maximum that belongs to the caller * @return pointer to a new Maximum that belongs to the caller
*/ */
template<typename AdapterType> template<typename AdapterType>
@ -1763,7 +1748,7 @@ private:
* @param node JSON node containing an integer, representing * @param node JSON node containing an integer, representing
* the minimum value. * the minimum value.
* *
* @param exclusiveMaximum Optional pointer to a JSON boolean value that * @param exclusiveMinimum Optional pointer to a JSON boolean value that
* indicates whether the minimum value is * indicates whether the minimum value is
* excluded from the range of permitted values. * excluded from the range of permitted values.
* *
@ -1797,9 +1782,6 @@ private:
* *
* @param node JSON node containing an integer, representing the minimum value. * @param node JSON node containing an integer, representing the minimum value.
* *
* @param exclusive Optional pointer to a JSON boolean value that indicates whether the
* minimum value is excluded from the range of permitted values.
*
* @return pointer to a new MinimumConstraint that belongs to the caller * @return pointer to a new MinimumConstraint that belongs to the caller
*/ */
template<typename AdapterType> template<typename AdapterType>