Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
S
src
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
71
Issues
71
List
Boards
Labels
Service Desk
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Code Review
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
OPAL
src
Commits
8255e6f5
Commit
8255e6f5
authored
Apr 30, 2018
by
snuverink_j
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temporary duplicate HashNameGenerator for forgotten UUIDNameGenerator.h; for
#222
and
d9a2b372
parent
d9a2b372
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
optimizer/Util/UUIDNameGenerator.h
optimizer/Util/UUIDNameGenerator.h
+61
-0
No files found.
optimizer/Util/UUIDNameGenerator.h
0 → 100644
View file @
8255e6f5
#include <vector>
#include <string>
#include <sstream>
#include "boost/uuid/sha1.hpp"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
/**
* \brief Generates a hash name.
*
* Concatenates and hashes a vector of strings.
*/
class
UUIDNameGenerator
{
public:
static
std
::
string
generate
(
std
::
vector
<
std
::
string
>
arguments
,
size_t
world_pid
=
0
)
{
std
::
string
hash_string
=
""
;
foreach
(
std
::
string
arg
,
arguments
)
{
hash_string
+=
arg
;
}
// append PID
std
::
ostringstream
pidStr
;
pidStr
<<
world_pid
;
hash_string
+=
"_"
+
pidStr
.
str
();
boost
::
uuids
::
detail
::
sha1
hash
;
hash
.
process_bytes
(
hash_string
.
c_str
(),
hash_string
.
size
());
unsigned
int
digest
[
5
];
hash
.
get_digest
(
digest
);
char
hash_final
[
20
];
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
const
char
*
tmp
=
reinterpret_cast
<
char
*>
(
digest
);
hash_final
[
i
*
4
]
=
tmp
[
i
*
4
+
3
];
hash_final
[
i
*
4
+
1
]
=
tmp
[
i
*
4
+
2
];
hash_final
[
i
*
4
+
2
]
=
tmp
[
i
*
4
+
1
];
hash_final
[
i
*
4
+
3
]
=
tmp
[
i
*
4
];
}
std
::
ostringstream
hash_out
;
hash_out
<<
std
::
hex
;
for
(
int
i
=
0
;
i
<
20
;
i
++
)
{
hash_out
<<
((
hash_final
[
i
]
&
0x000000F0
)
>>
4
);
hash_out
<<
(
hash_final
[
i
]
&
0x0000000F
);
}
return
hash_out
.
str
();
}
private:
UUIDNameGenerator
()
{}
~
UUIDNameGenerator
()
{}
};
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