mirror of
https://github.com/NGSolve/netgen.git
synced 2025-04-08 22:37:28 +05:00
mayor and minor are macros defined in GNU_SOURCE...
This commit is contained in:
parent
32bc3f826e
commit
69769fc628
@ -6,24 +6,24 @@ namespace ngcore
|
|||||||
class VersionInfo
|
class VersionInfo
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
size_t mayor, minor, release, patch;
|
size_t mayor_, minor_, release, patch;
|
||||||
std::string git_hash;
|
std::string git_hash;
|
||||||
public:
|
public:
|
||||||
VersionInfo() : mayor(0), minor(0), release(0), patch(0), git_hash("") {}
|
VersionInfo() : mayor_(0), minor_(0), release(0), patch(0), git_hash("") {}
|
||||||
VersionInfo(std::string vstring)
|
VersionInfo(std::string vstring)
|
||||||
{
|
{
|
||||||
minor = release = patch = 0;
|
minor_ = release = patch = 0;
|
||||||
git_hash = "";
|
git_hash = "";
|
||||||
if(vstring.substr(0,1) == "v")
|
if(vstring.substr(0,1) == "v")
|
||||||
vstring = vstring.substr(1,vstring.size()-1);
|
vstring = vstring.substr(1,vstring.size()-1);
|
||||||
auto dot = vstring.find(".");
|
auto dot = vstring.find(".");
|
||||||
mayor = std::stoi(vstring.substr(0,dot));
|
mayor_ = std::stoi(vstring.substr(0,dot));
|
||||||
if(dot == size_t(-1)) vstring = "";
|
if(dot == size_t(-1)) vstring = "";
|
||||||
else vstring = vstring.substr(dot+1, vstring.size()-dot-1);
|
else vstring = vstring.substr(dot+1, vstring.size()-dot-1);
|
||||||
if(vstring.size())
|
if(vstring.size())
|
||||||
{
|
{
|
||||||
dot = vstring.find(".");
|
dot = vstring.find(".");
|
||||||
minor = std::stoi(vstring.substr(0,dot));
|
minor_ = std::stoi(vstring.substr(0,dot));
|
||||||
if (dot == size_t(-1)) vstring = "";
|
if (dot == size_t(-1)) vstring = "";
|
||||||
else vstring = vstring.substr(dot+1, vstring.size()-dot-1);
|
else vstring = vstring.substr(dot+1, vstring.size()-dot-1);
|
||||||
if(vstring.size())
|
if(vstring.size())
|
||||||
@ -47,10 +47,10 @@ namespace ngcore
|
|||||||
VersionInfo(const char* cstr) : VersionInfo(std::string(cstr)) { }
|
VersionInfo(const char* cstr) : VersionInfo(std::string(cstr)) { }
|
||||||
|
|
||||||
std::string to_string() const
|
std::string to_string() const
|
||||||
{ std::string vstring = "v" + std::to_string(mayor);
|
{ std::string vstring = "v" + std::to_string(mayor_);
|
||||||
if(minor || release || patch || git_hash.size())
|
if(minor_ || release || patch || git_hash.size())
|
||||||
{
|
{
|
||||||
vstring += "." + std::to_string(minor);
|
vstring += "." + std::to_string(minor_);
|
||||||
if(release || patch || git_hash.size())
|
if(release || patch || git_hash.size())
|
||||||
{
|
{
|
||||||
vstring += "." + std::to_string(release);
|
vstring += "." + std::to_string(release);
|
||||||
@ -66,12 +66,12 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
bool operator <(const VersionInfo& other) const
|
bool operator <(const VersionInfo& other) const
|
||||||
{
|
{
|
||||||
return std::tie(mayor, minor, release, patch) <
|
return std::tie(mayor_, minor_, release, patch) <
|
||||||
std::tie(other.mayor, other.minor, other.release, other.patch);
|
std::tie(other.mayor_, other.minor_, other.release, other.patch);
|
||||||
}
|
}
|
||||||
bool operator ==(const VersionInfo& other) const
|
bool operator ==(const VersionInfo& other) const
|
||||||
{
|
{
|
||||||
return mayor == other.mayor && minor == other.minor && release == other.release
|
return mayor_ == other.mayor_ && minor_ == other.minor_ && release == other.release
|
||||||
&& patch == other.patch;
|
&& patch == other.patch;
|
||||||
}
|
}
|
||||||
bool operator >(const VersionInfo& other) const { return other < (*this); }
|
bool operator >(const VersionInfo& other) const { return other < (*this); }
|
||||||
@ -80,7 +80,7 @@ namespace ngcore
|
|||||||
|
|
||||||
void DoArchive(Archive& ar)
|
void DoArchive(Archive& ar)
|
||||||
{
|
{
|
||||||
ar & mayor & minor & release & patch & git_hash;
|
ar & mayor_ & minor_ & release & patch & git_hash;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user