Represents the version number of an assembly, operating system, or the xtd. This class cannot be inherited.
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following example shows how to use xtd::version to get the version of the Operating System.
#include <xtd/xtd>
namespace examples {
class program :
public object {
public:
static void main() {
}
};
}
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
Represents information about an operating system, such as the version and platform identifier....
Definition operating_system.h:23
const xtd::version & version() const noexcept
Gets a xtd::version object that identifies the operating system.
Definition operating_system.h:109
xtd::ustring version_string() const noexcept
Gets the concatenated string representation of the platform identifier, version, and service pack tha...
Definition operating_system.h:114
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.h:93
xtd::ustring to_string() const noexcept override
Converts the value of the current xtd::version object to its equivalent xtd::ustring representation.
#define startup_(main_class)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.h:49
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
- Warning
- The value of xtd::version properties that have not been explicitly assigned a value is undefined (-1).
- Retrieving Version Information
- xtd::version objects are most frequently used to store version information about some system or application component (such as the operating system), the common language runtime, the current application's executable, or a particular assembly. The following examples illustrate some of the most common scenarios:
- Retrieving the operating system version. The following example uses the xtd::operating_system::version property to retrieve the version number of the operating system.
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static xtd::operating_system os_version()
Gets an operating_system object that contains the current platform identifier and version number.
- Retrieving the version of xtd. The following example uses the xtd::environment::version property to retrieve version information about xtd.
static xtd::version version()
Gets a version consisting of the major, minor, build, and revision numbers of the xtd framework.
- Comparing xtd::version objects
- You can use the xtd::version::compare_to method to determine whether one xtd::version object is earlier than, the same as, or later than a second xtd::version object. The following example indicates that xtd::version 2.1 is later than xtd::version 2.0.
switch(v1.compare_to(v2)) {
}
static void write(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition console.h:333
For two versions to be equal, the major, minor, build, and revision numbers of the first xtd::version object must be identical to those of the second xtd::version object. If the build or revision number of a xtd::version object is undefined, that xtd::version object is considered to be earlier than a xtd::vVersion object whose build or revision number is equal to zero. The following example illustrates this by comparing three xtd::version objects that have undefined version components.
enum class version_time {earlier = -1, same = 0, later = 1 };
std::ostream& operator<<(std::ostream& os, version_time value) {
return os <<
to_string(value, {{version_time::earlier,
"earlier"}, {version_time::same,
"same"}, {version_time::later,
"later"}});}
class example {
public:
static void main() {
show_relationship(v1, v1a);
show_relationship(v1b, v1a);
}
private:
console::write_line(
"Relationship of {0} to {1}: {2}", v1, v2, as<version_time>(v1.
compare_to(v2)));
}
};
int32_t compare_to(const object &version) const noexcept override
Compares the current xtd::version object to a specified object and returns an indication of their rel...
|
| version () noexcept=default |
| Initializes a new instance of the xtd::version class.
|
|
| version (const xtd::ustring &version) |
| Initializes a new instance of the xtd::version class using the specified string.
|
|
| version (int32_t major, int32_t minor) |
| Initializes a new instance of the xtd::version class using the specified major and minor values.
|
|
| version (int32_t major, int32_t minor, int32_t build) |
| Initializes a new instance of the xtd::version class using the specified major, minor and build values.
|
|
| version (int32_t major, int32_t minor, int32_t build, int32_t revision) |
| Initializes a new instance of the xtd::version class using the specified major, minor, build and revision values.
|
|
int32_t | build () const noexcept |
| Gets the value of the build component of the version number for the current xtd::version object.
|
|
int32_t | compare_to (const object &version) const noexcept override |
| Compares the current xtd::version object to a specified object and returns an indication of their relative values.
|
|
int32_t | 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.
|
|
int32_t | major () const noexcept |
| Gets the value of the major component of the version number for the current xtd::version object.
|
|
int16_t | major_revision () const noexcept |
| Gets the high 16 bits of the revision number.
|
|
int32_t | minor () const noexcept |
| Gets the value of the minor component of the version number for the current xtd::version object.
|
|
int16_t | minor_revision () const noexcept |
| Gets the low 16 bits of the revision number.
|
|
int32_t | revision () const noexcept |
| Gets the value of the revision component of the version number for the current xtd::version object.
|
|
xtd::ustring | to_string () const noexcept override |
| Converts the value of the current xtd::version object to its equivalent xtd::ustring representation.
|
|
xtd::ustring | to_string (size_t field_count) const |
| Converts the value of the current xtd::version object to its equivalent xtd::ustring representation. A specified count indicates the number of components to return.
|
|
| object ()=default |
| Create a new instance of the ultimate base class object.
|
|
virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object.
|
|
virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type.
|
|
template<typename object_t > |
std::unique_ptr< object_t > | memberwise_clone () const |
| Gets the type of the current instance.
|
|
virtual xtd::ustring | to_string () const noexcept |
| Returns a std::string that represents the current object.
|
|
virtual int32_t | compare_to (const object &obj) const noexcept |
| Compares the current instance with another object of the same type.
|
|
virtual int32_t | compare_to (const version &obj) const noexcept=0 |
| Compares the current instance with another object of the same type.
|
|
|
static version | parse (const xtd::ustring &input) |
| Converts the string representation of a version number to an equivalent Version object.
|
|
static bool | try_parse (const xtd::ustring &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.
|
|
static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal.
|
|
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance.
|
|