xtd 0.2.0
version.h
Go to the documentation of this file.
1 #pragma once
5 #include "icomparable.h"
6 #include "ustring.h"
7 
9 #undef major
10 #undef minor
11 
14 namespace xtd {
95  class version final : public object, public icomparable<version>, public xtd::iequatable<version> {
96  public:
98 
108  version() noexcept = default;
119  explicit version(const xtd::ustring& version);
144  version(int32 major, int32 minor, int32 build);
161  version(int32 major, int32 minor, int32 build, int32 revision);
163 
165  version(const version&) noexcept = default;
166  version& operator =(const version&) noexcept = default;
168 
170 
175  int32 build() const noexcept;
176 
180  int32 major() const noexcept;
181 
185  int16 major_revision() const noexcept;
186 
190  int32 minor() const noexcept;
191 
195  int16 minor_revision() const noexcept;
196 
200  int32 revision() const noexcept;
202 
204 
221  int32 compare_to(const version& version) const noexcept override;
222 
223  bool equals(const version& v) const noexcept override;
224 
236  static version parse(const xtd::ustring& input);
237 
242  xtd::ustring to_string() const noexcept override;
255  xtd::ustring to_string(size_t field_count) const;
256 
265  static bool try_parse(const xtd::ustring& input, version& result) noexcept;
267 
268  private:
269  int32 major_ = 0;
270  int32 minor_ = 0;
271  int32 build_ = -1;
272  int32 revision_ = -1;
273  };
274 }
int32 major() const noexcept
Gets the value of the major component of the version number for the current xtd::version object...
Contains xtd::icomparable interface.
int16 major_revision() const noexcept
Gets the high 16 bits of the revision number.
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition: icomparable.h:17
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...
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
static version parse(const xtd::ustring &input)
Converts the string representation of a version number to an equivalent Version object.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition: version.h:95
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...
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
int32 build() const noexcept
Gets the value of the build component of the version number for the current xtd::version object...
Contains xtd::ustring class.
int16 minor_revision() const noexcept
Gets the low 16 bits of the revision number.
int_least16_t int16
Represents a 16-bit signed integer.
Definition: types.h:118
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
bool equals(const version &v) const noexcept override
Indicates whether the current object is equal to another object of the same type. ...
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
int32 revision() const noexcept
Gets the value of the revision component of the version number for the current xtd::version object...
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.
xtd::ustring to_string() const noexcept override
Converts the value of the current xtd::version object to its equivalent xtd::ustring representation...