mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 22:20:35 +05:00
fixes for core guidelines checks
This commit is contained in:
parent
0093dab1be
commit
0ef2d0f7f9
@ -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
|
@ -506,25 +506,25 @@ namespace ngcore
|
||||
: BinaryOutArchive(std::make_shared<std::ofstream>(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<std::ifstream>(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<char*>(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<char*>(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<char*>(i), n*sizeof(size_t)); return *this; }
|
||||
|
||||
private:
|
||||
@ -648,25 +648,25 @@ namespace ngcore
|
||||
TextOutArchive (std::string filename) :
|
||||
TextOutArchive(std::make_shared<std::ofstream>(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<std::ifstream>(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;
|
||||
|
@ -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 <type_traits>
|
||||
|
||||
@ -7,7 +7,7 @@ namespace ngcore
|
||||
{
|
||||
template<bool... b> struct _BoolArray{};
|
||||
template<bool ... vals>
|
||||
constexpr bool all_of_tmpl = std::is_same<_BoolArray<vals...>, _BoolArray<(vals || true)...>>::value;
|
||||
constexpr bool all_of_tmpl = std::is_same<_BoolArray<vals...>, _BoolArray<(vals || true)...>>::value; // NOLINT
|
||||
} // namespace ngcore
|
||||
|
||||
#endif // NGS_TYPE_TRAITS_HPP
|
||||
#endif // NETGEN_LIBSRC_CORE_TYPE_TRAITS_HPP
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef NETGEN_CORE_VERSION_HPP
|
||||
#define NETGEN_CORE_VERSION_HPP
|
||||
|
||||
#include "ngcore_api.hpp"
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user