Mech-Eye API
2.6.0
API reference documentation for Mech-Eye 3D Laser Profiler
Toggle main menu visibility
Loading...
Searching...
No Matches
Version.h
1
#pragma once
2
#include <string>
3
#include <regex>
4
#include "api_global.h"
5
6
namespace
mmind {
7
8
namespace
eye {
9
13
MMIND_API_EXPORT std::string getApiVersionInfo();
14
18
class
Version
19
{
20
public
:
24
Version
() =
default
;
25
29
Version
(
int
major,
int
minor,
int
patch) : _major(major), _minor(minor), _patch(patch) {}
30
34
explicit
Version
(
const
std::string& version) {
fromString
(version); }
35
39
bool
operator==
(
const
Version
& other)
const
{
return
toString
() == other.
toString
(); }
40
44
bool
operator!=
(
const
Version
& other)
const
{
return
!(*
this
== (other)); }
45
50
bool
operator>=
(
const
Version
& other)
const
51
{
52
return
_major > other._major ||
53
(_major == other._major &&
54
(_minor > other._minor || (_minor == other._minor && _patch >= other._patch)));
55
}
56
60
bool
operator<
(
const
Version
& other)
const
{
return
!(*
this
>= (other)); }
61
66
bool
operator<=
(
const
Version
& other)
const
{
return
*
this
< other || *
this
== other; }
67
71
std::string
toString
()
const
72
{
73
char
buff[16] = {0};
74
snprintf(buff,
sizeof
(buff),
"%d.%d.%d"
, _major, _minor, _patch);
75
return
buff;
76
}
77
81
void
fromString
(
const
std::string& version)
82
{
83
std::regex rege(R
"((\d+).(\d+).(\d+))");
84
std::smatch result;
85
if
(std::regex_search(version, result, rege)) {
86
_major = std::stoi(result.str(1));
87
_minor = std::stoi(result.str(2));
88
_patch = std::stoi(result.str(3));
89
}
90
}
91
95
bool
isEmpty
()
const
{
return
*
this
==
Version
(); }
96
97
private
:
98
int
_major = 0;
99
int
_minor = 0;
100
int
_patch = 0;
101
};
102
}
// namespace eye
103
104
}
// namespace mmind
mmind::eye::Version::Version
Version(const std::string &version)
Constructor.
Definition
Version.h:34
mmind::eye::Version::operator==
bool operator==(const Version &other) const
Overloads the == operator to determine if two Version objects are equal.
Definition
Version.h:39
mmind::eye::Version::Version
Version()=default
Default constructor.
mmind::eye::Version::fromString
void fromString(const std::string &version)
Converts a version in the string format to a Version object.
Definition
Version.h:81
mmind::eye::Version::operator!=
bool operator!=(const Version &other) const
Overloads the != operator to determine if two Version objects are unequal.
Definition
Version.h:44
mmind::eye::Version::operator<=
bool operator<=(const Version &other) const
Overloads the <= operator to determine if one Version object is smaller than or equal to the other.
Definition
Version.h:66
mmind::eye::Version::operator>=
bool operator>=(const Version &other) const
Overloads the >= operator to determine if one Version object is greater than or equal to the other.
Definition
Version.h:50
mmind::eye::Version::toString
std::string toString() const
Converts a Version object to a string.
Definition
Version.h:71
mmind::eye::Version::operator<
bool operator<(const Version &other) const
Overloads the < operator to determine if one Version object is smaller than the other.
Definition
Version.h:60
mmind::eye::Version::isEmpty
bool isEmpty() const
Checks if a Version object is empty.
Definition
Version.h:95
mmind::eye::Version::Version
Version(int major, int minor, int patch)
Constructor.
Definition
Version.h:29
Generated by
1.17.0