diff --git a/CMakeLists.txt b/CMakeLists.txt index 42ff98f..1cc5e08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,8 @@ else() endif() # find c++utilities -find_package(c++utilities 4.17.0 REQUIRED) +set(CONFIGURATION_PACKAGE_SUFFIX "" CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities") +find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED) # use the source directory of c++utilities for includes rather than the location where headers are going to be installed # note: this enables the tests to find the header files for c++utilities in case it is built within the same project diff --git a/generator/main.cpp b/generator/main.cpp index 656f7aa..ebe01de 100644 --- a/generator/main.cpp +++ b/generator/main.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -123,9 +122,8 @@ int main(int argc, char *argv[]) return -2; } - } catch (...) { - catchIoFailure(); - const char *errorMessage; + } catch (const std::ios_base::failure &failure) { + const char *errorMessage = failure.what(); if (os) { errorMessage = os->fail() || os->bad() ? "An IO error occured when writing to the output stream." : "An IO error occured."; } else { diff --git a/lib/binary/reflector.h b/lib/binary/reflector.h index 98691f4..a09e8a9 100644 --- a/lib/binary/reflector.h +++ b/lib/binary/reflector.h @@ -10,7 +10,6 @@ #include "../traits.h" #include -#include #include #include @@ -39,7 +38,8 @@ namespace BinaryReflector { // define traits to distinguish between "built-in" types like int, std::string, std::vector, ... and custom structs/classes template -using IsBuiltInType = Traits::Any, +using IsBuiltInType = Traits::Any, Traits::IsIteratable, Traits::IsSpecializingAnyOf, std::is_enum>; template using IsCustomType = Traits::Not>; @@ -66,7 +66,7 @@ public: template > * = nullptr> void read(Type &customType); template > * = nullptr> void read(Type &customType); - std::unordered_map m_pointer; + std::unordered_map m_pointer; }; class BinarySerializer : public IoUtilities::BinaryWriter { @@ -81,7 +81,7 @@ public: template > * = nullptr> void write(const Type &customType); template > * = nullptr> void write(const Type &customType); - std::unordered_map m_pointer; + std::unordered_map m_pointer; }; inline BinaryDeserializer::BinaryDeserializer(std::istream *stream) @@ -202,7 +202,7 @@ template (pointer.get()); const auto bigId = id >= 0x80000000000000; auto &alreadyWritten = m_pointer[id]; - byte mode = alreadyWritten ? 2 : 1; + std::uint8_t mode = alreadyWritten ? 2 : 1; if (bigId) { mode = mode | 0x4; // "flag" 3rd bit to indicate big ID } diff --git a/lib/json/errorhandling.h b/lib/json/errorhandling.h index 7936c30..9f41c6f 100644 --- a/lib/json/errorhandling.h +++ b/lib/json/errorhandling.h @@ -6,11 +6,11 @@ * \brief Contains helper for error handling when deserializing JSON files. */ -#include #include #include +#include #include #include #include @@ -21,7 +21,7 @@ namespace ReflectiveRapidJSON { /*! * \brief The JsonDeserializationErrorKind enum specifies which kind of error happend when populating variables from parsing results. */ -enum class JsonDeserializationErrorKind : byte { +enum class JsonDeserializationErrorKind : std::uint8_t { TypeMismatch, /**< The expected type does not match the type actually present in the JSON document. */ ArraySizeMismatch, /**< The expected array size does not match the actual size of the JSON array. A fixed size is expected when deserializing an std::tuple. */ ConversionError, /**< The expected type matches the type present in the JSON document, but further conversion of the value failed. */ @@ -32,7 +32,7 @@ enum class JsonDeserializationErrorKind : byte { * \brief The JsonType enum specifies the JSON data type. * \remarks This is currently only used for error handling to propagate expected and actual types in case of a mismatch. */ -enum class JsonType : byte { +enum class JsonType : std::uint8_t { Null, Number, Bool, @@ -164,7 +164,13 @@ struct JsonDeserializationErrors : public std::vector /// \brief The index in the array which is currently processed. std::size_t currentIndex; /// \brief The list of fatal error types in form of flags. - enum class ThrowOn : byte { None = 0, TypeMismatch = 0x1, ArraySizeMismatch = 0x2, ConversionError = 0x4, UnexpectedDuplicate = 0x8 } throwOn; + enum class ThrowOn : std::uint8_t { + None = 0, + TypeMismatch = 0x1, + ArraySizeMismatch = 0x2, + ConversionError = 0x4, + UnexpectedDuplicate = 0x8 + } throwOn; private: void throwMaybe(ThrowOn on) const; @@ -186,7 +192,7 @@ inline JsonDeserializationErrors::JsonDeserializationErrors() */ constexpr JsonDeserializationErrors::ThrowOn operator|(JsonDeserializationErrors::ThrowOn lhs, JsonDeserializationErrors::ThrowOn rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); + return static_cast(static_cast(lhs) | static_cast(rhs)); } /*! @@ -196,7 +202,7 @@ constexpr JsonDeserializationErrors::ThrowOn operator|(JsonDeserializationErrors */ inline void JsonDeserializationErrors::throwMaybe(ThrowOn on) const { - if (static_cast(throwOn) & static_cast(on)) { + if (static_cast(throwOn) & static_cast(on)) { throw back(); } } diff --git a/lib/json/reflector.h b/lib/json/reflector.h index 2760bd7..8c6436a 100644 --- a/lib/json/reflector.h +++ b/lib/json/reflector.h @@ -9,8 +9,6 @@ #include "../traits.h" -#include - #include #include #include @@ -153,7 +151,8 @@ inline void push(Type reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_ template > * = nullptr> inline void push(Type reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) { - value.Set(static_cast::type>, uint64, int64>>(reflectable), allocator); + value.Set(static_cast::type>, std::uint64_t, std::int64_t>>(reflectable), + allocator); } /*! @@ -459,7 +458,7 @@ template > * = nullptr> inline void pull( Type &reflectable, const RAPIDJSON_NAMESPACE::GenericValue> &value, JsonDeserializationErrors *errors) { - using ExpectedType = Traits::Conditional::type>, uint64, int64>; + using ExpectedType = Traits::Conditional::type>, std::uint64_t, std::int64_t>; if (!value.Is()) { if (errors) { errors->reportTypeMismatch(value.GetType()); diff --git a/lib/tests/binaryreflector.cpp b/lib/tests/binaryreflector.cpp index 01a805e..31a38fe 100644 --- a/lib/tests/binaryreflector.cpp +++ b/lib/tests/binaryreflector.cpp @@ -11,6 +11,7 @@ using TestUtilities::operator<<; // must be visible prior to the call site #include #include +#include #include #include #include @@ -38,7 +39,7 @@ enum SomeEnum { SomeEnumItem3, }; -enum class SomeEnumClass : uint16 { +enum class SomeEnumClass : std::uint16_t { Item1, Item2, Item3,