00001 #ifndef QPID_FRAMING_UUID_H
00002 #define QPID_FRAMING_UUID_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "qpid/sys/uuid.h"
00023
00024 #include <boost/array.hpp>
00025
00026 #include <ostream>
00027 #include <istream>
00028
00029 namespace qpid {
00030 namespace framing {
00031
00032 class Buffer;
00033
00040 struct Uuid : public boost::array<uint8_t, 16> {
00042 Uuid(bool unique=false) { if (unique) generate(); else clear(); }
00043
00045 Uuid(uint8_t* data) { assign(data); }
00046
00048 void assign(uint8_t* data) {
00049 uuid_copy(c_array(), data);
00050 }
00051
00053 void generate() { uuid_generate(c_array()); }
00054
00056 void clear() { uuid_clear(c_array()); }
00057
00059 bool isNull() {
00060 return uuid_is_null(data());
00061 }
00062
00063
00064
00065
00066 void encode(framing::Buffer& buf) const;
00067 void decode(framing::Buffer& buf);
00068 uint32_t encodedSize() const { return size(); }
00069
00071 std::string str();
00072
00073 template <class S> void serialize(S& s) {
00074 s.raw(begin(), size());
00075 }
00076 };
00077
00079 std::ostream& operator<<(std::ostream&, Uuid);
00080
00082 std::istream& operator>>(std::istream&, Uuid&);
00083
00084 }}
00085
00086
00087
00088 #endif