Fixed guards
[distributed.git] / src / libs / net / uuid.h
blob5cbd765169d1044993284e68a627b46ba54abfb5
1 //
2 // Copyright (C) 2008 Francesco Salvestrini
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef LIBS_NET_UUID_H
20 #define LIBS_NET_UUID_H
22 #include "config.h"
24 #include <string>
26 namespace Net {
27 class UUID {
28 public:
29 UUID(void);
30 ~UUID(void);
31 UUID(const std::string & u);
33 void clear(void);
35 // Operators
36 operator std::string(void);
37 bool operator ==(const UUID & rhs);
38 UUID & operator =(const UUID & rhs);
39 friend std::ostream & operator <<(std::ostream & stream,
40 UUID obj);
41 friend std::istream & operator >>(std::istream & stream,
42 UUID & obj);
44 protected:
46 private:
47 struct uuid {
48 uint32_t time_low;
49 uint16_t time_mid;
50 uint16_t time_high_and_version;
51 uint16_t clock_seq;
52 uint8_t node[6];
53 } uuid_;
55 bool grab_4hex(const std::string & u,
56 std::string::size_type s,
57 std::string::size_type e,
58 uint16_t & v);
59 bool grab_8hex(const std::string & u,
60 std::string::size_type s,
61 std::string::size_type e,
62 uint32_t & v);
63 bool grab_12hex(const std::string & u,
64 std::string::size_type s,
65 std::string::size_type e,
66 uint8_t * v);
70 #endif // LIBS_NET_UUID_H