diff --git a/include/valijson/adapters/adapter.hpp b/include/valijson/adapters/adapter.hpp index 4234ac4..8491040 100644 --- a/include/valijson/adapters/adapter.hpp +++ b/include/valijson/adapters/adapter.hpp @@ -35,7 +35,7 @@ public: * @brief Virtual destructor defined to ensure deletion via base-class * pointers is safe. */ - virtual ~Adapter() { }; + virtual ~Adapter() = default;; /** * @brief Apply a callback function to each value in an array. diff --git a/include/valijson/constraint_builder.hpp b/include/valijson/constraint_builder.hpp index 768f0ea..53407a9 100644 --- a/include/valijson/constraint_builder.hpp +++ b/include/valijson/constraint_builder.hpp @@ -13,7 +13,7 @@ namespace constraints { class ConstraintBuilder { public: - virtual ~ConstraintBuilder() {} + virtual ~ConstraintBuilder() = default; virtual constraints::Constraint * make(const adapters::Adapter &) const = 0; }; diff --git a/include/valijson/constraints/concrete_constraints.hpp b/include/valijson/constraints/concrete_constraints.hpp index 41ce08e..acdeffd 100644 --- a/include/valijson/constraints/concrete_constraints.hpp +++ b/include/valijson/constraints/concrete_constraints.hpp @@ -365,6 +365,7 @@ public: m_enumValues.push_back(value); } catch (...) { delete value; + value = nullptr; throw; } } diff --git a/include/valijson/constraints/constraint.hpp b/include/valijson/constraints/constraint.hpp index 98616f8..03b6444 100644 --- a/include/valijson/constraints/constraint.hpp +++ b/include/valijson/constraints/constraint.hpp @@ -21,7 +21,7 @@ struct Constraint /** * @brief Virtual destructor. */ - virtual ~Constraint() { } + virtual ~Constraint() = default; /** * @brief Perform an action on the constraint using the visitor pattern. diff --git a/include/valijson/constraints/constraint_visitor.hpp b/include/valijson/constraints/constraint_visitor.hpp index 1623bd6..da3f3d7 100644 --- a/include/valijson/constraints/constraint_visitor.hpp +++ b/include/valijson/constraints/constraint_visitor.hpp @@ -36,7 +36,7 @@ class UniqueItemsConstraint; class ConstraintVisitor { protected: - virtual ~ConstraintVisitor() {} + virtual ~ConstraintVisitor() = default; // Shorten type names for derived classes outside of this namespace typedef constraints::AllOfConstraint AllOfConstraint; diff --git a/include/valijson/internal/json_pointer.hpp b/include/valijson/internal/json_pointer.hpp index e22fada..ad3064c 100644 --- a/include/valijson/internal/json_pointer.hpp +++ b/include/valijson/internal/json_pointer.hpp @@ -50,7 +50,7 @@ inline char decodePercentEncodedChar(const std::string &digits) errno = 0; const char *begin = digits.c_str(); - char *end = NULL; + char *end = nullptr; const unsigned long value = strtoul(begin, &end, 16); if (end != begin && *end != '\0') { throw std::runtime_error("Failed to decode %-encoded character '" + @@ -178,7 +178,7 @@ inline AdapterType resolveJsonPointer( return resolveJsonPointer(node, jsonPointer, jsonPointerNext); } else if (node.isArray()) { - if (referenceToken.compare("-") == 0) { + if (referenceToken == "-") { throw std::runtime_error("Hyphens cannot be used as array indices " "since the requested array element does not yet exist"); } diff --git a/include/valijson/internal/json_reference.hpp b/include/valijson/internal/json_reference.hpp index ac72cdd..fc67a34 100644 --- a/include/valijson/internal/json_reference.hpp +++ b/include/valijson/internal/json_reference.hpp @@ -20,7 +20,7 @@ namespace json_reference { inline opt::optional getJsonReferenceUri( const std::string &jsonRef) { - const size_t ptrPos = jsonRef.find("#"); + 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 @@ -47,7 +47,7 @@ inline opt::optional getJsonReferencePointer( // 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("#"); + const size_t ptrPos = jsonRef.find('#'); if (ptrPos != std::string::npos) { return jsonRef.substr(ptrPos + 1); }