diff options
-rw-r--r-- | Jamroot.jam | 25 | ||||
-rw-r--r-- | slicer/db/sqlInsertSerializer.h | 2 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.h | 2 | ||||
-rw-r--r-- | slicer/db/sqlTablePatchSerializer.h | 2 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.h | 2 | ||||
-rw-r--r-- | slicer/ice/serializer.h | 8 | ||||
-rw-r--r-- | slicer/json/serializer.cpp | 52 | ||||
-rw-r--r-- | slicer/json/serializer.h | 12 | ||||
-rw-r--r-- | slicer/slicer/modelParts.h | 9 | ||||
-rw-r--r-- | slicer/slicer/modelPartsTypes.h | 166 | ||||
-rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 24 | ||||
-rw-r--r-- | slicer/slicer/serializer.h | 13 | ||||
-rw-r--r-- | slicer/test/compilation.cpp | 6 | ||||
-rw-r--r-- | slicer/test/conversions.h | 4 | ||||
-rw-r--r-- | slicer/tool/parser.cpp | 2 | ||||
-rw-r--r-- | slicer/tool/parser.h | 37 | ||||
-rw-r--r-- | slicer/xml/serializer.cpp | 30 | ||||
-rw-r--r-- | slicer/xml/serializer.h | 12 |
18 files changed, 236 insertions, 172 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index c332369..9f35c7f 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -12,22 +12,37 @@ project <define>ICE_CPP11_MAPPING <cxxstd>17 <visibility>hidden - <linkflags>"-Wl,-z,defs,--warn-once,--gc-sections" + <linkflags>"-Wl,-z,defs,--warn-once,--gc-sections" <variant>release:<cxxflags>"-flto" <toolset>gcc:<variant>release:<cxxflags>"-flto=2" <variant>release:<linkflags>"-flto" <toolset>gcc:<variant>release:<linkflags>"-flto=2" - <variant>debug:<warnings>extra - <variant>debug:<warnings-as-errors>on - <variant>coverage:<coverage>on + <variant>debug:<warnings>extra + <variant>debug:<warnings-as-errors>on + <variant>coverage:<coverage>on <toolset>tidy:<checkxx>boost-* <toolset>tidy:<checkxx>bugprone-* <toolset>tidy:<checkxx>clang-* <toolset>tidy:<checkxx>misc-* <toolset>tidy:<checkxx>modernize-* + <toolset>tidy:<xcheckxx>modernize-use-trailing-return-type <toolset>tidy:<checkxx>hicpp-* <toolset>tidy:<checkxx>performance-* - ; + <toolset>tidy:<exclude>test/bin/tidy/debug/classes.h + <toolset>tidy:<exclude>test/bin/tidy/debug/classtype.h + <toolset>tidy:<exclude>test/bin/tidy/debug/collections.h + <toolset>tidy:<exclude>test/bin/tidy/debug/enums.h + <toolset>tidy:<exclude>test/bin/tidy/debug/inheritance.h + <toolset>tidy:<exclude>test/bin/tidy/debug/interfaces.h + <toolset>tidy:<exclude>test/bin/tidy/debug/json.h + <toolset>tidy:<exclude>test/bin/tidy/debug/locals.h + <toolset>tidy:<exclude>test/bin/tidy/debug/optionals.h + <toolset>tidy:<exclude>test/bin/tidy/debug/structs.h + <toolset>tidy:<exclude>test/bin/tidy/debug/types.h + <toolset>tidy:<exclude>test/bin/tidy/debug/xml.h + <toolset>tidy:<exclude>slicer/bin/common.h + <toolset>tidy:<exclude>xml/bin/tidy/debug/cxxstd-17-iso/xmlExceptions.h + ; build-project slicer ; diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h index 3534b87..175706f 100644 --- a/slicer/db/sqlInsertSerializer.h +++ b/slicer/db/sqlInsertSerializer.h @@ -11,7 +11,7 @@ namespace Slicer { public: SqlInsertSerializer(DB::Connection * const, std::string tableName); - virtual void Serialize(Slicer::ModelPartForRootPtr) override; + void Serialize(Slicer::ModelPartForRootPtr) override; protected: void SerializeObject(const Slicer::ModelPartPtr &) const; diff --git a/slicer/db/sqlSelectDeserializer.h b/slicer/db/sqlSelectDeserializer.h index 736bb11..e9afd1d 100644 --- a/slicer/db/sqlSelectDeserializer.h +++ b/slicer/db/sqlSelectDeserializer.h @@ -10,7 +10,7 @@ namespace Slicer { public: SqlSelectDeserializer(DB::SelectCommand *, Ice::optional<std::string> typeIdCol = Ice::optional<std::string>()); - virtual void Deserialize(Slicer::ModelPartForRootPtr) override; + void Deserialize(Slicer::ModelPartForRootPtr) override; protected: void DLL_PRIVATE DeserializeSimple(const Slicer::ModelPartPtr &); diff --git a/slicer/db/sqlTablePatchSerializer.h b/slicer/db/sqlTablePatchSerializer.h index 425ce95..00ea328 100644 --- a/slicer/db/sqlTablePatchSerializer.h +++ b/slicer/db/sqlTablePatchSerializer.h @@ -9,7 +9,7 @@ namespace Slicer { public: SqlTablePatchSerializer(DB::Connection * const, DB::TablePatch &); - virtual void Serialize(Slicer::ModelPartForRootPtr) override; + void Serialize(Slicer::ModelPartForRootPtr) override; private: void createTemporaryTable(); diff --git a/slicer/db/sqlUpdateSerializer.h b/slicer/db/sqlUpdateSerializer.h index 7c451b2..a3462f8 100644 --- a/slicer/db/sqlUpdateSerializer.h +++ b/slicer/db/sqlUpdateSerializer.h @@ -10,7 +10,7 @@ namespace Slicer { public: SqlUpdateSerializer(DB::Connection * const, std::string tableName); - virtual void Serialize(Slicer::ModelPartForRootPtr) override; + void Serialize(Slicer::ModelPartForRootPtr) override; protected: void SerializeObject(const Slicer::ModelPartPtr &) const; diff --git a/slicer/ice/serializer.h b/slicer/ice/serializer.h index d534b3e..c1768c0 100644 --- a/slicer/ice/serializer.h +++ b/slicer/ice/serializer.h @@ -21,7 +21,7 @@ namespace Slicer { public: IceBlobSerializer(Ice::ByteSeq &); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; private: Ice::ByteSeq & blob; @@ -31,7 +31,7 @@ namespace Slicer { public: IceStreamSerializer(std::ostream &); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; protected: std::ostream & strm; @@ -42,7 +42,7 @@ namespace Slicer { public: IceBlobDeserializer(const Ice::ByteSeq &); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: const Ice::ByteSeq & blob; @@ -52,7 +52,7 @@ namespace Slicer { public: IceStreamDeserializer(std::istream &); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: std::istream & strm; diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp index d56a98e..b9b0c69 100644 --- a/slicer/json/serializer.cpp +++ b/slicer/json/serializer.cpp @@ -248,21 +248,37 @@ namespace Slicer { mp = mp->GetSubclassModelPart(*typeId); } } - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterate, &std::get<json::Object>(*n).insert({name, nn}).first->second, _1, _2)); + mp->OnEachChild( + [capture0 = &std::get<json::Object>(*n).insert({name, nn}).first->second] + (auto && PH1, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterate(capture0, PH1, PH2); + }); } break; case mpt_Sequence: if (mp->HasValue()) { - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateSeq, &std::get<json::Object>(*n).insert({name, json::Array()}).first->second, _2)); + mp->OnEachChild( + [capture0 = &std::get<json::Object>(*n).insert({name, json::Array()}).first->second] + (auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateSeq(capture0, PH2); + }); } break; case mpt_Dictionary: if (mp->HasValue()) { if (metaDataFlagSet(mp->GetMetadata(), md_object)) { - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateDictObj, &std::get<json::Object>(*n).insert({name, json::Object()}).first->second, _2)); + mp->OnEachChild( + [capture0 = &std::get<json::Object>(*n).insert({name, json::Object()}).first->second] + (auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateDictObj(capture0, PH2); + }); } else { - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateSeq, &std::get<json::Object>(*n).insert({name, json::Array()}).first->second, _2)); + mp->OnEachChild( + [capture0 = &std::get<json::Object>(*n).insert({name, json::Array()}).first->second] + (auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateSeq(capture0, PH2); + }); } } break; @@ -288,20 +304,28 @@ namespace Slicer { mp = mp->GetSubclassModelPart(*typeId); } } - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterate, n, _1, _2)); + mp->OnEachChild([n](auto && PH1, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterate(n, PH1, PH2); + }); break; case mpt_Sequence: *n = json::Array(); - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateSeq, n, _2)); + mp->OnEachChild([n](auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateSeq(n, PH2); + }); break; case mpt_Dictionary: if (metaDataFlagSet(mp->GetMetadata(), md_object)) { *n = json::Object(); - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateDictObj, n, _2)); + mp->OnEachChild([n](auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateDictObj(n, PH2); + }); } else { *n = json::Array(); - mp->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterate, n, _1, _2)); + mp->OnEachChild([n](auto && PH1, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterate(n, PH1, PH2); + }); } break; } @@ -330,7 +354,9 @@ namespace Slicer { JsonStreamSerializer::Serialize(ModelPartForRootPtr modelRoot) { json::Value doc; - modelRoot->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateRoot, &doc, _2)); + modelRoot->OnEachChild([&doc](auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateRoot(&doc, PH2); + }); json::serializeValue(doc, strm, "utf-8"); } @@ -357,7 +383,9 @@ namespace Slicer { JsonFileSerializer::Serialize(ModelPartForRootPtr modelRoot) { json::Value doc; - modelRoot->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateRoot, &doc, _2)); + modelRoot->OnEachChild([&doc](auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateRoot(&doc, PH2); + }); std::ofstream outFile(path); json::serializeValue(doc, outFile, "utf-8"); } @@ -382,7 +410,9 @@ namespace Slicer { void JsonValueSerializer::Serialize(ModelPartForRootPtr modelRoot) { - modelRoot->OnEachChild(std::bind(&JsonSerializer::ModelTreeIterateRoot, &value, _2)); + modelRoot->OnEachChild([this](auto &&, auto && PH2, auto &&) { + return JsonSerializer::ModelTreeIterateRoot(&value, PH2); + }); } } diff --git a/slicer/json/serializer.h b/slicer/json/serializer.h index 64679ed..ed666aa 100644 --- a/slicer/json/serializer.h +++ b/slicer/json/serializer.h @@ -18,7 +18,7 @@ namespace Slicer { public: JsonStreamSerializer(std::ostream &); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; protected: std::ostream & strm; @@ -28,7 +28,7 @@ namespace Slicer { public: JsonFileSerializer(std::filesystem::path); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; protected: const std::filesystem::path path; @@ -38,7 +38,7 @@ namespace Slicer { public: JsonValueSerializer(json::Value &); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; protected: json::Value & value; @@ -48,7 +48,7 @@ namespace Slicer { public: JsonStreamDeserializer(std::istream &); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: std::istream & strm; @@ -58,7 +58,7 @@ namespace Slicer { public: JsonFileDeserializer(std::filesystem::path); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: const std::filesystem::path path; @@ -68,7 +68,7 @@ namespace Slicer { public: JsonValueDeserializer(const json::Value &); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: const json::Value & value; diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index 3ec4201..f31a8c0 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -95,8 +95,8 @@ namespace Slicer { explicit ChildRef(ModelPartPtr); explicit ChildRef(ModelPartPtr, const Metadata &); - ModelPartPtr Child() const; - const Metadata & ChildMetaData() const; + [[nodiscard]] ModelPartPtr Child() const; + [[nodiscard]] const Metadata & ChildMetaData() const; explicit operator bool() const; private: @@ -111,8 +111,9 @@ namespace Slicer { bool filter(const HookFilter & flt); void apply(const ChildHandler & ch, const ModelPartPtr & modelPart); - virtual const Metadata & GetMetadata() const = 0; + [[nodiscard]] virtual const Metadata & GetMetadata() const = 0; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) const std::string name; }; @@ -167,6 +168,7 @@ namespace Slicer { protected: explicit ModelPartModel() : Model(nullptr) { } explicit ModelPartModel(T * m) : Model(m) { } + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) T * Model; }; @@ -184,6 +186,7 @@ namespace Slicer { virtual void Read(::Ice::InputStream &) = 0; ModelPartPtr GetContainedModelPart() override; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) ModelPartPtr mp; }; } diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index 3c69f76..99ccb81 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -17,7 +17,7 @@ namespace Slicer { ModelPartForRoot(T * o); const std::string & GetRootName() const override; - virtual bool HasValue() const override; + bool HasValue() const override; void Write(::Ice::OutputStream &) const override; void Read(::Ice::InputStream &) override; @@ -29,32 +29,32 @@ namespace Slicer { class DLL_PUBLIC ModelPartForSimpleBase : public ModelPart { public: - virtual void OnEachChild(const ChildHandler &) override; - virtual ChildRef GetAnonChildRef(const HookFilter &) override; - virtual ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; - virtual bool HasValue() const override; - virtual ModelPartType GetType() const override; + void OnEachChild(const ChildHandler &) override; + ChildRef GetAnonChildRef(const HookFilter &) override; + ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; + bool HasValue() const override; + ModelPartType GetType() const override; static const ModelPartType type; }; template<typename T> class DLL_PUBLIC ModelPartForSimple : public ModelPartForSimpleBase, protected ModelPartModel<T> { public: - typedef T element_type; + using element_type = T; ModelPartForSimple(T * h); - virtual void SetValue(ValueSource && s) override; - virtual bool GetValue(ValueTarget && s) override; + void SetValue(ValueSource && s) override; + bool GetValue(ValueTarget && s) override; }; class DLL_PUBLIC ModelPartForConvertedBase : public ModelPart { public: - virtual void OnEachChild(const ChildHandler &) override; - virtual ChildRef GetAnonChildRef(const HookFilter &) override; - virtual ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; - virtual bool HasValue() const override; - virtual ModelPartType GetType() const override; + void OnEachChild(const ChildHandler &) override; + ChildRef GetAnonChildRef(const HookFilter &) override; + ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; + bool HasValue() const override; + ModelPartType GetType() const override; static const ModelPartType type; protected: @@ -71,39 +71,40 @@ namespace Slicer { template<typename T, typename M, T M::* MV> class DLL_PUBLIC ModelPartForConverted : public ModelPartForConvertedBase, protected ModelPartModel<T> { public: - typedef T element_type; + using element_type = T; ModelPartForConverted(T * h); - virtual void SetValue(ValueSource && s) override; - virtual bool GetValue(ValueTarget && s) override; + void SetValue(ValueSource && s) override; + bool GetValue(ValueTarget && s) override; }; template<typename T, typename M, Ice::optional<T> M::* MV> class DLL_PUBLIC ModelPartForConverted<Ice::optional<T>, M, MV> : public ModelPartForConvertedBase, protected ModelPartModel<Ice::optional<T>> { public: - typedef Ice::optional<T> element_type; + using element_type = Ice::optional<T>; ModelPartForConverted(Ice::optional<T> * h); - virtual void SetValue(ValueSource && s) override; - virtual bool GetValue(ValueTarget && s) override; - virtual bool HasValue() const override; + void SetValue(ValueSource && s) override; + bool GetValue(ValueTarget && s) override; + bool HasValue() const override; }; class DLL_PUBLIC ModelPartForOptionalBase : public ModelPart { public: - virtual void OnEachChild(const ChildHandler & ch) override; - virtual void Complete() override; - virtual ChildRef GetAnonChildRef(const HookFilter & flt) override; - virtual ChildRef GetChildRef(const std::string & name, const HookFilter & flt, bool matchCase = true) override; - virtual void SetValue(ValueSource && s) override; - virtual bool HasValue() const override; - virtual bool IsOptional() const override; - virtual const Metadata & GetMetadata() const override; + void OnEachChild(const ChildHandler & ch) override; + void Complete() override; + ChildRef GetAnonChildRef(const HookFilter & flt) override; + ChildRef GetChildRef(const std::string & name, const HookFilter & flt, bool matchCase = true) override; + void SetValue(ValueSource && s) override; + bool HasValue() const override; + bool IsOptional() const override; + const Metadata & GetMetadata() const override; protected: virtual bool hasModel() const = 0; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) ModelPartPtr modelPart; }; @@ -111,17 +112,17 @@ namespace Slicer { class DLL_PUBLIC ModelPartForOptional : public ModelPartForOptionalBase, protected ModelPartModel<Ice::optional<typename T::element_type> > { public: ModelPartForOptional(Ice::optional< typename T::element_type > * h); - virtual void Create() override; - virtual bool GetValue(ValueTarget && s) override; - virtual ModelPartType GetType() const override; + void Create() override; + bool GetValue(ValueTarget && s) override; + ModelPartType GetType() const override; protected: - virtual bool hasModel() const override; + bool hasModel() const override; }; class DLL_PUBLIC ModelPartForComplexBase : public ModelPart { public: - virtual ModelPartType GetType() const override; + ModelPartType GetType() const override; static const ModelPartType type; protected: @@ -140,7 +141,7 @@ namespace Slicer { class DLL_PUBLIC ModelPartForComplex : public ModelPartForComplexBase { public: class DLL_PRIVATE HookBase; - typedef std::unique_ptr<HookBase> HookPtr; + using HookPtr = std::unique_ptr<HookBase>; template <typename MT, typename MP> class DLL_PRIVATE Hook; @@ -148,12 +149,12 @@ namespace Slicer { template <typename MT, typename MP> class DLL_PRIVATE HookMetadata; - virtual void OnEachChild(const ChildHandler & ch) override; + void OnEachChild(const ChildHandler & ch) override; - virtual ChildRef GetAnonChildRef(const HookFilter & flt) override; + ChildRef GetAnonChildRef(const HookFilter & flt) override; ChildRef GetChildRef(const std::string & name, const HookFilter & flt, bool matchCase = true) override; - virtual const Metadata & GetMetadata() const override; + const Metadata & GetMetadata() const override; virtual T * GetModel() = 0; @@ -173,25 +174,25 @@ namespace Slicer { template<typename T> class DLL_PUBLIC ModelPartForClass : public ModelPartForComplex<T>, protected ModelPartModel<std::shared_ptr<T> > { public: - typedef std::shared_ptr<T> element_type; + using element_type = std::shared_ptr<T>; ModelPartForClass(element_type * h); - virtual void Create() override; + void Create() override; T * GetModel() override; - virtual ModelPartPtr GetSubclassModelPart(const std::string & name) override; + ModelPartPtr GetSubclassModelPart(const std::string & name) override; - virtual bool HasValue() const override; + [[nodiscard]] bool HasValue() const override; - virtual TypeId GetTypeId() const override; + [[nodiscard]] TypeId GetTypeId() const override; template<typename dummy = T> const std::string & getTypeId(typename std::enable_if<std::is_base_of<Ice::Object, dummy>::value>::type * = nullptr) const; template<typename dummy = T> std::string getTypeId(typename std::enable_if<!std::is_base_of<Ice::Object, dummy>::value>::type * = nullptr) const; - virtual Ice::optional<std::string> GetTypeIdProperty() const override; + [[nodiscard]] Ice::optional<std::string> GetTypeIdProperty() const override; static const std::string typeIdProperty; static const std::string * className; @@ -209,38 +210,38 @@ namespace Slicer { template<typename T> class DLL_PUBLIC ModelPartForStruct : public ModelPartForComplex<T>, protected ModelPartModel<T> { public: - typedef T element_type; + using element_type = T; ModelPartForStruct(T * o); T * GetModel() override; - virtual bool HasValue() const override; + [[nodiscard]] bool HasValue() const override; }; class DLL_PUBLIC ModelPartForEnumBase : public ModelPart { public: - virtual void OnEachChild(const ChildHandler &) override; + void OnEachChild(const ChildHandler &) override; ChildRef GetAnonChildRef(const HookFilter &) override; ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; - virtual bool HasValue() const override; - virtual ModelPartType GetType() const override; + bool HasValue() const override; + ModelPartType GetType() const override; static const ModelPartType type; }; template<typename T> class DLL_PUBLIC ModelPartForEnum : public ModelPartForEnumBase, protected ModelPartModel<T> { public: - typedef T element_type; + using element_type = T; class DLL_PRIVATE Enumerations; ModelPartForEnum(T * s); - virtual const Metadata & GetMetadata() const override; + const Metadata & GetMetadata() const override; - virtual void SetValue(ValueSource && s) override; + void SetValue(ValueSource && s) override; - virtual bool GetValue(ValueTarget && s) override; + bool GetValue(ValueTarget && s) override; static const Metadata metadata; static const Enumerations enumerations; @@ -250,27 +251,27 @@ namespace Slicer { class DLL_PUBLIC ModelPartForSequenceBase : public ModelPart { public: - virtual bool HasValue() const override; - virtual ModelPartType GetType() const override; + bool HasValue() const override; + ModelPartType GetType() const override; static const ModelPartType type; }; template<typename T> class DLL_PUBLIC ModelPartForSequence : public ModelPartForSequenceBase, protected ModelPartModel<T> { public: - typedef T element_type; + using element_type = T; ModelPartForSequence(T * s); - virtual void OnEachChild(const ChildHandler & ch) override; + void OnEachChild(const ChildHandler & ch) override; ChildRef GetAnonChildRef(const HookFilter &) override; ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; - virtual const Metadata & GetMetadata() const override; + const Metadata & GetMetadata() const override; - virtual ModelPartPtr GetContainedModelPart() override; + ModelPartPtr GetContainedModelPart() override; static const Metadata metadata; static const std::string elementName; @@ -284,8 +285,9 @@ namespace Slicer { public: ModelPartForDictionaryElementInserter(T * d); - virtual void Complete() override; + void Complete() override; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) typename T::value_type value; private: @@ -294,27 +296,27 @@ namespace Slicer { class DLL_PUBLIC ModelPartForDictionaryBase : public ModelPart { public: - virtual bool HasValue() const override; - virtual ModelPartType GetType() const override; + bool HasValue() const override; + ModelPartType GetType() const override; static const ModelPartType type; }; template<typename T> class DLL_PUBLIC ModelPartForDictionary : public ModelPartForDictionaryBase, protected ModelPartModel<T> { public: - typedef T element_type; + using element_type = T; ModelPartForDictionary(T * d); - virtual void OnEachChild(const ChildHandler & ch) override; + void OnEachChild(const ChildHandler & ch) override; ChildRef GetAnonChildRef(const HookFilter &) override; ChildRef GetChildRef(const std::string & name, const HookFilter &, bool matchCase = true) override; - virtual const Metadata & GetMetadata() const override; + const Metadata & GetMetadata() const override; - virtual ModelPartPtr GetContainedModelPart() override; + ModelPartPtr GetContainedModelPart() override; static const Metadata metadata; static const std::string pairName; @@ -323,21 +325,21 @@ namespace Slicer { template<typename T> class DLL_PUBLIC Stream { public: - typedef std::function<void(const T &)> Consumer; - typedef T element_type; + using Consumer = std::function<void(const T &)>; + using element_type = T; virtual void Produce(const Consumer & c) = 0; }; class DLL_PUBLIC ModelPartForStreamBase : public ModelPart { public: - virtual ModelPartType GetType() const override; - virtual bool HasValue() const override; - virtual ChildRef GetAnonChildRef(const HookFilter &) override; - virtual ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; + ModelPartType GetType() const override; + bool HasValue() const override; + ChildRef GetAnonChildRef(const HookFilter &) override; + ChildRef GetChildRef(const std::string &, const HookFilter &, bool matchCase = true) override; - virtual ModelPartPtr GetContainedModelPart() override = 0; - virtual void OnEachChild(const ChildHandler & ch) override = 0; + ModelPartPtr GetContainedModelPart() override = 0; + void OnEachChild(const ChildHandler & ch) override = 0; }; template<typename T> @@ -345,19 +347,19 @@ namespace Slicer { public: ModelPartForStream(Stream<T> * s); - virtual ModelPartPtr GetContainedModelPart() override; - virtual void OnEachChild(const ChildHandler & ch) override; + ModelPartPtr GetContainedModelPart() override; + void OnEachChild(const ChildHandler & ch) override; }; class DLL_PUBLIC ModelPartForStreamRootBase : public ModelPartForRootBase { public: ModelPartForStreamRootBase(const ModelPartPtr & mp); - virtual void Write(Ice::OutputStream&) const override; - virtual void Read(Ice::InputStream&) override; - virtual bool HasValue() const override; - virtual void OnEachChild(const ChildHandler & ch) override; - virtual const std::string & GetRootName() const override = 0; + void Write(Ice::OutputStream&) const override; + void Read(Ice::InputStream&) override; + bool HasValue() const override; + void OnEachChild(const ChildHandler & ch) override; + const std::string & GetRootName() const override = 0; }; template<typename T> @@ -365,7 +367,7 @@ namespace Slicer { public: ModelPartForStreamRoot(Stream<T> * s); - virtual const std::string & GetRootName() const override; + const std::string & GetRootName() const override; private: Stream<T> * stream; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index e75c849..5153b2e 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -65,8 +65,8 @@ namespace Slicer { typeWrite(::Ice::OutputStream & s, const ::Ice::optional<T> & m) { if constexpr (!isLocal<T>::value) { - typedef Ice::StreamableTraits<T> traits; - typedef Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength> SOH; + using traits = Ice::StreamableTraits<T>; + using SOH = Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength>; s.startEncapsulation(); if (m && s.writeOptional(0, SOH::optionalFormat)) { SOH::write(&s, *m); @@ -95,8 +95,8 @@ namespace Slicer { typeRead(::Ice::InputStream & s, ::Ice::optional<T> & m) { if constexpr (!isLocal<T>::value) { - typedef Ice::StreamableTraits<T> traits; - typedef Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength> SOH; + using traits = Ice::StreamableTraits<T>; + using SOH = Ice::StreamOptionalHelper<T, traits::helper, traits::fixedLength>; s.startEncapsulation(); if (s.readOptional(0, SOH::optionalFormat)) { m = T(); @@ -185,7 +185,7 @@ namespace Slicer { template <typename R, typename ... Args> struct function_traits; template <typename R, typename ... Args> struct function_traits<std::function<R(Args...)>> { template<int A> struct arg { - typedef typename std::tuple_element<A, std::tuple<Args...>>::type type; + using type = typename std::tuple_element<A, std::tuple<Args...>>::type; }; }; template <typename F> struct callable_traits : public function_traits<std::function<typename std::remove_pointer<F>::type>> { }; @@ -193,7 +193,7 @@ namespace Slicer { // Converters that remove "optionalness". template <typename X> struct Coerce { - typedef typename std::remove_const<typename std::remove_reference<X>::type>::type T; + using T = typename std::remove_const<typename std::remove_reference<X>::type>::type; T & operator()(T & x) const { return x; } const T & operator()(const T & x) const { return x; } @@ -206,7 +206,7 @@ namespace Slicer { }; template <typename X> struct Coerce<Ice::optional<X>> { - typedef typename std::remove_const<typename std::remove_reference<X>::type>::type T; + using T = typename std::remove_const<typename std::remove_reference<X>::type>::type; Ice::optional<T> & operator()(Ice::optional<T> & x) const { return x; } const Ice::optional<T> & operator()(const Ice::optional<T> & x) const { return x; } @@ -221,7 +221,7 @@ namespace Slicer { bool ModelPartForConvertedBase::tryConvertFrom(ValueSource & vsp, MT * model, const Conv & conv) { if (auto vspt = dynamic_cast<TValueSource<ET> *>(&vsp)) { - typedef typename callable_traits<Conv>::template arg<0>::type CA; + using CA = typename callable_traits<Conv>::template arg<0>::type; ET tmp; vspt->set(tmp); auto converted = conv(Coerce<CA>()(tmp)); @@ -251,8 +251,8 @@ namespace Slicer { TryConvertResult ModelPartForConvertedBase::tryConvertTo(ValueTarget & vsp, const MT * model, const Conv & conv) { if (auto vspt = dynamic_cast<TValueTarget<ET> *>(&vsp)) { - typedef typename callable_traits<Conv>::template arg<0>::type CA; - typedef typename std::remove_const<typename std::remove_reference<CA>::type>::type CAR; + using CA = typename callable_traits<Conv>::template arg<0>::type; + using CAR = typename std::remove_const<typename std::remove_reference<CA>::type>::type; if (Coerce<CAR>::valueExists(*model)) { auto converted = conv(Coerce<CA>()(*model)); if (Coerce<ET>::valueExists(converted)) { @@ -399,7 +399,7 @@ namespace Slicer { virtual ~HookBase() = default; virtual ModelPartPtr Get(T * t) const = 0; - virtual const Metadata & GetMetadata() const override + const Metadata & GetMetadata() const override { return emptyMetadata; } @@ -434,7 +434,7 @@ namespace Slicer { { } - virtual const Metadata & GetMetadata() const override + const Metadata & GetMetadata() const override { return metadata; } diff --git a/slicer/slicer/serializer.h b/slicer/slicer/serializer.h index 73d4617..90acc18 100644 --- a/slicer/slicer/serializer.h +++ b/slicer/slicer/serializer.h @@ -5,19 +5,16 @@ #include <slicer/modelParts.h> #include <visibility.h> #include <factory.h> +#include <c++11Helpers.h> namespace Slicer { class DLL_PUBLIC Serializer { public: Serializer() = default; - Serializer(const Serializer &) = delete; - Serializer(Serializer &&) = delete; + SPECIAL_MEMBERS_DEFAULT(Serializer); virtual ~Serializer() = default; - Serializer & operator=(const Serializer &) = delete; - Serializer & operator=(Serializer &&) = delete; - virtual void Serialize(ModelPartForRootPtr) = 0; }; using SerializerPtr = std::shared_ptr<Serializer>; @@ -25,14 +22,10 @@ namespace Slicer { class DLL_PUBLIC Deserializer { public: Deserializer() = default; - Deserializer(const Deserializer &) = delete; - Deserializer(Deserializer &&) = delete; + SPECIAL_MEMBERS_DEFAULT(Deserializer); virtual ~Deserializer() = default; - Deserializer & operator=(const Deserializer &) = delete; - Deserializer & operator=(Deserializer &&) = delete; - virtual void Deserialize(ModelPartForRootPtr) = 0; }; using DeserializerPtr = std::shared_ptr<Deserializer>; diff --git a/slicer/test/compilation.cpp b/slicer/test/compilation.cpp index 445e867..0475bbe 100644 --- a/slicer/test/compilation.cpp +++ b/slicer/test/compilation.cpp @@ -10,8 +10,6 @@ BOOST_TEST_DONT_PRINT_LOG_VALUE(std::type_info); // LCOV_EXCL_STOP -namespace pl = std::placeholders; - #define TypeTest(Var, Expr, Explicit, Expected) \ Var obj = Expr; \ Slicer::ModelPartPtr mpp = Slicer::ModelPart::CreateFor(obj); \ @@ -54,7 +52,7 @@ BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_sequenceclasses ) BOOST_REQUIRE(cmpp); BOOST_REQUIRE_EQUAL(Slicer::mpt_Complex, cmpp->GetType()); std::vector<std::string> names; - cmpp->OnEachChild(std::bind(&hookHandler, &names, pl::_1, pl::_2, pl::_3)); + cmpp->OnEachChild(std::bind(&hookHandler, &names, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); BOOST_REQUIRE_EQUAL(2, names.size()); BOOST_REQUIRE_EQUAL("a", names.front()); BOOST_REQUIRE_EQUAL("b", names.back()); @@ -67,7 +65,7 @@ BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_sequencestructs ) BOOST_REQUIRE(cmpp); BOOST_REQUIRE_EQUAL(Slicer::mpt_Complex, cmpp->GetType()); std::vector<std::string> names; - cmpp->OnEachChild(std::bind(&hookHandler, &names, pl::_1, pl::_2, pl::_3)); + cmpp->OnEachChild(std::bind(&hookHandler, &names, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); BOOST_REQUIRE_EQUAL(2, names.size()); BOOST_REQUIRE_EQUAL("a", names.front()); BOOST_REQUIRE_EQUAL("b", names.back()); diff --git a/slicer/test/conversions.h b/slicer/test/conversions.h index 55f42f3..bf70407 100644 --- a/slicer/test/conversions.h +++ b/slicer/test/conversions.h @@ -11,14 +11,14 @@ namespace TestModule { class DLL_PUBLIC AbValidator : public Slicer::ModelPartForClass<ClassType> { public: - AbValidator(ClassTypePtr *); + explicit AbValidator(ClassTypePtr *); void Complete() override; }; class DLL_PUBLIC MonthValidator : public Slicer::ModelPartForSimple<::Ice::Short> { public: - MonthValidator(::Ice::Short *); + explicit MonthValidator(::Ice::Short *); void Complete() override; }; diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp index 0edcc2f..f3b7a0e 100644 --- a/slicer/tool/parser.cpp +++ b/slicer/tool/parser.cpp @@ -545,7 +545,7 @@ namespace Slicer { for (auto & pi : {0, 1, 2}) { boost::algorithm::replace_all(split[pi], ".", "::"); } - rtn.push_back(split); + rtn.push_back(ConversionSpec(split)); } return rtn; } diff --git a/slicer/tool/parser.h b/slicer/tool/parser.h index b9474d3..6b5ba8b 100644 --- a/slicer/tool/parser.h +++ b/slicer/tool/parser.h @@ -11,49 +11,58 @@ namespace Slicer { typedef std::vector<std::string> Args; class ConversionSpec { public: - ConversionSpec(const Args &); + explicit ConversionSpec(const Args &); + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) std::string ExchangeType; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) std::string ConvertToModelFunc; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) std::string ConvertToExchangeFunc; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) Args Options; }; - typedef std::vector<ConversionSpec> Conversions; + using Conversions = std::vector<ConversionSpec>; Slicer(); + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) FILE * cpp; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) std::filesystem::path slicePath; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) std::filesystem::path cppPath; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) std::filesystem::path headerPrefix; + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) std::vector<std::filesystem::path> includes; unsigned int Execute(); - unsigned int Components() const; + [[nodiscard]] unsigned int Components() const; #pragma GCC visibility push(hidden) - virtual bool visitUnitStart(const Slice::UnitPtr&) override; + bool visitUnitStart(const Slice::UnitPtr&) override; - virtual void visitUnitEnd(const Slice::UnitPtr&) override; + void visitUnitEnd(const Slice::UnitPtr&) override; - virtual bool visitModuleStart(const Slice::ModulePtr & m) override; + bool visitModuleStart(const Slice::ModulePtr & m) override; - virtual bool visitClassDefStart(const Slice::ClassDefPtr & c) override; + bool visitClassDefStart(const Slice::ClassDefPtr & c) override; - virtual bool visitStructStart(const Slice::StructPtr&) override; + bool visitStructStart(const Slice::StructPtr&) override; - virtual void visitEnum(const Slice::EnumPtr &) override; + void visitEnum(const Slice::EnumPtr &) override; - virtual void visitSequence(const Slice::SequencePtr & s) override; + void visitSequence(const Slice::SequencePtr & s) override; - virtual void visitDictionary(const Slice::DictionaryPtr & d) override; + void visitDictionary(const Slice::DictionaryPtr & d) override; - virtual void visitModuleEnd(const Slice::ModulePtr & m) override; + void visitModuleEnd(const Slice::ModulePtr & m) override; private: void createModelPartForConverted(const Slice::TypePtr & type, const std::string & container, const Slice::DataMemberPtr & dm) const; void createNewModelPartPtrFor(const Slice::TypePtr & type, const Slice::DataMemberPtr & dm = Slice::DataMemberPtr(), const Slice::StringList & md = Slice::StringList()) const; - std::string getBasicModelPart(const Slice::TypePtr & type) const; + [[nodiscard]] std::string getBasicModelPart(const Slice::TypePtr & type) const; void defineMODELPART(const std::string & type, const Slice::TypePtr & stype, const Slice::StringList & metadata) const; void visitComplexDataMembers(const Slice::ConstructedPtr & t, const Slice::DataMemberList &) const; @@ -61,7 +70,7 @@ namespace Slicer { void defineConversions(const Slice::DataMemberPtr & dm) const; void defineRoot(const std::string & type, const std::string & name, const Slice::TypePtr & stype) const; - bool hasMetadata(const std::list<std::string> & metadata) const; + [[nodiscard]] bool hasMetadata(const std::list<std::string> & metadata) const; void copyMetadata(const std::list<std::string> & metadata) const; static Slice::StringList getAllMetadata(const Slice::DataMemberPtr & dm); static Conversions getConversions(const Slice::StringList & metadata); diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp index 36605e6..f31acb0 100644 --- a/slicer/xml/serializer.cpp +++ b/slicer/xml/serializer.cpp @@ -163,7 +163,9 @@ namespace Slicer { class XmlAttributeValueTarget : public XmlValueTarget { public: explicit XmlAttributeValueTarget(xmlpp::Element * p, const std::string & n) : - XmlValueTarget(std::bind(&xmlpp::Element::set_attribute, p, Glib::ustring(n), _1, Glib::ustring())) + XmlValueTarget([p, n](auto && PH1) { + p->set_attribute(n, PH1); + }) { } }; @@ -171,7 +173,9 @@ namespace Slicer { class XmlContentValueTarget : public XmlValueTarget { public: explicit XmlContentValueTarget(xmlpp::Element * p) : - XmlValueTarget(std::bind(&xmlpp::Element::set_first_child_text, p, _1)) + XmlValueTarget([p](auto && PH1) { + p->set_first_child_text(PH1); + }) { } @@ -322,10 +326,12 @@ namespace Slicer { } else { if (hp && metaDataFlagSet(hp->GetMetadata(), md_bare)) { - ModelTreeProcessElement(n, mp, std::bind((ElementCreatorF)&xmlpp::Element::add_child_element, _1, name, Glib::ustring())); + ModelTreeProcessElement(n, mp, [name](auto && PH1, auto &&) { + return PH1->add_child_element(name); + }); } else { - CurrentElementCreator cec(std::bind(ec, n, name)); + CurrentElementCreator cec([ec, n, name] { return ec(n, name); }); ModelTreeProcessElement(cec, mp, defaultElementCreator); } } @@ -370,7 +376,9 @@ namespace Slicer { element->set_attribute(*typeIdPropName, *typeId); mp = mp->GetSubclassModelPart(*typeId); } - mp->OnEachChild(std::bind(&XmlSerializer::ModelTreeIterate, element, _1, _2, _3, ec)); + mp->OnEachChild([element, ec](auto && PH1, auto && PH2, auto && PH3) { + return XmlSerializer::ModelTreeIterate(element, PH1, PH2, PH3, ec); + }); } } @@ -403,7 +411,9 @@ namespace Slicer { XmlStreamSerializer::Serialize(ModelPartForRootPtr modelRoot) { xmlpp::Document doc; - modelRoot->OnEachChild(std::bind(&XmlSerializer::ModelTreeIterateRoot, &doc, _1, _2)); + modelRoot->OnEachChild([&doc](auto && PH1, auto && PH2, auto &&) { + return XmlSerializer::ModelTreeIterateRoot(&doc, PH1, PH2); + }); doc.write_to_stream(strm); } @@ -429,7 +439,9 @@ namespace Slicer { XmlFileSerializer::Serialize(ModelPartForRootPtr modelRoot) { xmlpp::Document doc; - modelRoot->OnEachChild(std::bind(&XmlSerializer::ModelTreeIterateRoot, &doc, _1, _2)); + modelRoot->OnEachChild([&doc](auto && PH1, auto && PH2, auto &&) { + return XmlSerializer::ModelTreeIterateRoot(&doc, PH1, PH2); + }); doc.write_to_file_formatted(path); } @@ -453,7 +465,9 @@ namespace Slicer { XmlDocumentSerializer::Serialize(ModelPartForRootPtr modelRoot) { doc = new xmlpp::Document(); - modelRoot->OnEachChild(std::bind(&XmlSerializer::ModelTreeIterateRoot, doc, _1, _2)); + modelRoot->OnEachChild([this](auto && PH1, auto && PH2, auto &&) { + return XmlSerializer::ModelTreeIterateRoot(doc, PH1, PH2); + }); } AdHocFormatter(BadBooleanValueMsg, "Bad boolean value [%?]"); diff --git a/slicer/xml/serializer.h b/slicer/xml/serializer.h index d2220ef..f41e5a7 100644 --- a/slicer/xml/serializer.h +++ b/slicer/xml/serializer.h @@ -26,7 +26,7 @@ namespace Slicer { public: XmlStreamSerializer(std::ostream &); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; protected: std::ostream & strm; @@ -36,7 +36,7 @@ namespace Slicer { public: XmlFileSerializer(std::filesystem::path); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; protected: const std::filesystem::path path; @@ -46,7 +46,7 @@ namespace Slicer { public: XmlDocumentSerializer(xmlpp::Document * &); - virtual void Serialize(ModelPartForRootPtr) override; + void Serialize(ModelPartForRootPtr) override; protected: xmlpp::Document * & doc; @@ -65,7 +65,7 @@ namespace Slicer { public: XmlStreamDeserializer(std::istream &); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: std::istream & strm; @@ -75,7 +75,7 @@ namespace Slicer { public: XmlFileDeserializer(std::filesystem::path); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: const std::filesystem::path path; @@ -85,7 +85,7 @@ namespace Slicer { public: XmlDocumentDeserializer(const xmlpp::Document *); - virtual void Deserialize(ModelPartForRootPtr) override; + void Deserialize(ModelPartForRootPtr) override; protected: const xmlpp::Document * doc; |