preCICE
v3.2.0
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Variables
_
a
b
c
d
e
f
h
i
m
n
p
r
s
t
Typedefs
b
d
e
g
l
m
p
r
s
t
u
v
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Variables
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
i
k
m
n
o
p
r
s
t
v
w
Enumerations
Enumerator
c
d
e
i
l
m
n
o
r
s
u
v
w
Related Symbols
Files
File List
File Members
All
_
a
b
c
d
e
g
i
j
m
n
o
p
r
s
t
v
Functions
a
b
c
g
m
p
r
s
t
v
Variables
Typedefs
Macros
b
d
m
n
p
t
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
src
utils
Hash.cpp
Go to the documentation of this file.
1
#include <boost/uuid/name_generator.hpp>
2
#include <boost/uuid/string_generator.hpp>
3
#include <boost/uuid/uuid_io.hpp>
4
5
#include "
utils/Hash.hpp
"
6
#include "
utils/assertion.hpp
"
7
8
namespace
precice::utils
{
9
10
std::string
preciceHash
(
std::string_view
s)
11
try
{
12
boost::uuids::string_generator ns_gen;
13
auto
ns = ns_gen(
"af7ce8f2-a9ee-46cb-38ee-71c318aa3580"
);
// md5 hash of precice.org as namespace
14
15
boost::uuids::name_generator gen{ns};
16
std::string
hash = boost::uuids::to_string(gen(s.
data
(), s.
size
()));
17
hash.
erase
(std::remove(hash.
begin
(), hash.
end
(),
'-'
), hash.
end
());
18
return
hash;
19
20
}
catch
(
const
std::runtime_error
&e) {
21
PRECICE_UNREACHABLE
(
"preCICE hashing failed"
, e.
what
());
22
return
""
;
23
}
10
std::string
preciceHash
(
std::string_view
s) {
…
}
24
25
}
// namespace precice::utils
Hash.hpp
assertion.hpp
PRECICE_UNREACHABLE
#define PRECICE_UNREACHABLE(...)
Definition
assertion.hpp:93
std::string
std::string_view
std::string::begin
T begin(T... args)
std::string_view::data
T data(T... args)
std::string::end
T end(T... args)
std::string::erase
T erase(T... args)
precice::utils
contains precice-related utilities.
Definition
PointToPointCommunicationTest.cpp:23
precice::utils::preciceHash
std::string preciceHash(std::string_view s)
creates a portable hash of the given input
Definition
Hash.cpp:10
std::runtime_error
std::string_view::size
T size(T... args)
std::runtime_error::what
T what(T... args)