| 35 | class QXmlStreamReader; |
| 36 | |
| 37 | class AppVersion |
| 38 | { |
| 39 | public: |
| 40 | AppVersion() |
| 41 | : _major(0) |
| 42 | , _minor(0) |
| 43 | , _rc(0) |
| 44 | , _build(0) |
| 45 | {} |
| 46 | |
| 47 | AppVersion(const char *version) |
| 48 | : AppVersion() |
| 49 | { |
| 50 | QString str(version); |
| 51 | initWith(QStringRef(&str)); |
| 52 | } |
| 53 | |
| 54 | AppVersion(const QStringRef &ver) |
| 55 | : AppVersion() |
| 56 | { |
| 57 | initWith(ver); |
| 58 | } |
| 59 | |
| 60 | void initWith(const QStringRef &version) |
| 61 | { |
| 62 | QStringList splittedVer = version.toString().split("."); |
| 63 | if (splittedVer.size() > 4 || splittedVer.size() < 1) |
| 64 | { |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | _major = splittedVer[0].toInt(); |
| 69 | _minor = splittedVer.size() > 1 ? splittedVer[1].toInt() : 0; |
| 70 | _rc = splittedVer.size() > 2 ? splittedVer[2].toInt() : 0; |
| 71 | _build = splittedVer.size() > 3 ? splittedVer[3].toInt() : 0; |
| 72 | } |
| 73 | |
| 74 | bool isValid() const { |
| 75 | return _major != 0 || _minor != 0 || _rc != 0 || _build != 0; |
| 76 | } |
| 77 | |
| 78 | int compare(const AppVersion &other) const { |
| 79 | int dmj = this->_major - other._major; |
| 80 | if (dmj != 0) |
| 81 | return dmj; |
| 82 | int dmn = this->_minor - other._minor; |
| 83 | if (dmn != 0) |
| 84 | return dmn; |
| 85 | int drc = this->_rc - other._rc; |
| 86 | if (drc != 0) |
| 87 | return drc; |
| 88 | int dbuild = this->_build - other._build; |
| 89 | return dbuild; |
| 90 | } |
| 91 | |
| 92 | bool operator== (const AppVersion &other) const { |
| 93 | return this->compare(other) == 0; |
| 94 | } |
nothing calls this directly
no outgoing calls
no test coverage detected