Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
14818fc3
Commit
14818fc3
authored
5 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Make UUID work in Windows.
parent
945271d7
No related branches found
No related tags found
No related merge requests found
Pipeline
#9534
passed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
net/cpp/include/ftl/uuid.hpp
+26
-7
26 additions, 7 deletions
net/cpp/include/ftl/uuid.hpp
net/cpp/test/p2p_base_unit.cpp
+2
-0
2 additions, 0 deletions
net/cpp/test/p2p_base_unit.cpp
with
28 additions
and
7 deletions
net/cpp/include/ftl/uuid.hpp
+
26
−
7
View file @
14818fc3
#ifndef _FTL_UUID_HPP_
#define _FTL_UUID_HPP_
#ifndef WIN32
#include
<uuid/uuid.h>
#else
#include
<Rpc.h>
#endif
#include
<memory>
#include
<string>
#include
<functional>
...
...
@@ -13,25 +18,35 @@ namespace ftl {
*/
class
UUID
{
public:
UUID
()
{
uuid_generate
(
uuid_
);
};
UUID
(
int
u
)
{
memset
(
uuid_
,
u
,
16
);
};
UUID
(
const
UUID
&
u
)
{
memcpy
(
uuid_
,
u
.
uuid_
,
16
);
}
UUID
()
{
#ifdef WIN32
::
UuidCreate
(
&
uuid_
);
#else
uuid_generate
(
uuid_
);
#endif
};
UUID
(
int
u
)
{
memset
(
&
uuid_
,
u
,
16
);
};
UUID
(
const
UUID
&
u
)
{
memcpy
(
&
uuid_
,
&
u
.
uuid_
,
16
);
}
bool
operator
==
(
const
UUID
&
u
)
const
{
return
memcmp
(
uuid_
,
u
.
uuid_
,
16
)
==
0
;
}
bool
operator
!=
(
const
UUID
&
u
)
const
{
return
memcmp
(
uuid_
,
u
.
uuid_
,
16
)
!=
0
;
}
bool
operator
==
(
const
UUID
&
u
)
const
{
return
memcmp
(
&
uuid_
,
&
u
.
uuid_
,
16
)
==
0
;
}
bool
operator
!=
(
const
UUID
&
u
)
const
{
return
memcmp
(
&
uuid_
,
&
u
.
uuid_
,
16
)
!=
0
;
}
/**
* Get a raw data string.
*/
std
::
string
str
()
const
{
return
std
::
string
((
char
*
)
uuid_
,
16
);
};
const
unsigned
char
*
raw
()
const
{
return
&
uuid_
[
0
]
;
}
std
::
string
str
()
const
{
return
std
::
string
((
char
*
)
&
uuid_
,
16
);
};
const
unsigned
char
*
raw
()
const
{
return
(
const
unsigned
char
*
)
&
uuid_
;
}
/**
* Get a pretty string.
*/
std
::
string
to_string
()
const
{
char
b
[
37
];
#ifdef WIN32
UuidToString
(
&
uuid_
,
(
RPC_CSTR
*
)
b
);
#else
uuid_unparse
(
uuid_
,
b
);
#endif
return
std
::
string
(
b
);
}
...
...
@@ -39,7 +54,11 @@ namespace ftl {
MSGPACK_DEFINE
(
uuid_
);
private
:
#ifdef WIN32
_GUID
uuid_
;
#else
unsigned
char
uuid_
[
16
];
#endif
};
};
...
...
This diff is collapsed.
Click to expand it.
net/cpp/test/p2p_base_unit.cpp
+
2
−
0
View file @
14818fc3
...
...
@@ -5,7 +5,9 @@
#include
<memory>
#include
<iostream>
#ifndef WIN32
#include
<sys/select.h>
#endif
using
ftl
::
net
::
Dispatcher
;
using
ftl
::
net
::
Protocol
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment