summaryrefslogtreecommitdiff
path: root/zen/guid.h
blob: 823f443194b14cf00f0d0014039cba4a89166ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved        *
// **************************************************************************

#ifndef GUID_H_INCLUDED
#define GUID_H_INCLUDED

#include <string>
#include <boost/uuid/uuid.hpp>

#ifdef __MINGW32__  //boost should start cleaning this mess up
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif

#include <boost/uuid/uuid_generators.hpp>

#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif


namespace zen
{
inline
std::string generateGUID() //creates a 16 byte GUID
{
    boost::uuids::uuid nativeRep = boost::uuids::random_generator()(); //generator is thread-safe like an int
    //perf: generator: 0.22ms per call; retrieve GUID: 0.12µs per call
    return std::string(nativeRep.begin(), nativeRep.end());
}
}

#endif // GUID_H_INCLUDED
bgstack15