diff --git a/libsrc/core/.clang-tidy b/libsrc/core/.clang-tidy index 81b0a6ae..6d5e34da 100644 --- a/libsrc/core/.clang-tidy +++ b/libsrc/core/.clang-tidy @@ -1,4 +1,4 @@ -Checks: '*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-*,-google-runtime-references,-readability-implicit-bool-conversion' +Checks: '*,-clang-analyzer-alpha.*,-*braces-around-statements,-fuchsia-*,-google-runtime-references,-readability-implicit-bool-conversion,-google-explicit-constructor,-hicpp-explicit-conversions' CheckOptions: - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor - value: 1 + value: 1 \ No newline at end of file diff --git a/libsrc/core/archive.hpp b/libsrc/core/archive.hpp index 8bdfe0f1..7efc2d9d 100644 --- a/libsrc/core/archive.hpp +++ b/libsrc/core/archive.hpp @@ -506,25 +506,25 @@ namespace ngcore : BinaryOutArchive(std::make_shared(filename)) {} virtual ~BinaryOutArchive () { FlushBuffer(); } - const VersionInfo& getVersion(const std::string& library) + const VersionInfo& getVersion(const std::string& library) override { return GetLibraryVersions()[library]; } using Archive::operator&; - virtual Archive & operator & (double & d) + Archive & operator & (double & d) override { return Write(d); } - virtual Archive & operator & (int & i) + Archive & operator & (int & i) override { return Write(i); } - virtual Archive & operator & (short & i) + Archive & operator & (short & i) override { return Write(i); } - virtual Archive & operator & (long & i) + Archive & operator & (long & i) override { return Write(i); } - virtual Archive & operator & (size_t & i) + Archive & operator & (size_t & i) override { return Write(i); } - virtual Archive & operator & (unsigned char & i) + Archive & operator & (unsigned char & i) override { return Write(i); } - virtual Archive & operator & (bool & b) + Archive & operator & (bool & b) override { return Write(b); } - virtual Archive & operator & (std::string & str) + Archive & operator & (std::string & str) override { int len = str.length(); (*this) & len; @@ -533,7 +533,7 @@ namespace ngcore fout->write (&str[0], len); return *this; } - virtual Archive & operator & (char *& str) + Archive & operator & (char *& str) override { long len = str ? strlen (str) : -1; (*this) & len; @@ -542,7 +542,7 @@ namespace ngcore fout->write (&str[0], len); return *this; } - void FlushBuffer() + void FlushBuffer() override { if (ptr > 0) { @@ -581,25 +581,25 @@ namespace ngcore BinaryInArchive (std::string filename) : BinaryInArchive(std::make_shared(filename)) { ; } - const VersionInfo& getVersion(const std::string& library) + const VersionInfo& getVersion(const std::string& library) override { return vinfo[library]; } using Archive::operator&; - virtual Archive & operator & (double & d) + Archive & operator & (double & d) override { Read(d); return *this; } - virtual Archive & operator & (int & i) + Archive & operator & (int & i) override { Read(i); return *this; } - virtual Archive & operator & (short & i) + Archive & operator & (short & i) override { Read(i); return *this; } - virtual Archive & operator & (long & i) + Archive & operator & (long & i) override { Read(i); return *this; } - virtual Archive & operator & (size_t & i) + Archive & operator & (size_t & i) override { Read(i); return *this; } - virtual Archive & operator & (unsigned char & i) + Archive & operator & (unsigned char & i) override { Read(i); return *this; } - virtual Archive & operator & (bool & b) + Archive & operator & (bool & b) override { Read(b); return *this; } - virtual Archive & operator & (std::string & str) + Archive & operator & (std::string & str) override { int len; (*this) & len; @@ -608,7 +608,7 @@ namespace ngcore fin->read(&str[0], len); return *this; } - virtual Archive & operator & (char *& str) + Archive & operator & (char *& str) override { long len; (*this) & len; @@ -623,11 +623,11 @@ namespace ngcore return *this; } - virtual Archive & Do (double * d, size_t n) + Archive & Do (double * d, size_t n) override { fin->read(reinterpret_cast(d), n*sizeof(double)); return *this; } - virtual Archive & Do (int * i, size_t n) + Archive & Do (int * i, size_t n) override { fin->read(reinterpret_cast(i), n*sizeof(int)); return *this; } - virtual Archive & Do (size_t * i, size_t n) + Archive & Do (size_t * i, size_t n) override { fin->read(reinterpret_cast(i), n*sizeof(size_t)); return *this; } private: @@ -648,25 +648,25 @@ namespace ngcore TextOutArchive (std::string filename) : TextOutArchive(std::make_shared(filename)) { } - const VersionInfo& getVersion(const std::string& library) + const VersionInfo& getVersion(const std::string& library) override { return GetLibraryVersions()[library]; } using Archive::operator&; - virtual Archive & operator & (double & d) + Archive & operator & (double & d) override { *fout << d << '\n'; return *this; } - virtual Archive & operator & (int & i) + Archive & operator & (int & i) override { *fout << i << '\n'; return *this; } - virtual Archive & operator & (short & i) + Archive & operator & (short & i) override { *fout << i << '\n'; return *this; } - virtual Archive & operator & (long & i) + Archive & operator & (long & i) override { *fout << i << '\n'; return *this; } - virtual Archive & operator & (size_t & i) + Archive & operator & (size_t & i) override { *fout << i << '\n'; return *this; } - virtual Archive & operator & (unsigned char & i) + Archive & operator & (unsigned char & i) override { *fout << int(i) << '\n'; return *this; } - virtual Archive & operator & (bool & b) + Archive & operator & (bool & b) override { *fout << (b ? 't' : 'f') << '\n'; return *this; } - virtual Archive & operator & (std::string & str) + Archive & operator & (std::string & str) override { int len = str.length(); *fout << len << '\n'; @@ -677,7 +677,7 @@ namespace ngcore } return *this; } - virtual Archive & operator & (char *& str) + Archive & operator & (char *& str) override { long len = str ? strlen (str) : -1; *this & len; @@ -703,25 +703,25 @@ namespace ngcore TextInArchive (std::string filename) : TextInArchive(std::make_shared(filename)) {} - const VersionInfo& getVersion(const std::string& library) + const VersionInfo& getVersion(const std::string& library) override { return vinfo[library]; } using Archive::operator&; - virtual Archive & operator & (double & d) + Archive & operator & (double & d) override { *fin >> d; return *this; } - virtual Archive & operator & (int & i) + Archive & operator & (int & i) override { *fin >> i; return *this; } - virtual Archive & operator & (short & i) + Archive & operator & (short & i) override { *fin >> i; return *this; } - virtual Archive & operator & (long & i) + Archive & operator & (long & i) override { *fin >> i; return *this; } - virtual Archive & operator & (size_t & i) + Archive & operator & (size_t & i) override { *fin >> i; return *this; } - virtual Archive & operator & (unsigned char & i) + Archive & operator & (unsigned char & i) override { int _i; *fin >> _i; i = _i; return *this; } - virtual Archive & operator & (bool & b) + Archive & operator & (bool & b) override { char c; *fin >> c; b = (c=='t'); return *this; } - virtual Archive & operator & (std::string & str) + Archive & operator & (std::string & str) override { int len; *fin >> len; @@ -732,7 +732,7 @@ namespace ngcore fin->get(&str[0], len+1, '\0'); return *this; } - virtual Archive & operator & (char *& str) + Archive & operator & (char *& str) override { long len; (*this) & len; diff --git a/libsrc/core/type_traits.hpp b/libsrc/core/type_traits.hpp index c298aedc..36315e7a 100644 --- a/libsrc/core/type_traits.hpp +++ b/libsrc/core/type_traits.hpp @@ -1,5 +1,5 @@ -#ifndef NGS_TYPE_TRAITS_HPP -#define NGS_TYPE_TRAITS_HPP +#ifndef NETGEN_LIBSRC_CORE_TYPE_TRAITS_HPP +#define NETGEN_LIBSRC_CORE_TYPE_TRAITS_HPP #include @@ -7,7 +7,7 @@ namespace ngcore { template struct _BoolArray{}; template - constexpr bool all_of_tmpl = std::is_same<_BoolArray, _BoolArray<(vals || true)...>>::value; + constexpr bool all_of_tmpl = std::is_same<_BoolArray, _BoolArray<(vals || true)...>>::value; // NOLINT } // namespace ngcore -#endif // NGS_TYPE_TRAITS_HPP +#endif // NETGEN_LIBSRC_CORE_TYPE_TRAITS_HPP diff --git a/libsrc/core/version.hpp b/libsrc/core/version.hpp index 5ffa8bb0..27828e6e 100644 --- a/libsrc/core/version.hpp +++ b/libsrc/core/version.hpp @@ -1,9 +1,9 @@ #ifndef NETGEN_CORE_VERSION_HPP #define NETGEN_CORE_VERSION_HPP +#include "ngcore_api.hpp" #include #include -#include "ngcore_api.hpp" namespace ngcore { @@ -11,39 +11,39 @@ namespace ngcore class VersionInfo { private: - size_t mayor_, minor_, release, patch; - std::string git_hash; + size_t mayor_{}, minor_{}, release{}, patch{}; + std::string git_hash{}; public: - VersionInfo() : mayor_(0), minor_(0), release(0), patch(0), git_hash("") {} + VersionInfo() = default; VersionInfo(std::string vstring) { minor_ = release = patch = 0; git_hash = ""; if(vstring.substr(0,1) == "v") vstring = vstring.substr(1,vstring.size()-1); - auto dot = vstring.find("."); + auto dot = vstring.find('.'); mayor_ = std::stoi(vstring.substr(0,dot)); if(dot == size_t(-1)) vstring = ""; else vstring = vstring.substr(dot+1, vstring.size()-dot-1); - if(vstring.size()) + if(!vstring.empty()) { - dot = vstring.find("."); + dot = vstring.find('.'); minor_ = std::stoi(vstring.substr(0,dot)); if (dot == size_t(-1)) vstring = ""; else vstring = vstring.substr(dot+1, vstring.size()-dot-1); - if(vstring.size()) + if(!vstring.empty()) { - dot = vstring.find("-"); + dot = vstring.find('-'); release = std::stoi(vstring.substr(0,dot)); if(dot == size_t(-1)) vstring = ""; else vstring = vstring.substr(dot+1,vstring.size()-dot-1); - if(vstring.size()) + if(!vstring.empty()) { - dot = vstring.find("-"); + dot = vstring.find('-'); patch = std::stoi(vstring.substr(0,dot)); if(dot == size_t(-1)) vstring = ""; else vstring = vstring.substr(dot+1, vstring.size()-dot-1); - if(vstring.size()) + if(!vstring.empty()) git_hash = vstring; } }