Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
distversion.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2024 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#include "distversion.h"
9namespace QH {
10
11unsigned short DistVersion::max() const {
12 return _max;
13}
14
15void DistVersion::setMax(unsigned short newMax) {
16 _max = newMax;
17}
18
19int DistVersion::getMaxCompatible(const DistVersion &distVersion) const {
20 unsigned short midMax = std::min(distVersion.max(), _max);
21 unsigned short midMin = std::max(distVersion.min(), _min);
22
23 if (midMax < midMin)
24 return -1;
25
26 return midMax;
27}
28
29int DistVersion::getMinCompatible(const DistVersion &distVersion) const {
30 unsigned short midMax = std::min(distVersion.max(), _max);
31 unsigned short midMin = std::max(distVersion.min(), _min);
32
33 if (midMax < midMin)
34 return -1;
35
36 return midMin;
37}
38
39bool DistVersion::isSupport(unsigned short version) const {
40 return _min <= version && version <= _max;
41}
42
43QString DistVersion::toString() const {
44 return QString("%0:%1").arg(_min).arg(_max);
45}
46
47QDataStream &DistVersion::fromStream(QDataStream &stream) {
48
49 stream >> _min;
50 stream >> _max;
51 return stream;
52}
53
54QDataStream &DistVersion::toStream(QDataStream &stream) const {
55 stream << _min;
56 stream << _max;
57 return stream;
58}
59
60DistVersion::operator bool() const {
61 return _min || _max;
62}
63
64unsigned short DistVersion::min() const {
65 return _min;
66}
67
68void DistVersion::setMin(unsigned short newMin) {
69 _min = newMin;
70}
71
72}
The DistVersion class This is information of supported versions of the destinations api.
Definition distversion.h:21
int getMinCompatible(const DistVersion &distVersion) const
getMinСompatible return maximum available on booth nodes version.
void setMax(unsigned short newMax)
bool isSupport(unsigned short version) const
isSupport This method return true if the version is supported of this versions range.
void setMin(unsigned short newMin)
QDataStream & toStream(QDataStream &stream) const override
fromStream This method should be write all members of the current object to the stream object.
unsigned short min() const
unsigned short max() const
QDataStream & fromStream(QDataStream &stream) override
fromStream This method should be read all bytes from the stream object and full the current object.
QString toString() const override
int getMaxCompatible(const DistVersion &distVersion) const
getMaxСompatible return maximum available on booth nodes version.
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13