Represents the version number of an assembly, operating system, or the xtd. This class cannot be inherited.
major.minor[.build[.revision]]
Public Constructors | |
version () noexcept=default | |
Initializes a new instance of the xtd::version class. | |
version (const xtd::string &version) | |
Initializes a new instance of the xtd::version class using the specified string. | |
version (int32 major, int32 minor) | |
Initializes a new instance of the xtd::version class using the specified major and minor values. | |
version (int32 major, int32 minor, int32 build) | |
Initializes a new instance of the xtd::version class using the specified major, minor and build values. | |
version (int32 major, int32 minor, int32 build, int32 revision) | |
Initializes a new instance of the xtd::version class using the specified major, minor, build and revision values. | |
Public Properties | |
int32 | build () const noexcept |
Gets the value of the build component of the version number for the current xtd::version object. | |
int32 | major () const noexcept |
Gets the value of the major component of the version number for the current xtd::version object. | |
int16 | major_revision () const noexcept |
Gets the high 16 bits of the revision number. | |
int32 | minor () const noexcept |
Gets the value of the minor component of the version number for the current xtd::version object. | |
int16 | minor_revision () const noexcept |
Gets the low 16 bits of the revision number. | |
int32 | revision () const noexcept |
Gets the value of the revision component of the version number for the current xtd::version object. | |
Public Methods | |
int32 | compare_to (const version &version) const noexcept override |
Compares the current xtd::version object to a specified object and returns an indication of their relative values. | |
bool | equals (const object &obj) const noexcept override |
Determines whether the specified object is equal to the current object. | |
bool | equals (const version &v) const noexcept override |
Determines whether the specified object is equal to the current object. | |
xtd::size | get_hash_code () const noexcept override |
Serves as a hash function for a particular type. | |
xtd::string | to_string () const noexcept override |
Converts the value of the current xtd::version object to its equivalent xtd::string representation. | |
xtd::string | to_string (size_t field_count) const |
Converts the value of the current xtd::version object to its equivalent xtd::string representation. A specified count indicates the number of components to return. | |
Public Static Methods | |
static version | parse (const xtd::string &input) |
Converts the string representation of a version number to an equivalent Version object. | |
static bool | try_parse (const xtd::string &input, version &result) noexcept |
Tries to convert the string representation of a version number to an equivalent xtd::version object, and returns a value that indicates whether the conversion succeeded. | |
Additional Inherited Members | |
![]() | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
![]() | |
![]() | |
![]() | |
template<class object_a_t , class object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<class object_a_t , class object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
|
defaultnoexcept |
Initializes a new instance of the xtd::version class.
Property | Value |
---|---|
xtd::version::major | 0 |
xtd::version::minor | 0 |
xtd::version::build | -1 |
xtd::version::revision | -1 |
|
explicit |
Initializes a new instance of the xtd::version class using the specified string.
version | A string containing the major, minor, build, and revision numbers, where each number is delimited with a period character ('.'). |
xtd::argument_exception | version has fewer than two components or more than four components. |
xtd::argument_out_of_range_exception | A major, minor, build, or revision component is less than zero. |
xtd::format_exception | At least one component of version does not parse to an integer. |
xtd::overflow_exception | At least one component of version represents a number greater than std::numeric_limits<int32>::max(). |
major.minor[.build[.revision]]
Initializes a new instance of the xtd::version class using the specified major and minor values.
major | The major version number. |
minor | The minor version number. |
xtd::out_of_range_exception | major or minor is less than zero. |
Property | Value |
---|---|
xtd::version::major | major |
xtd::version::minor | minor |
xtd::version::build | undefined (-1) |
xtd::version::revision | undefined (-1) |
Initializes a new instance of the xtd::version class using the specified major, minor and build values.
major | The major version number. |
minor | The minor version number. |
build | The build version number. |
xtd::out_of_range_exception | major, minor or build is less than zero. |
Property | Value |
---|---|
xtd::version::major | major |
xtd::version::minor | minor |
xtd::version::build | build |
xtd::version::revision | undefined (-1) |
Initializes a new instance of the xtd::version class using the specified major, minor, build and revision values.
major | The major version number. |
minor | The minor version number. |
build | The build version number. |
revision | The revision version number. |
xtd::out_of_range_exception | major, minor, build or revision is less than zero. |
Property | Value |
---|---|
xtd::version::major | major |
xtd::version::minor | minor |
xtd::version::build | build |
xtd::version::revision | revision |
|
noexcept |
Gets the value of the build component of the version number for the current xtd::version object.
|
noexcept |
Gets the value of the major component of the version number for the current xtd::version object.
|
noexcept |
Gets the high 16 bits of the revision number.
|
noexcept |
Gets the value of the minor component of the version number for the current xtd::version object.
|
noexcept |
Gets the low 16 bits of the revision number.
|
noexcept |
Gets the value of the revision component of the version number for the current xtd::version object.
Compares the current xtd::version object to a specified object and returns an indication of their relative values.
version | An object to compare. |
Return value | Meaning |
---|---|
Less than zero | The current xtd::version object is a version before version. |
Zero | The current xtd::version object is the same version as version. |
Greater than zero | The current xtd::version object is a version subsequent to version. |
Implements xtd::icomparable< version >.
|
overridevirtualnoexcept |
Determines whether the specified object is equal to the current object.
obj | The object to compare with the current object. |
true
if the specified object is equal to the current object. otherwise, false
. Reimplemented from xtd::object.
|
overridevirtualnoexcept |
Determines whether the specified object is equal to the current object.
v | The object to compare with the current object. |
true
if the specified object is equal to the current object. otherwise, false
. Implements xtd::iequatable< version >.
|
overridevirtualnoexcept |
Serves as a hash function for a particular type.
Reimplemented from xtd::object.
|
overridevirtualnoexcept |
Converts the value of the current xtd::version object to its equivalent xtd::string representation.
major.minor[.build[.revision]]For example, if you create a xtd::version object using the constructor xtd::version(1, 1), the returned string is "1.1". If you create a xtd::version object using the constructor xtd::version(1, 3, 4, 2), the returned string is "1.3.4.2".
Reimplemented from xtd::object.
xtd::string xtd::version::to_string | ( | size_t | field_count | ) | const |
Converts the value of the current xtd::version object to its equivalent xtd::string representation. A specified count indicates the number of components to return.
field_count | The number of components to return. The field_count ranges from 0 to 4. |
field_count | Return Value |
---|---|
0 | An empty string (""). |
1 | major |
2 | major.minor |
3 | major.minor.build |
4 | major.minor.build.revision |
xtd::argument_exception | field_count is more than 4 -or- field_count is more than the number of components defined in the current xtd::version object. |
|
static |
Converts the string representation of a version number to an equivalent Version object.
input | A string that contains a version number to convert. |
xtd::argument_out_of_range_exception | A major, minor, build, or revision component is less than zero. |
xtd::format_exception | At least one component of input does not parse to an integer. |
xtd::overflow_exception | At least one component of input represents a number greater than std::numeric_limits<int32>::max(). |
major.minor[.build[.revision]]
|
staticnoexcept |
Tries to convert the string representation of a version number to an equivalent xtd::version object, and returns a value that indicates whether the conversion succeeded.
input | A string that contains a version number to convert. |
result | When this method returns, contains the xtd::version equivalent of the number that is contained in input, if the conversion succeeded. If input is empty, or if the conversion fails, result is empty when the method returns. |
true
if the input parameter was converted successfully; otherwise, false
. false
if input is null, has fewer than two or more than four components, has at least one component that is not an integer, has at least one component that is less than zero, or has at least one component that is greater than std::numeric_limits<int32>::max(). For the parse operation to succeed, the input parameter must be in the following format: major.minor[.build[.revision]]where major, minor, build, and revision are the string representations of the version number's four components: major version number, minor version number, build number, and revision number, respectively. Optional components are shown in square brackets ([ and ]). The components must appear in order and must be separated by periods.