xtd 1.0.0
Loading...
Searching...
No Matches
version.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "icomparable.hpp"
6#include "string.hpp"
7#include "parse.hpp"
8
10#if defined(major)
11/*
12# if defined(_MSC_VER) && __cplusplus < 202302L
13# pragma message("The macro `major` is defined. If you include the `sys/sysmacros.h` filev, please undef the 'major' macro before including `xtd/version`. xtd will undef the `major` macro.")
14# else
15# warning "The macro `major` is defined. If you include the `sys/sysmacros.h` file or other, please undef the 'major' macro before including `xtd/version`. xtd will undef the `major` macro."
16# endif
17 */
18# undef major
19#endif
20
21#if defined(minor)
22/*
23# if defined(_MSC_VER) && __cplusplus < 202302L
24# pragma message("The macro `minor` is defined. If you include the `sys/sysmacros.h` file or other, please undef the 'minor' macro before including `xtd/version`. xtd will undef the `minor` macro.")
25# else
26# warning "The macro `minor` is defined. If you include the `sys/sysmacros.h` file or other, please undef the 'minor' macro before including `xtd/version`. xtd will undef the `minor` macro."
27# endif
28 */
29# undef minor
30#endif
32
34namespace xtd {
115 class version final : public xtd::object, public xtd::icomparable<version>, public xtd::iequatable<version> {
116 public:
118
128 version() noexcept = default;
139 explicit version(const xtd::string& version);
183
185 version(const version&) noexcept = default;
186 version& operator =(const version&) noexcept = default;
188
190
195 [[nodiscard]] auto build() const noexcept -> xtd::int32;
196
200 [[nodiscard]] auto major() const noexcept -> xtd::int32;
201
205 [[nodiscard]] auto major_revision() const noexcept -> xtd::int16;
206
210 [[nodiscard]] auto minor() const noexcept -> xtd::int32;
211
215 [[nodiscard]] auto minor_revision() const noexcept -> xtd::int16;
216
220 [[nodiscard]] auto revision() const noexcept -> xtd::int32;
222
224
241 [[nodiscard]] auto compare_to(const xtd::version& version) const noexcept -> xtd::int32 override;
242
246 [[nodiscard]] auto equals(const object& obj) const noexcept -> bool override;
250 [[nodiscard]] auto equals(const version& v) const noexcept -> bool override;
251
254 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override;
255
260 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
273 [[nodiscard]] auto to_string(xtd::usize field_count) const -> xtd::string;
274
291 [[nodiscard]] auto to_uint64() const -> xtd::uint64;
293
295
315 [[nodiscard]] static auto from_uint64(xtd::uint64 value) noexcept -> version;
316
328 [[nodiscard]] static auto parse(const xtd::string& input) -> version;
329
338 [[nodiscard]] static auto try_parse(const xtd::string& input, version& result) noexcept -> bool;
340
341 private:
342 xtd::int32 major_ = 0;
343 xtd::int32 minor_ = 0;
344 xtd::int32 build_ = -1;
345 xtd::int32 revision_ = -1;
346 };
347
358 template<>
359 [[nodiscard]] inline auto parse<xtd::version>(const std::string& str) -> xtd::version {return xtd::version::parse(str);}
360}
361
362#include "literals/version.hpp"
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.hpp:115
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
auto major_revision() const noexcept -> xtd::int16
Gets the high 16 bits of the revision number.
auto compare_to(const xtd::version &version) const noexcept -> xtd::int32 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.
static auto from_uint64(xtd::uint64 value) noexcept -> version
Creates a new xtd::version object from its 64-bit integer representation.
auto minor_revision() const noexcept -> xtd::int16
Gets the low 16 bits of the revision number.
static auto parse(const xtd::string &input) -> version
Converts the string representation of a version number to an equivalent Version object.
auto equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
auto to_uint64() const -> xtd::uint64
Convert the value of the current xtd::version object to its equivalent xtd::uint64 representation.
auto to_string() const noexcept -> xtd::string override
Converts the value of the current xtd::version object to its equivalent xtd::string representation.
static auto try_parse(const xtd::string &input, version &result) noexcept -> bool
Tries to convert the string representation of a version number to an equivalent xtd::version object,...
auto build() const noexcept -> xtd::int32
Gets the value of the build component of the version number for the current xtd::version object.
auto major() const noexcept -> xtd::int32
Gets the value of the major component of the version number for the current xtd::version object.
auto minor() const noexcept -> xtd::int32
Gets the value of the minor component of the version number for the current xtd::version object.
auto revision() const noexcept -> xtd::int32
Gets the value of the revision component of the version number for the current xtd::version object.
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
std::uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
auto parse(const std::string &str) -> value_t
Convert a string into a type.
Definition parse.hpp:34
@ v
The V key.
Definition console_key.hpp:130
Contains xtd::icomparable interface.
Contains xtd::version suffixes.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::parse methods.
Contains xtd::string alias.