summaryrefslogtreecommitdiff
path: root/project2/uuid.h
blob: b4d0e7fc89b79fb812f01ccdccbd93d0bb028e30 (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
38
39
40
#ifndef UUID_H
#define UUID_H

#include <iostream>
#include <boost/version.hpp>

#ifdef USINGOSSPUUID
#	include <ossp/uuid++.hh>
#else
#	if BOOST_VERSION < 104200
#		error "Boost UUIDs required v1.42 or above"
#	else
#		include <boost/uuid/uuid.hpp>
#		define USINGBOOSTUUID
#	endif
#endif

class UUID {
	public:
		UUID();
		UUID(const std::string &);

		static UUID generate_random();

		bool operator!=(const UUID & other) const;
		bool is_nil() const;

		void operator=(const std::string &);
		std::string str() const;

	private:
#ifdef USINGBOOSTUUID
		boost::uuids::uuid boost_uuid;
#endif
#ifdef USINGOSSPUUID
		mutable uuid ossp_uuid;
#endif
};

#endif