Remove non-pragma header guards, and cleanup whitespace

This commit is contained in:
Tristan Penman 2019-08-27 12:32:47 +10:00
parent dbe09e0bab
commit d3a560d329
39 changed files with 746 additions and 904 deletions

View File

@ -993,21 +993,21 @@ namespace std{
{
x.swap(y);
}
template <class T>
constexpr optional<typename decay<T>::type> make_optional(T&& v)
{
return optional<typename decay<T>::type>(constexpr_forward<T>(v));
}
template <class X>
constexpr optional<X&> make_optional(reference_wrapper<X> v)
{
return optional<X&>(v.get());
}
} // namespace experimental
} // namespace std
@ -1018,18 +1018,18 @@ namespace std
{
typedef typename hash<T>::result_type result_type;
typedef std::experimental::optional<T> argument_type;
constexpr result_type operator()(argument_type const& arg) const {
return arg ? std::hash<T>{}(*arg) : result_type{};
}
};
template <typename T>
struct hash<std::experimental::optional<T&>>
{
typedef typename hash<T>::result_type result_type;
typedef std::experimental::optional<T&> argument_type;
constexpr result_type operator()(argument_type const& arg) const {
return arg ? std::hash<T>{}(*arg) : result_type{};
}

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_ADAPTERS_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_ADAPTER_HPP
#include <functional>
@ -472,5 +470,3 @@ struct AdapterTraits
} // namespace adapters
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_ADAPTERS_BASIC_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_BASIC_ADAPTER_HPP
#include <stdint.h>
#include <sstream>
@ -864,5 +862,3 @@ private:
} // namespace adapters
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_ADAPTERS_FROZEN_VALUE_HPP
#define __VALIJSON_ADAPTERS_FROZEN_VALUE_HPP
#include <valijson/adapters/adapter.hpp>
@ -52,5 +50,3 @@ public:
} // namespace adapters
} // namespace valijson
#endif

View File

@ -24,8 +24,6 @@
*/
#pragma once
#ifndef __VALIJSON_ADAPTERS_JSON11_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_JSON11_ADAPTER_HPP
#include <string>
#include <json11.hpp>
@ -709,5 +707,3 @@ inline Json11ObjectMemberIterator Json11Object::find(
} // namespace adapters
} // namespace valijson
#endif

View File

@ -24,10 +24,8 @@
*/
#pragma once
#ifndef __VALIJSON_ADAPTERS_JSONCPP_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_JSONCPP_ADAPTER_HPP
#include <stdint.h>
#include <cstdint>
#include <string>
#include <iterator>
@ -720,5 +718,3 @@ inline JsonCppObjectMemberIterator JsonCppObject::find(
} // namespace adapters
} // namespace valijson
#endif

View File

@ -24,8 +24,6 @@
*/
#pragma once
#ifndef __VALIJSON_ADAPTERS_NLOHMANN_JSON_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_NLOHMANN_JSON_ADAPTER_HPP
#include <string>
#include <json.hpp>
@ -707,6 +705,3 @@ inline NlohmannJsonObjectMemberIterator NlohmannJsonObject::find(
} // namespace adapters
} // namespace valijson
#endif

View File

@ -24,8 +24,6 @@
*/
#pragma once
#ifndef __VALIJSON_ADAPTERS_PICOJSON_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_PICOJSON_ADAPTER_HPP
#include <string>
@ -723,5 +721,3 @@ inline PicoJsonObjectMemberIterator PicoJsonObject::find(
} // namespace adapters
} // namespace valijson
#endif

File diff suppressed because it is too large Load Diff

View File

@ -24,8 +24,6 @@
*/
#pragma once
#ifndef __VALIJSON_ADAPTERS_PROPERTY_TREE_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_PROPERTY_TREE_ADAPTER_HPP
#include <string>
@ -753,5 +751,3 @@ inline PropertyTreeObjectMemberIterator PropertyTreeObject::find(
} // namespace adapters
} // namespace valijson
#endif

View File

@ -24,8 +24,6 @@
*/
#pragma once
#ifndef __VALIJSON_ADAPTERS_QTJSON_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_QTJSON_ADAPTER_HPP
#include <string>
@ -33,7 +31,6 @@
#include <QJsonValue>
#include <QJsonArray>
#include <valijson/adapters/adapter.hpp>
#include <valijson/adapters/basic_adapter.hpp>
#include <valijson/adapters/frozen_value.hpp>
@ -721,5 +718,3 @@ inline QtJsonObjectMemberIterator QtJsonObject::find(
} // namespace adapters
} // namespace valijson
#endif

View File

