xtd 0.2.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 object, public 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 int32 build() const noexcept;
196
200 int32 major() const noexcept;
201
205 int16 major_revision() const noexcept;
206
210 int32 minor() const noexcept;
211
215 int16 minor_revision() const noexcept;
216
220 int32 revision() const noexcept;
222
224
241 int32 compare_to(const version& version) const noexcept override;
242
246 bool equals(const object& obj) const noexcept override;
250 bool equals(const version& v) const noexcept override;
251
254 xtd::size get_hash_code() const noexcept override;
255
260 xtd::string to_string() const noexcept override;
273 xtd::string to_string(size_t field_count) const;
274
293
295
315 static version from_uint64(xtd::uint64 value) noexcept;
316
328 static version parse(const xtd::string& input);
329
338 static bool try_parse(const xtd::string& input, version& result) noexcept;
340
341 private:
342 int32 major_ = 0;
343 int32 minor_ = 0;
344 int32 build_ = -1;
345 int32 revision_ = -1;
346 };
347
358 template<>
359 inline xtd::version parse<xtd::version>(const std::string& str) {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:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
object()=default
Create a new instance of the ultimate base class object.
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.hpp:115
int32 major() const noexcept
Gets the value of the major component of the version number for the current xtd::version object.
xtd::uint64 to_uint64() const
Convert the value of the current xtd::version object to its equivalent xtd::uint64 representation.
int32 minor() const noexcept
Gets the value of the minor component of the version number for the current xtd::version object.
version() noexcept=default
Initializes a new instance of the xtd::version class.
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,...
int16 major_revision() const noexcept
Gets the high 16 bits of the revision number.
int32 build() const noexcept
Gets the value of the build component of the version number for the current xtd::version object.
static version from_uint64(xtd::uint64 value) noexcept
Creates a new xtd::version object from its 64-bit integer representation.
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 rel...
static version parse(const xtd::string &input)
Converts the string representation of a version number to an equivalent Version object.
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
xtd::string to_string() const noexcept override
Converts the value of the current xtd::version object to its equivalent xtd::string representation.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
int32 revision() const noexcept
Gets the value of the revision 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.
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
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
value_t parse(const std::string &str)
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.