PLCnext API Documentation 25.0.2.69
Uuid.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Core/PimplPtr.hxx"
9
10namespace Arp::Base::Commons::Configuration
11{
12
15class ARP_EXPORT Uuid
16{
17public: // Impl forward declaration
18 class Impl;
19
20public: // construction
21 Uuid(void);
22 // canonical construction/destruction/assignment
23 Uuid(const Uuid& arg);
24 Uuid(Uuid&& arg)noexcept;
25 Uuid& operator=(const Uuid& arg);
26 Uuid& operator=(Uuid&& arg)noexcept;
27 ~Uuid(void);
28
29public: // compare operators
30 ARP_EXPORT friend bool operator==(const Uuid& lhs, const Uuid& rhs)noexcept;
31 ARP_EXPORT friend bool operator!=(const Uuid& lhs, const Uuid& rhs)noexcept;
32 ARP_EXPORT friend bool operator<(const Uuid& lhs, const Uuid& rhs)noexcept;
33 ARP_EXPORT friend bool operator>(const Uuid& lhs, const Uuid& rhs)noexcept;
34 ARP_EXPORT friend bool operator<=(const Uuid& lhs, const Uuid& rhs)noexcept;
35 ARP_EXPORT friend bool operator>=(const Uuid& lhs, const Uuid& rhs)noexcept;
36
37public: // stream operators
38 ARP_EXPORT friend std::ostream& operator<<(std::ostream& os, const Uuid& id);
39 ARP_EXPORT friend std::istream& operator>>(std::istream& is, Uuid& id);
40
41public: // static operations
42 static Uuid GetEmpty(void);
43 static Uuid CreateNew(void);
44 static Uuid Create(const byte* pData);
45 static Uuid CreateFromLittleEndian(const byte* pData);
46 static Uuid Parse(const String& input);
47 static bool TryParse(const String& input, Uuid& result);
48
49public: // setter/getter operations
50 bool IsEmpty(void)const;
51
52public: // operations
53 String ToString(void)const;
54 size_t GetHashValue(void)const;
55 void Clear(void);
56 void CopyTo(byte* pData)const;
57 void CopyLittleEndianTo(byte* pData)const;
58
59public: // internal operations
60 Impl& GetImpl(void);
61 const Impl& GetImpl(void)const;
62
63private: // Impl usings
65
66private: // Impl fields
67 Pimpl pimpl;
68};
69
70} // end of namespace Arp::Base::Commons::Configuration
71
73// template specialization of Uuid formatter
74template<> struct fmt::formatter<Arp::Base::Commons::Configuration::Uuid> : public fmt::ostream_formatter {};
75
77// standard template specializations of class Uuid
78namespace std
79{
80
82template<>
83struct hash<Arp::Base::Commons::Configuration::Uuid>
84{
85public: // usings
87 using result_type = size_t;
88
89public: // operators
94 {
95 return arg.GetHashValue();
96 }
97};
98
99} // end of namespace std
This class represents a Universal Unique ID.
Definition: Uuid.hpp:16
~Uuid(void)
The default destructor.
size_t GetHashValue(void) const
Returns the hash value of this Uuid.
Definition: Uuid.cpp:206
Uuid(const Uuid &arg)
The default copy constructor.
Uuid & operator=(Uuid &&arg) noexcept
The default move-assignment operator.
Uuid & operator=(const Uuid &arg)
THe default copy-assignment operator.
Uuid(Uuid &&arg) noexcept
The default move constructor.
Adapter class to implement PImpl idiom.
Definition: PimplPtr.hxx:15
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
@ CreateNew
Creates a new file. An exception is raised if the file already exists.
@ Create
Creates a new file. If the file already exists, it is overwritten.
Root namespace for the PLCnext API
Namespace of the C++ standard library
size_t result_type
The result type (hash policy)
Definition: Uuid.hpp:87
result_type operator()(const argument_type &arg) const
Implementation of hash functor of class Uuid The hash value of arg .
Definition: Uuid.hpp:93