Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
2cabff9c
Commit
2cabff9c
authored
Jul 13, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make UUID comparable
parent
d25d4f99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
libcaf_core/caf/uuid.hpp
libcaf_core/caf/uuid.hpp
+10
-11
No files found.
libcaf_core/caf/uuid.hpp
View file @
2cabff9c
...
@@ -6,9 +6,11 @@
...
@@ -6,9 +6,11 @@
#include <array>
#include <array>
#include <cstdint>
#include <cstdint>
#include <cstring>
#include <string>
#include <string>
#include "caf/byte.hpp"
#include "caf/byte.hpp"
#include "caf/detail/comparable.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/error.hpp"
#include "caf/error.hpp"
#include "caf/fwd.hpp"
#include "caf/fwd.hpp"
...
@@ -19,7 +21,7 @@ namespace caf {
...
@@ -19,7 +21,7 @@ namespace caf {
/// A universally unique identifier according to
/// A universally unique identifier according to
/// [RFC 4122](https://tools.ietf.org/html/rfc4122). While this implementation
/// [RFC 4122](https://tools.ietf.org/html/rfc4122). While this implementation
/// can read all UUID versions, it can only create random-generated ones.
/// can read all UUID versions, it can only create random-generated ones.
class
CAF_CORE_EXPORT
uuid
{
class
CAF_CORE_EXPORT
uuid
:
detail
::
comparable
<
uuid
>
{
public:
public:
using
array_type
=
std
::
array
<
byte
,
16
>
;
using
array_type
=
std
::
array
<
byte
,
16
>
;
...
@@ -119,6 +121,13 @@ public:
...
@@ -119,6 +121,13 @@ public:
/// Returns whether `parse` would produce a valid UUID.
/// Returns whether `parse` would produce a valid UUID.
static
bool
can_parse
(
string_view
str
)
noexcept
;
static
bool
can_parse
(
string_view
str
)
noexcept
;
/// Lexicographically compares `this` and `other`.
/// @returns a negative value if `*this < other`, zero if `*this == other`
/// and a positive number if `*this > other`.
int
compare
(
const
uuid
&
other
)
const
noexcept
{
return
memcmp
(
bytes_
.
data
(),
other
.
bytes_
.
data
(),
16u
);
}
private:
private:
/// Stores the fields, encoded as 16 octets:
/// Stores the fields, encoded as 16 octets:
///
///
...
@@ -138,16 +147,6 @@ private:
...
@@ -138,16 +147,6 @@ private:
array_type
bytes_
;
array_type
bytes_
;
};
};
/// @relates uuid
inline
bool
operator
==
(
const
uuid
&
x
,
const
uuid
&
y
)
noexcept
{
return
x
.
bytes
()
==
y
.
bytes
();
}
/// @relates uuid
inline
bool
operator
!=
(
const
uuid
&
x
,
const
uuid
&
y
)
noexcept
{
return
x
.
bytes
()
!=
y
.
bytes
();
}
/// @relates uuid
/// @relates uuid
CAF_CORE_EXPORT
error
parse
(
string_view
str
,
uuid
&
dest
);
CAF_CORE_EXPORT
error
parse
(
string_view
str
,
uuid
&
dest
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment