diff options
| author | Alan Conway <aconway@apache.org> | 2007-07-04 05:26:26 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-07-04 05:26:26 +0000 |
| commit | d4be469092c558ca9031d82b963b8b845fa1e1bd (patch) | |
| tree | 745ccfec0f180932ab2f3a9abe31a708a49c020c /cpp/src/qpid/framing/Uuid.cpp | |
| parent | 90e275cc082f3ec71c4b879c2ea4d037d4128278 (diff) | |
| download | qpid-python-d4be469092c558ca9031d82b963b8b845fa1e1bd.tar.gz | |
Encode/decode for UUIDs.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@553083 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/Uuid.cpp')
| -rw-r--r-- | cpp/src/qpid/framing/Uuid.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/cpp/src/qpid/framing/Uuid.cpp b/cpp/src/qpid/framing/Uuid.cpp index 47010ba515..b1523f0d61 100644 --- a/cpp/src/qpid/framing/Uuid.cpp +++ b/cpp/src/qpid/framing/Uuid.cpp @@ -17,7 +17,11 @@ */ #include "Uuid.h" -#include "uuid/uuid.h" + +#include "qpid/QpidError.h" +#include "qpid/framing/Buffer.h" + +#include <uuid/uuid.h> namespace qpid { namespace framing { @@ -30,6 +34,16 @@ Uuid::Uuid(uint8_t* uu) { uuid_copy(c_array(),uu); } static const size_t UNPARSED_SIZE=36; +void Uuid::encode(Buffer& buf) { + buf.putRawData(data(), size()); +} + +void Uuid::decode(Buffer& buf) { + if (buf.available() < size()) + THROW_QPID_ERROR(FRAMING_ERROR, "Not enough data for UUID."); + buf.getRawData(c_array(), size()); +} + ostream& operator<<(ostream& out, const Uuid& uuid) { char unparsed[UNPARSED_SIZE + 1]; uuid_unparse(uuid.data(), unparsed); |
