Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
VersionId Class Referencefinal

A class, that supports base manipulation with version number. More...

#include <VersionId.h>

Public Member Functions

 VersionId ()=default
 Creates an zero version object. More...
 
 VersionId (int version, int release, int revision, int patch=0)
 
wxString GetString () const
 Make string with version by MakeString() from instance values. More...
 
bool operator== (const VersionId &other)
 
bool operator!= (const VersionId &other)
 
bool operator< (const VersionId &other)
 
bool operator> (const VersionId &other)
 

Static Public Member Functions

static wxString MakeString (int version, int release, int revision, int patch)
 Creates version string like "1.2.3" by parameters. More...
 
static VersionId ParseFromString (wxString &versionString)
 Parse and return version object from version string like "1.2.3". More...
 

Private Attributes

int mVersion { 0 }
 
int mRelease { 0 }
 
int mRevision { 0 }
 
int mPatch { 0 }
 

Detailed Description

A class, that supports base manipulation with version number.

By default initialized by zero version number (Version = 0, Release = 0, Revision = 0, Patch = 0), that not allow us to update.

Definition at line 18 of file VersionId.h.

Constructor & Destructor Documentation

◆ VersionId() [1/2]

VersionId::VersionId ( )
default

Creates an zero version object.

◆ VersionId() [2/2]

VersionId::VersionId ( int  version,
int  release,
int  revision,
int  patch = 0 
)

Definition at line 11 of file VersionId.cpp.

12 : mVersion(version),
13 mRelease(release),
14 mRevision(revision),
15 mPatch(patch)
16{}
int mRevision
Definition: VersionId.h:42
int mRelease
Definition: VersionId.h:41
int mVersion
Definition: VersionId.h:40
int mPatch
Definition: VersionId.h:43

Member Function Documentation

◆ GetString()

wxString VersionId::GetString ( ) const

Make string with version by MakeString() from instance values.

Definition at line 60 of file VersionId.cpp.

61{
63}
static wxString MakeString(int version, int release, int revision, int patch)
Creates version string like "1.2.3" by parameters.
Definition: VersionId.cpp:18

References MakeString(), mPatch, mRelease, mRevision, and mVersion.

Referenced by UpdatePopupDialog::AddHtmlContent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeString()

wxString VersionId::MakeString ( int  version,
int  release,
int  revision,
int  patch 
)
static

Creates version string like "1.2.3" by parameters.

Definition at line 18 of file VersionId.cpp.

19{
20 if (patch == 0)
21 return std::to_string(version)
22 + "." + std::to_string(release)
23 + "." + std::to_string(revision);
24 else
25 return std::to_string(version)
26 + "." + std::to_string(release)
27 + "." + std::to_string(revision)
28 + "." + std::to_string(patch);
29}

Referenced by GetString().

Here is the caller graph for this function:

◆ operator!=()

bool VersionId::operator!= ( const VersionId other)

Definition at line 71 of file VersionId.cpp.

72{
73 return !(*this == other);
74}

◆ operator<()

bool VersionId::operator< ( const VersionId other)

Definition at line 76 of file VersionId.cpp.

77{
78 return std::tie(mVersion, mRelease, mRevision, mPatch) <
79 std::tie(other.mVersion, other.mRelease, other.mRevision, other.mPatch);
80}

References mPatch, mRelease, mRevision, and mVersion.

◆ operator==()

bool VersionId::operator== ( const VersionId other)

Definition at line 65 of file VersionId.cpp.

66{
67 return std::tie(mVersion, mRelease, mRevision, mPatch) ==
68 std::tie(other.mVersion, other.mRelease, other.mRevision, other.mPatch);
69}

References mPatch, mRelease, mRevision, and mVersion.

◆ operator>()

bool VersionId::operator> ( const VersionId other)

Definition at line 82 of file VersionId.cpp.

83{
84 return !(*this < other) && (*this != other);
85}

◆ ParseFromString()

VersionId VersionId::ParseFromString ( wxString &  versionString)
static

Parse and return version object from version string like "1.2.3".

Definition at line 31 of file VersionId.cpp.

32{
33 auto versionStringParts = wxSplit(versionString, '.');
34
35 // If we have corrupted version string,
36 // then return the zero version number, that not allow us to update.
37 const auto size = versionStringParts.size();
38 if (size < 2 || size > 4)
39 return VersionId{};
40
41 VersionId versionId;
42
43 const auto fields = { &versionId.mVersion, &versionId.mRelease,
44 &versionId.mRevision, &versionId.mPatch };
45
46 auto currentField = fields.begin();
47
48 for (auto& v : versionStringParts)
49 {
50 if (v.empty() || !v.IsNumber())
51 return VersionId{};
52
53 **currentField = std::stoi(v.ToStdString());
54 ++currentField;
55 }
56
57 return versionId;
58}
A class, that supports base manipulation with version number.
Definition: VersionId.h:19

References mPatch, mRelease, mRevision, mVersion, and size.

Referenced by UpdateDataParser::HandleXMLContent().

Here is the caller graph for this function:

Member Data Documentation

◆ mPatch

int VersionId::mPatch { 0 }
private

Definition at line 43 of file VersionId.h.

Referenced by GetString(), operator<(), operator==(), and ParseFromString().

◆ mRelease

int VersionId::mRelease { 0 }
private

Definition at line 41 of file VersionId.h.

Referenced by GetString(), operator<(), operator==(), and ParseFromString().

◆ mRevision

int VersionId::mRevision { 0 }
private

Definition at line 42 of file VersionId.h.

Referenced by GetString(), operator<(), operator==(), and ParseFromString().

◆ mVersion

int VersionId::mVersion { 0 }
private

Definition at line 40 of file VersionId.h.

Referenced by GetString(), operator<(), operator==(), and ParseFromString().


The documentation for this class was generated from the following files: