LibrePCB Developers Documentation
|
The Version class represents a version number in the format "1.42.7". More...
#include <version.h>
Public Member Functions | |
Version ()=delete | |
Default constructor (disabled to avoid creating invalid versions) More... | |
Version (const Version &other) noexcept | |
Copy constructor. More... | |
~Version () noexcept=default | |
bool | isPrefixOf (const Version &other) const noexcept |
Check if this version is the prefix of another version. More... | |
const QVector< uint > & | getNumbers () const noexcept |
Get the numbers in the version string. More... | |
QString | toStr () const noexcept |
Get the version as a string in the format "1.2.3". More... | |
QString | toPrettyStr (int minSegCount, int maxSegCount=10) const noexcept |
Get the version as a string with trailing zeros (e.g. "1.2.0") More... | |
QString | toComparableStr () const noexcept |
Get the version as a comparable string (59 characters) More... | |
Version & | operator= (const Version &rhs) noexcept |
bool | operator> (const Version &rhs) const noexcept |
Comparison operators. More... | |
bool | operator< (const Version &rhs) const noexcept |
bool | operator>= (const Version &rhs) const noexcept |
bool | operator<= (const Version &rhs) const noexcept |
bool | operator== (const Version &rhs) const noexcept |
bool | operator!= (const Version &rhs) const noexcept |
Static Public Member Functions | |
static bool | isValid (const QString &str) noexcept |
Check if a string is a valid version number. More... | |
static Version | fromString (const QString &str) |
Create a Version object from a string. More... | |
static tl::optional< Version > | tryFromString (const QString &str) noexcept |
Try creating a Version object from a string, returning empty optional if invalid. More... | |
Private Member Functions | |
Version (const QVector< uint > &numbers) noexcept | |
Private Attributes | |
QVector< uint > | mNumbers |
List of all version numbers of the whole version. More... | |
The Version class represents a version number in the format "1.42.7".
Rules for a version number:
So the lowest possible version is "0", and the highest possible version is "99999.99999.99999.99999.99999.99999.99999.99999.99999.99999".
Leading zeros in numbers are ignored: "002.0005" will be converted to "2.5" Trailing zero numbers are ignored: "2.5.0.0" will be converted to "2.5"
|
delete |
Default constructor (disabled to avoid creating invalid versions)
Copy constructor.
other | Another librepcb::Version object |
|
defaultnoexcept |
Destructor
|
inlineexplicitprivatenoexcept |
|
noexcept |
Check if this version is the prefix of another version.
Example: "1.2" is a prefix of "1.2", "1.2.0.1", "1.2.1"
other | Another version |
|
inlinenoexcept |
Get the numbers in the version string.
The first item in the list is the major version number.
|
noexcept |
Get the version as a string in the format "1.2.3".
|
noexcept |
Get the version as a string with trailing zeros (e.g. "1.2.0")
minSegCount | If the version has less segments than specified by this parameter, trailing zeros will be appended. Example: "0.1" gets "0.1.0.0" with minSegCount = 4 |
maxSegCount | If the version has more segments than specified by this parameter, trailing segments will be omitted. Example: "0.1.2.3.4" gets "0.1" with maxSegCount = 2 |
|
noexcept |
Get the version as a comparable string (59 characters)
The version will be returned with all 10x5 decimal places: "#####.#####.#####.#####.#####.#####.#####.#####.#####.#####"
This method is useful to compare versions in a database (e.g. SQLite) as you only need a simple string compare.
|
inlinenoexcept |
Comparison operators.
rhs | The other object to compare |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
staticnoexcept |
Check if a string is a valid version number.
str | The string to check |
true | If str is a valid version number |
false | If str is not a valid version number |
|
static |
Create a Version object from a string.
str | The version string in the format "1.2.3" (variable count of numbers) |
Exception | if the string does not contain a valid version number |
|
staticnoexcept |
Try creating a Version object from a string, returning empty optional if invalid.
str | Input string |
Version | The created Version object if str was valid |
tl::nullopt | If str was not a valid version number |
|
private |
List of all version numbers of the whole version.
Guaranteed to contain at least one item.