@ -39,8 +39,6 @@
*/
#pragma once
#ifndef __VALIJSON_ADAPTERS_RAPIDJSON_ADAPTER_HPP
#define __VALIJSON_ADAPTERS_RAPIDJSON_ADAPTER_HPP
#include <string>
#include <iterator>
@ -929,5 +927,3 @@ struct AdapterTraits<valijson::adapters::GenericRapidJsonAdapter<RapidJsonCrt> >
} // namespace adapters
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_CONSTRAINT_BUILDER_HPP
#define __VALIJSON_CONSTRAINT_BUILDER_HPP
namespace valijson {
@ -21,5 +19,3 @@ public:
};
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_CONSTRAINTS_BASIC_CONSTRAINT_HPP
#define __VALIJSON_CONSTRAINTS_BASIC_CONSTRAINT_HPP
#include <valijson/constraints/constraint.hpp>
#include <valijson/constraints/constraint_visitor.hpp>
@ -65,5 +63,3 @@ protected:
} // namespace constraints
} // namespace valijson
#endif

View File

@ -13,8 +13,6 @@
*/
#pragma once
#ifndef __VALIJSON_CONSTRAINTS_CONCRETE_CONSTRAINTS_HPP
#define __VALIJSON_CONSTRAINTS_CONCRETE_CONSTRAINTS_HPP
#include <limits>
#include <map>
@ -1093,5 +1091,3 @@ public:
} // namespace constraints
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_CONSTRAINTS_CONSTRAINT_HPP
#define __VALIJSON_CONSTRAINTS_CONSTRAINT_HPP
namespace valijson {
namespace constraints {
@ -50,5 +48,3 @@ struct Constraint
} // namespace constraints
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_CONSTRAINTS_CONSTRAINT_VISITOR_HPP
#define __VALIJSON_CONSTRAINTS_CONSTRAINT_VISITOR_HPP
namespace valijson {
namespace constraints {
@ -35,7 +33,7 @@ class ConstraintVisitor
{
protected:
virtual ~ConstraintVisitor() {}
// Shorten type names for derived classes outside of this namespace
typedef constraints::AllOfConstraint AllOfConstraint;
typedef constraints::AnyOfConstraint AnyOfConstraint;
@ -92,5 +90,3 @@ public:
} // namespace constraints
} // namespace valijson
#endif

View File

@ -1,5 +1,4 @@
#ifndef __VALIJSON_CUSTOM_ALLOCATOR_HPP
#define __VALIJSON_CUSTOM_ALLOCATOR_HPP
#pragma once
namespace valijson {
namespace internal {
@ -106,5 +105,3 @@ public:
} // end namespace internal
} // end namespace valijson
#endif

View File

@ -1,5 +1,4 @@
#ifndef __VALIJSON_DEBUG_HPP
#define __VALIJSON_DEBUG_HPP
#pragma once
#include <string>
@ -29,5 +28,3 @@ std::string nodeTypeAsString(const AdapterType &node) {
} // end namespace internal
} // end namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_INTERNAL_JSON_POINTER_HPP
#define __VALIJSON_INTERNAL_JSON_POINTER_HPP
#include <algorithm>
#include <cerrno>
@ -253,5 +251,3 @@ inline AdapterType resolveJsonPointer(
} // namespace json_pointer
} // namespace internal
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_INTERNAL_JSON_REFERENCE_HPP
#define __VALIJSON_INTERNAL_JSON_REFERENCE_HPP
#include <stdexcept>
#include <string>
@ -11,55 +9,52 @@ namespace valijson {
namespace internal {
namespace json_reference {
/**
* @brief Extract URI from JSON Reference relative to the current schema
*
* @param jsonRef JSON Reference to extract from
* @param schema Schema that JSON Reference URI is relative to
*
* @return Optional string containing URI
*/
inline opt::optional<std::string> getJsonReferenceUri(
const std::string &jsonRef)
{
const size_t ptrPos = jsonRef.find("#");
if (ptrPos == 0) {
// The JSON Reference does not contain a URI, but might contain a
// JSON Pointer that refers to the current document
return opt::optional<std::string>();
} else if (ptrPos != std::string::npos) {
// The JSON Reference contains a URI and possibly a JSON Pointer
return jsonRef.substr(0, ptrPos);
}
// The entire JSON Reference should be treated as a URI
return jsonRef;
}
/**
* @brief Extract JSON Pointer portion of a JSON Reference
*
* @param jsonRef JSON Reference to extract from
*
* @return Optional string containing JSON Pointer
*/
inline opt::optional<std::string> getJsonReferencePointer(
const std::string &jsonRef)
{
// Attempt to extract JSON Pointer if '#' character is present. Note
// that a valid pointer would contain at least a leading forward
// slash character.
const size_t ptrPos = jsonRef.find("#");
if (ptrPos != std::string::npos) {
return jsonRef.substr(ptrPos + 1);
}
/**
* @brief Extract URI from JSON Reference relative to the current schema
*
* @param jsonRef JSON Reference to extract from
* @param schema Schema that JSON Reference URI is relative to
*
* @return Optional string containing URI
*/
inline opt::optional<std::string> getJsonReferenceUri(
const std::string &jsonRef)
{
const size_t ptrPos = jsonRef.find("#");
if (ptrPos == 0) {
// The JSON Reference does not contain a URI, but might contain a
// JSON Pointer that refers to the current document
return opt::optional<std::string>();
} else if (ptrPos != std::string::npos) {
// The JSON Reference contains a URI and possibly a JSON Pointer
return jsonRef.substr(0, ptrPos);
}
// The entire JSON Reference should be treated as a URI
return jsonRef;
}
/**
* @brief Extract JSON Pointer portion of a JSON Reference
*
* @param jsonRef JSON Reference to extract from
*
* @return Optional string containing JSON Pointer
*/
inline opt::optional<std::string> getJsonReferencePointer(
const std::string &jsonRef)
{
// Attempt to extract JSON Pointer if '#' character is present. Note
// that a valid pointer would contain at least a leading forward
// slash character.
const size_t ptrPos = jsonRef.find("#");
if (ptrPos != std::string::npos) {
return jsonRef.substr(ptrPos + 1);
}
return opt::optional<std::string>();
}
} // namespace json_reference
} // namespace internal
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_OPTIONAL_HPP
#define __VALIJSON_OPTIONAL_HPP
#if __cplusplus >= 201703
// Visual C++ only supports __has_include in versions 14.12 and greater
@ -14,5 +12,3 @@ namespace opt = std;
# include <compat/optional.hpp>
namespace opt = std::experimental;
#endif
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_INTERNAL_URI_HPP
#define __VALIJSON_INTERNAL_URI_HPP
#include <string>
@ -8,30 +6,28 @@ namespace valijson {
namespace internal {
namespace uri {
/**
* @brief Placeholder function to check whether a URI is absolute
*
* This function just checks for '://'
*/
inline bool isUriAbsolute(const std::string &documentUri)
{
static const char * placeholderMarker = "://";
/**
* @brief Placeholder function to check whether a URI is absolute
*
* This function just checks for '://'
*/
inline bool isUriAbsolute(const std::string &documentUri)
{
static const char * placeholderMarker = "://";
return documentUri.find(placeholderMarker) != std::string::npos;
}
return documentUri.find(placeholderMarker) != std::string::npos;
}
/**
* Placeholder function to resolve a relative URI within a given scope
*/
inline std::string resolveRelativeUri(
const std::string &resolutionScope,
const std::string &relativeUri)
{
return resolutionScope + relativeUri;
}
/**
* Placeholder function to resolve a relative URI within a given scope
*/
inline std::string resolveRelativeUri(
const std::string &resolutionScope,
const std::string &relativeUri)
{
return resolutionScope + relativeUri;
}
} // namespace uri
} // namespace internal
} // namespace valijson
#endif // __VALIJSON_INTERNAL_URI_HPP

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_SCHEMA_HPP
#define __VALIJSON_SCHEMA_HPP
#include <cstdio>
#include <set>
@ -209,5 +207,3 @@ private:
};
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_SCHEMA_PARSER_HPP
#define __VALIJSON_SCHEMA_PARSER_HPP
#include <stdexcept>
#include <iostream>
@ -2116,5 +2114,3 @@ private:
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_SUBSCHEMA_HPP
#define __VALIJSON_SUBSCHEMA_HPP
#include <vector>
@ -17,7 +15,7 @@ namespace valijson {
* While all JSON Schemas have at least one sub-schema, the root, some will
* have additional sub-schemas that are defined as part of constraints that are
* included in the schema. For example, a 'oneOf' constraint maintains a set of
* references to one or more nested sub-schemas. As per the definition of a
* references to one or more nested sub-schemas. As per the definition of a
* oneOf constraint, a document is valid within that constraint if it validates
* against one of the nested sub-schemas.
*/
@ -244,7 +242,7 @@ public:
*
* The title will not be used for validation, but may be used as part
* of the user interface for interacting with schemas and sub-schema. As an
* example, it may be used as part of the validation error descriptions
* example, it may be used as part of the validation error descriptions
* that are produced by the Validator and ValidationVisitor classes.
*
* @param title new title
@ -282,5 +280,3 @@ private:
};
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_FILE_UTILS_HPP
#define __VALIJSON_FILE_UTILS_HPP
#include <fstream>
#include <limits>
@ -44,5 +42,3 @@ inline bool loadFile(const std::string &path, std::string &dest)
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_UTILS_JSON11_UTILS_HPP
#define __VALIJSON_UTILS_JSON11_UTILS_HPP
#include <iostream>
@ -34,6 +32,3 @@ inline bool loadDocument(const std::string &path, json11::Json &document)
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_UTILS_JSONCPP_UTILS_HPP
#define __VALIJSON_UTILS_JSONCPP_UTILS_HPP
#include <iostream>
@ -33,5 +31,3 @@ inline bool loadDocument(const std::string &path, Json::Value &document)
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef VALIJSON_NLOHMANN_JSON_UTILS_HPP
#define VALIJSON_NLOHMANN_JSON_UTILS_HPP
#include <iostream>
@ -10,7 +8,8 @@
namespace valijson {
namespace utils {
inline bool loadDocument(const std::string &path, nlohmann::json &document) {
inline bool loadDocument(const std::string &path, nlohmann::json &document)
{
// Load schema JSON from file
std::string file;
if (!loadFile(path, file)) {
@ -33,5 +32,3 @@ inline bool loadDocument(const std::string &path, nlohmann::json &document) {
} // namespace utils
} // namespace valijson
#endif //VALIJSON_NLOHMANN_JSON_UTILS_HPP

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_UTILS_PICOJSON_UTILS_HPP
#define __VALIJSON_UTILS_PICOJSON_UTILS_HPP
#include <iostream>
@ -33,5 +31,3 @@ inline bool loadDocument(const std::string &path, picojson::value &document)
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef VALIJSON_POCO_JSON_UTILS_HPP
#define VALIJSON_POCO_JSON_UTILS_HPP
#include <iostream>
@ -13,7 +11,8 @@
namespace valijson {
namespace utils {
inline bool loadDocument(const std::string &path, Poco::Dynamic::Var &document) {
inline bool loadDocument(const std::string &path, Poco::Dynamic::Var &document)
{
// Load schema JSON from file
std::string file;
if (!loadFile(path, file)) {
@ -36,5 +35,3 @@ inline bool loadDocument(const std::string &path, Poco::Dynamic::Var &document)
} // namespace utils
} // namespace valijson
#endif //VALIJSON_POCO_JSON_UTILS_HPP

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_UTILS_PROPERTY_TREE_UTILS_HPP
#define __VALIJSON_UTILS_PROPERTY_TREE_UTILS_HPP
#include <iostream>
#include <sstream>
@ -36,5 +34,3 @@ inline bool loadDocument(const std::string &path, boost::property_tree::ptree &d
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_UTILS_QTJSON_UTILS_HPP
#define __VALIJSON_UTILS_QTJSON_UTILS_HPP
#include <QFile>
@ -44,5 +42,3 @@ inline bool loadDocument(const std::string &path, QJsonValue &root)
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_UTILS_RAPIDJSON_UTILS_HPP
#define __VALIJSON_UTILS_RAPIDJSON_UTILS_HPP
#include <iostream>
@ -35,5 +33,3 @@ inline bool loadDocument(const std::string &path, rapidjson::GenericDocument<Enc
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_UTILS_UTF8_UTILS_HPP
#define __VALIJSON_UTILS_UTF8_UTILS_HPP
#include <stdexcept>
@ -60,5 +58,3 @@ inline uint64_t u8_strlen(const char *s)
} // namespace utils
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_VALIDATION_RESULTS_HPP
#define __VALIJSON_VALIDATION_RESULTS_HPP
#include <deque>
#include <string>
@ -122,5 +120,3 @@ private:
};
} // namespace valijson
#endif // __VALIJSON_VALIDATION_RESULTS_HPP

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_VALIDATION_VISITOR_HPP
#define __VALIJSON_VALIDATION_VISITOR_HPP
#include <cmath>
#include <string>
@ -241,7 +239,7 @@ public:
/**
* @brief Validate a value against a LinearItemsConstraint
*
* A LinearItemsConstraint represents an 'items' constraint that specifies,
* for each item in array, an individual sub-schema that the item must
* validate against. The LinearItemsConstraint class also captures the
@ -1702,5 +1700,3 @@ private:
};
} // namespace valijson
#endif

View File

@ -1,6 +1,4 @@
#pragma once
#ifndef __VALIJSON_VALIDATOR_HPP
#define __VALIJSON_VALIDATOR_HPP
#include <valijson/schema.hpp>
#include <valijson/validation_visitor.hpp>
@ -74,5 +72,3 @@ private:
};
} // namespace valijson
#endif