diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:09:45 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:09:45 +0200 |
commit | 88c8801298cbf6fec9cdce254c7b3cb9e066a421 (patch) | |
tree | 35a35acf48eb227bac30abc8f87ea9b1c3c57b68 /shared/guid.cpp | |
parent | 3.12 (diff) | |
download | FreeFileSync-88c8801298cbf6fec9cdce254c7b3cb9e066a421.tar.gz FreeFileSync-88c8801298cbf6fec9cdce254c7b3cb9e066a421.tar.bz2 FreeFileSync-88c8801298cbf6fec9cdce254c7b3cb9e066a421.zip |
3.13
Diffstat (limited to 'shared/guid.cpp')
-rw-r--r-- | shared/guid.cpp | 54 |
1 files changed, 6 insertions, 48 deletions
diff --git a/shared/guid.cpp b/shared/guid.cpp index b20a1143..dcf63e60 100644 --- a/shared/guid.cpp +++ b/shared/guid.cpp @@ -1,7 +1,7 @@ // ************************************************************************** // * 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) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * // ************************************************************************** // #include "guid.h" @@ -12,59 +12,17 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #endif + #include <boost/uuid/uuid_generators.hpp> + #ifdef __MINGW32__ #pragma GCC diagnostic pop #endif -#include <cassert> -#include <algorithm> -#include <vector> - -using namespace util; - - -struct UniqueId::IntData -{ - boost::uuids::uuid nativeRep; -}; - - -UniqueId::UniqueId() : pData(new IntData) -{ - pData->nativeRep = boost::uuids::random_generator()(); -} - - -bool UniqueId::operator==(const UniqueId rhs) const -{ - return pData->nativeRep == rhs.pData->nativeRep; -} - -bool UniqueId::operator<(const UniqueId rhs) const +std::string util::generateGUID() //creates a 16 byte GUID { - return pData->nativeRep < rhs.pData->nativeRep; -} - - -UniqueId::UniqueId(wxInputStream& stream) : //read - pData(new IntData) -{ - std::vector<char> rawData(boost::uuids::uuid::static_size()); - stream.Read(&rawData[0], rawData.size()); - - std::copy(rawData.begin(), rawData.end(), pData->nativeRep.begin()); -} - - -void UniqueId::toStream(wxOutputStream& stream) const //write -{ - std::vector<char> rawData; - std::copy(pData->nativeRep.begin(), pData->nativeRep.end(), std::back_inserter(rawData)); - - assert(boost::uuids::uuid::static_size() == rawData.size()); - - stream.Write(&rawData[0], rawData.size()); + boost::uuids::uuid nativeRep = boost::uuids::random_generator()(); + return std::string(nativeRep.begin(), nativeRep.end()); } |