summaryrefslogtreecommitdiff
path: root/src/mongo/util/uuid.h
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2017-03-28 17:30:05 -0400
committerGeert Bosch <geert@mongodb.com>2017-03-29 11:55:01 -0400
commitc31befb4c2870bc0e615ab09645ace281906cea5 (patch)
treef34f37e4311db2365b51fab389bd7885c3525479 /src/mongo/util/uuid.h
parentf7bed566056ba8cc13f765a1f8eb00c798ffc405 (diff)
downloadmongo-c31befb4c2870bc0e615ab09645ace281906cea5.tar.gz
SERVER-28532 Implement UUID::appendToBuilder
Diffstat (limited to 'src/mongo/util/uuid.h')
-rw-r--r--src/mongo/util/uuid.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mongo/util/uuid.h b/src/mongo/util/uuid.h
index 5127932dd6a..22adb92ba01 100644
--- a/src/mongo/util/uuid.h
+++ b/src/mongo/util/uuid.h
@@ -44,13 +44,15 @@ namespace mongo {
* a secure random number generator.
*/
class UUID {
+ using UUIDStorage = std::array<unsigned char, 16>;
+
public:
UUID() = delete;
/**
* The number of bytes contained in a UUID.
*/
- static const int kNumBytes;
+ static constexpr int kNumBytes = sizeof(UUIDStorage);
/**
* Generate a new random v4 UUID per RFC 4122.
@@ -75,6 +77,11 @@ public:
static bool isUUIDString(const std::string& s);
/**
+ * Append to builder as BinData(4, "...") element with the given name.
+ */
+ void appendToBuilder(BSONObjBuilder* builder, StringData name) const;
+
+ /**
* Return a BSON object of the form { uuid: BinData(4, "...") }.
*/
BSONObj toBSON() const;
@@ -109,7 +116,6 @@ public:
};
private:
- using UUIDStorage = std::array<unsigned char, 16>;
UUID(const UUIDStorage& uuid) : _uuid(uuid) {}
UUIDStorage _uuid; // UUID in network byte order