Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
common
Compare revisions
421ed9d1c0af7fadd5a6e9188c36f6f6a4290ed4 to ace72cd79ddea6874c56131ca7dde7b896f38a03
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
sip/common
Select target project
No results found
ace72cd79ddea6874c56131ca7dde7b896f38a03
Select Git revision
Loading items
Swap
Target
sip/common
Select target project
sip/common
1 result
421ed9d1c0af7fadd5a6e9188c36f6f6a4290ed4
Select Git revision
Loading items
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source
1
GUID generator
· ace72cd7
D-AIRY
authored
Dec 15, 2020
ace72cd7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
guid.cpp
+51
-0
51 additions, 0 deletions
guid.cpp
guid.h
+50
-0
50 additions, 0 deletions
guid.h
types.h
+1
-39
1 addition, 39 deletions
types.h
with
102 additions
and
39 deletions
guid.cpp
0 → 100644
View file @
ace72cd7
#include
"guid.h"
#include
<cstdio>
#ifdef _WINDOWS
#include
<objbase.h>
void
XCreateGUID
(
XGUID
*
pOut
)
{
GUID
newId
;
CoCreateGuid
(
&
newId
);
memcpy
(
pOut
,
&
newId
,
sizeof
(
XGUID
));
}
#define snprintf _snprintf
#elif defined(_LINUX)
#include
<uuid/uuid.h>
void
XCreateGUID
(
XGUID
*
pOut
)
{
uuid_generate
((
unsigned
char
*
)
pOut
);
}
#elif defined(_MAC)
#include
<CoreFoundation/CFUUID.h>
void
XCreateGUID
(
XGUID
*
pOut
)
{
auto
newId
=
CFUUIDCreate
(
NULL
);
auto
bytes
=
CFUUIDGetUUIDBytes
(
newId
);
CFRelease
(
newId
);
memcpy
(
pOut
,
&
bytes
,
sizeof
(
XGUID
));
}
#else
#error Unknown platform!
#endif
void
XGUIDToSting
(
const
XGUID
&
guid
,
char
*
dst
,
int
nBufSize
)
{
// {34D5ED67-D3D1-4ACE-9CE7-AAB5C4F9E2FD}
snprintf
(
dst
,
nBufSize
,
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}"
,
guid
.
Data1
,
guid
.
Data2
,
guid
.
Data3
,
guid
.
Data40
,
guid
.
Data41
,
guid
.
Data42
,
guid
.
Data43
,
guid
.
Data44
,
guid
.
Data45
,
guid
.
Data46
,
guid
.
Data47
);
}
bool
XGUIDFromString
(
XGUID
*
pGUID
,
const
char
*
szGUID
)
{
return
(
11
==
sscanf
(
szGUID
,
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}"
,
&
pGUID
->
Data1
,
&
pGUID
->
Data2
,
&
pGUID
->
Data3
,
&
pGUID
->
Data40
,
&
pGUID
->
Data41
,
&
pGUID
->
Data42
,
&
pGUID
->
Data43
,
&
pGUID
->
Data44
,
&
pGUID
->
Data45
,
&
pGUID
->
Data46
,
&
pGUID
->
Data47
));
}
This diff is collapsed.
Click to expand it.
guid.h
0 → 100644
View file @
ace72cd7
#ifndef __COMMON_GUID_H
#define __COMMON_GUID_H
#include
<memory.h>
typedef
struct
_XGUID
{
_XGUID
()
{
}
_XGUID
(
unsigned
long
l
,
unsigned
short
w1
,
unsigned
short
w2
,
unsigned
char
b1
,
unsigned
char
b2
,
unsigned
char
b3
,
unsigned
char
b4
,
unsigned
char
b5
,
unsigned
char
b6
,
unsigned
char
b7
,
unsigned
char
b8
)
:
Data1
(
l
),
Data2
(
w1
),
Data3
(
w2
),
Data40
(
b1
),
Data41
(
b2
),
Data42
(
b3
),
Data43
(
b4
),
Data44
(
b5
),
Data45
(
b6
),
Data46
(
b7
),
Data47
(
b8
)
{
}
unsigned
long
Data1
=
0
;
unsigned
short
Data2
=
0
;
unsigned
short
Data3
=
0
;
unsigned
char
Data40
=
0
;
unsigned
char
Data41
=
0
;
unsigned
char
Data42
=
0
;
unsigned
char
Data43
=
0
;
unsigned
char
Data44
=
0
;
unsigned
char
Data45
=
0
;
unsigned
char
Data46
=
0
;
unsigned
char
Data47
=
0
;
}
XGUID
;
#define DEFINE_XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
inline
bool
operator
<
(
const
XGUID
&
a
,
const
XGUID
&
b
)
{
return
(
memcmp
(
&
a
,
&
b
,
sizeof
(
XGUID
))
<
0
);
}
inline
bool
operator
==
(
const
XGUID
&
a
,
const
XGUID
&
b
)
{
return
(
memcmp
(
&
a
,
&
b
,
sizeof
(
XGUID
))
==
0
);
}
void
XCreateGUID
(
XGUID
*
pOut
);
void
XGUIDToSting
(
const
XGUID
&
guid
,
char
*
dst
,
int
nBufSize
);
bool
XGUIDFromString
(
XGUID
*
pGUID
,
const
char
*
szGUID
);
#endif
This diff is collapsed.
Click to expand it.
types.h
View file @
ace72cd7
...
...
@@ -19,6 +19,7 @@ See the license in LICENSE
#include
<mutex>
#include
<atomic>
#include
"spinlock.h"
#include
"guid.h"
#include
"enum_flags.h"
...
...
@@ -149,45 +150,6 @@ inline const char* strcasestr(const char *haystack, const char *needle)
# error "unsupported compiler"
#endif
typedef
struct
_XGUID
{
_XGUID
()
{
}
_XGUID
(
unsigned
long
l
,
unsigned
short
w1
,
unsigned
short
w2
,
unsigned
char
b1
,
unsigned
char
b2
,
unsigned
char
b3
,
unsigned
char
b4
,
unsigned
char
b5
,
unsigned
char
b6
,
unsigned
char
b7
,
unsigned
char
b8
)
:
Data1
(
l
),
Data2
(
w1
),
Data3
(
w2
),
Data40
(
b1
),
Data41
(
b2
),
Data43
(
b3
),
Data44
(
b4
),
Data45
(
b5
),
Data46
(
b6
),
Data47
(
b7
)
{
}
unsigned
long
Data1
=
0
;
unsigned
short
Data2
=
0
;
unsigned
short
Data3
=
0
;
unsigned
char
Data40
=
0
;
unsigned
char
Data41
=
0
;
unsigned
char
Data42
=
0
;
unsigned
char
Data43
=
0
;
unsigned
char
Data44
=
0
;
unsigned
char
Data45
=
0
;
unsigned
char
Data46
=
0
;
unsigned
char
Data47
=
0
;
}
XGUID
;
#define DEFINE_XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
inline
bool
operator
<
(
const
XGUID
&
a
,
const
XGUID
&
b
)
{
return
(
memcmp
(
&
a
,
&
b
,
sizeof
(
XGUID
))
<
0
);
}
inline
bool
operator
==
(
const
XGUID
&
a
,
const
XGUID
&
b
)
{
return
(
memcmp
(
&
a
,
&
b
,
sizeof
(
XGUID
))
==
0
);
}
class
IXUnknown
{
public:
...
...
This diff is collapsed.
Click to expand it.