Add UUID support

This commit is contained in:
fbraem
2015-12-12 19:13:55 +01:00
parent edc8d2abff
commit a5a46bab95
4 changed files with 81 additions and 17 deletions

View File

@@ -26,6 +26,7 @@
#include "Poco/Buffer.h"
#include "Poco/StreamCopier.h"
#include "Poco/MemoryStream.h"
#include "Poco/UUID.h"
#include <sstream>
@@ -45,6 +46,9 @@ public:
Binary(Poco::Int32 size, unsigned char subtype);
/// Constructor
Binary(const UUID& uuid);
/// Constructor for setting a UUID in a binary element
virtual ~Binary();
/// Destructor
@@ -60,6 +64,10 @@ public:
std::string toString(int indent = 0) const;
/// Returns the binary encoded in Base64
UUID uuid() const;
/// Returns the UUID when the binary subtype is 0x04.
/// Otherwise BadCastException will be thrown
private:
Buffer<unsigned char> _buffer;
unsigned char _subtype;
@@ -109,7 +117,7 @@ inline void BSONReader::read<Binary::Ptr>(Binary::Ptr& to)
unsigned char subtype;
_reader >> subtype;
to->subtype(subtype);
_reader.readRaw((char*) to->buffer().begin(), size);
}