xtd 0.2.0
guid.h
Go to the documentation of this file.
1 #pragma once
5 #include "core_export.h"
6 #include "icomparable.h"
7 #include "iequatable.h"
8 #include "object.h"
9 #include "ustring.h"
10 #include <vector>
11 
13 namespace xtd {
23  struct core_export_ guid final : public object, public icomparable<guid>, public xtd::iequatable<guid> {
24  public:
26 
31  static const guid empty;
33 
35 
38  guid() = default;
42  explicit guid(const std::vector<xtd::byte>& data);
46  explicit guid(const std::initializer_list<xtd::byte>& data);
59  explicit guid(int32 a, int16 b, int16 c, const std::vector<xtd::byte>& d);
72  explicit guid(uint32 a, uint16 b, uint16 c, const std::vector<xtd::byte>& d);
122  explicit guid(const ustring& guid);
124 
126  guid(const guid&) = default;
127  guid& operator =(const guid&) = default;
129 
131 
142  int32 compare_to(const guid& value) const noexcept override;
143 
144  bool equals(const guid& g) const noexcept override;
145 
150  static guid new_guid() noexcept;
151 
154  const std::vector<xtd::byte>& to_byte_array() const noexcept;
155 
161  xtd::ustring to_string() const noexcept override;
179  ustring to_string(ustring format) const;
181 
182  private:
183  std::vector<xtd::byte> data_ = std::vector<xtd::byte>(16);
184  };
185 
187  template<>
188  inline std::string to_string(const guid& value, const std::string& fmt, const std::locale& loc) {
189  return value.to_string(fmt);
190  }
192 }
Contains xtd::iequatable interface.
Contains xtd::icomparable interface.
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition: icomparable.h:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
uint_least16_t uint16
Represents a 16-bit unsigned integer.
Definition: types.h:228
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1063
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
Contains xtd::ustring class.
static const guid empty
Gets A read-only instance of the xtd::guid structure whose value is all zeros.
Definition: guid.h:31
int_least16_t int16
Represents a 16-bit signed integer.
Definition: types.h:118
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be us...
Definition: guid.h:23
uint_least8_t byte
Represents a 8-bit unsigned integer.
Definition: types.h:39
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239