CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
guid.h
1
3#ifndef _aspose_system_guid_h_
4#define _aspose_system_guid_h_
5
6#include <fwd.h>
7#include <system/array.h>
8#include <system/boxable_traits.h>
9#include <system/details/array_view.h>
10#include <system/details/stack_array.h>
11
12
13#ifdef ASPOSECPPLIB_BEING_BUILT
14#include <boost/uuid/uuid.hpp>
15#endif
16
17
18namespace boost { namespace uuids {
20 ASPOSECPP_3RD_PARTY_STRUCT(uuid);
21} }
22
23
24namespace System {
25 namespace Detail {
27 ASPOSECPP_3RD_PARTY_TYPE_HOLDER(boost::uuids::uuid, uuid, sizeof(std::uint8_t[16]), uint8_t, UuidHolder);
28 }
29
33class ASPOSECPP_SHARED_CLASS Guid
34{
35public:
37 ASPOSECPP_SHARED_API Guid();
40 ASPOSECPP_SHARED_API Guid(const ArrayPtr<uint8_t>& b);
43 ASPOSECPP_SHARED_API Guid(const System::Details::ArrayView<uint8_t> &b);
46 ASPOSECPP_SHARED_API Guid(const String& g);
52 ASPOSECPP_SHARED_API Guid(int32_t a, int16_t b, int16_t c, const ArrayPtr<uint8_t>& d);
58 ASPOSECPP_SHARED_API Guid(int32_t a, int16_t b, int16_t c, const System::Details::ArrayView<uint8_t>& d);
71 ASPOSECPP_SHARED_API Guid(int32_t a, int16_t b, int16_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t i, uint8_t j, uint8_t k);
84 ASPOSECPP_SHARED_API Guid(uint32_t a, uint16_t b, uint16_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t i, uint8_t j, uint8_t k);
86 ASPOSECPP_SHARED_API ~Guid();
89 ASPOSECPP_SHARED_API Guid(const Guid &guid);
93 ASPOSECPP_SHARED_API Guid& operator = (const Guid &guid);
97 ASPOSECPP_SHARED_API int CompareTo(const Guid& g) const;
101 ASPOSECPP_SHARED_API bool Equals(const Guid& g) const;
104 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ToByteArray() const;
106 ASPOSECPP_SHARED_API String ToString() const;
110 ASPOSECPP_SHARED_API String ToString(const String& format) const;
115 ASPOSECPP_SHARED_API String ToString(const String& format, const SharedPtr<Globalization::CultureInfo>& culture) const;
119 ASPOSECPP_SHARED_API bool operator != (const Guid& b) const;
123 ASPOSECPP_SHARED_API bool operator == (const Guid& b) const;
125 static Guid ASPOSECPP_SHARED_API Empty;
127 static ASPOSECPP_SHARED_API Guid NewGuid();
131 static ASPOSECPP_SHARED_API Guid Parse(const String& input);
136 static ASPOSECPP_SHARED_API bool TryParse(const String& input, Guid& g);
138 ASPOSECPP_SHARED_API int GetHashCode() const;
139
140private:
143 Guid(boost::uuids::uuid uuid);
145 void Init(uint32_t a, uint16_t b, uint16_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t i, uint8_t j, uint8_t k);
149 static char_t HexToChar(int a);
157 static size_t HexsToChars(std::u16string & guid_str, size_t offset, uint8_t a, uint8_t b, bool hex = false);
158
160 Detail::UuidHolder m_uuid;
161
163 struct NatvisHelpers
164 {
166 struct Hex { unsigned char c; };
168 struct HexLow { unsigned char c; };
170 struct HexHigh { unsigned char c; };
171 };
172};
173
176template<> struct IsBoxable<Guid> : std::true_type {};
178
180ASPOSECPP_SHARED_API void PrintTo(const Guid& value, std::ostream* stream);
181
186inline std::ostream& operator<<(std::ostream& stream, const Guid& guid)
187{
188 stream << guid.ToString();
189 return stream;
190}
191
196inline std::wostream& operator<<(std::wostream& stream, const Guid& guid)
197{
198 stream << guid.ToString();
199 return stream;
200}
201
202} // namespace System
203
204namespace std
205{
207 template <>
208 struct hash<System::Guid>
209 {
212 std::size_t operator()(const System::Guid& g) const
213 {
214 return static_cast<std::size_t>(g.GetHashCode());
215 }
216 };
217}
218
219#endif // _aspose_system_guid_h_
Represents a Globally Unique IDentifier This type should be allocated on stack and passed to function...
Definition: guid.h:34
Guid(const System::Details::ArrayView< uint8_t > &b)
Constructs an object that represents a GUID specified as an array view of unsigned 8-bit integer valu...
String ToString(const String &format) const
Converts the GUID represented by the current object to its string representation using the specified ...
int GetHashCode() const
Returns a hash code for the current object.
static Guid NewGuid()
Generates a new GUID and returns a Guid object that represents it.
Guid(int32_t a, int16_t b, int16_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t i, uint8_t j, uint8_t k)
Constructs an instance of Guid class from the specified unsigned integers and bytes.
Guid(const ArrayPtr< uint8_t > &b)
Constructs an object that represents a GUID specified as an array of unsigned 8-bit integer values.
static Guid Parse(const String &input)
Converts the specified string representation of a GUID into equivalent Guid object.
ArrayPtr< uint8_t > ToByteArray() const
Converts the GUID represented by the current object into array of bytes.
Guid(const String &g)
Constructs an object that represents a GUID specified as a string.
bool Equals(const Guid &g) const
Determines if the GUIDs represented by the current and specified objects are equal.
Guid(const Guid &guid)
Constructs an object that represents the same GUID as the specified object.
int CompareTo(const Guid &g) const
Performs arithmetic comparison of the GUIDs represented by the current and specified objects.
String ToString(const String &format, const SharedPtr< Globalization::CultureInfo > &culture) const
Converts the GUID represented by the current object to its string representation using the specified ...
Guid(int32_t a, int16_t b, int16_t c, const ArrayPtr< uint8_t > &d)
Constructs an instance of Guid class from the specified GUID components.
static bool TryParse(const String &input, Guid &g)
Tries to convert the specified string into Guid object.
Guid(int32_t a, int16_t b, int16_t c, const System::Details::ArrayView< uint8_t > &d)
Constructs an instance of Guid class from the specified GUID components.
Guid(uint32_t a, uint16_t b, uint16_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h, uint8_t i, uint8_t j, uint8_t k)
Constructs an instance of Guid class from the specified unsigned integers and bytes.
static Guid Empty
Represents a GUID that has a value of 0.
Definition: guid.h:125
~Guid()
Destructor.
Guid()
Constructs an object that represents a GUID consisting of all zeroes.
String ToString() const
Converts the GUID represented by the current object to its string representation.
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Definition: db_command.h:9
void PrintTo(DateTime value, std::ostream *stream)
Prints value to ostream. Mostly used for debug.
bool operator!=(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:157
std::ostream & operator<<(std::ostream &stream, DateTime date_time)
Insert data into the stream using UTF-8 encoding.
Definition: date_time.h:729
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:151
The utility structure for Natvis.
Definition: guid.h:170
unsigned char c
Definition: guid.h:170
The utility structure for Natvis.
Definition: guid.h:166
unsigned char c
Definition: guid.h:166
The utility structure for Natvis.
Definition: guid.h:168
unsigned char c
Definition: guid.h:168
Template predicate that checks if boxing of the specified type is supported.
Definition: boxable_traits.h:16