diff options
author | Geert Bosch <geert@mongodb.com> | 2017-03-28 17:30:05 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2017-03-29 11:55:01 -0400 |
commit | c31befb4c2870bc0e615ab09645ace281906cea5 (patch) | |
tree | f34f37e4311db2365b51fab389bd7885c3525479 /src/mongo/util/uuid.cpp | |
parent | f7bed566056ba8cc13f765a1f8eb00c798ffc405 (diff) | |
download | mongo-c31befb4c2870bc0e615ab09645ace281906cea5.tar.gz |
SERVER-28532 Implement UUID::appendToBuilder
Diffstat (limited to 'src/mongo/util/uuid.cpp')
-rw-r--r-- | src/mongo/util/uuid.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/util/uuid.cpp b/src/mongo/util/uuid.cpp index ca9f527a2a5..e47889a6244 100644 --- a/src/mongo/util/uuid.cpp +++ b/src/mongo/util/uuid.cpp @@ -50,8 +50,6 @@ std::regex uuidRegex("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4 } // namespace -const int UUID::kNumBytes = 16; - StatusWith<UUID> UUID::parse(BSONElement from) { try { return UUID{from.uuid()}; @@ -111,9 +109,13 @@ UUID UUID::gen() { return UUID{randomBytes}; } +void UUID::appendToBuilder(BSONObjBuilder* builder, StringData name) const { + builder->appendBinData(name, sizeof(UUIDStorage), BinDataType::newUUID, &_uuid); +} + BSONObj UUID::toBSON() const { BSONObjBuilder builder; - builder.appendBinData("uuid", sizeof(UUIDStorage), BinDataType::newUUID, &_uuid); + appendToBuilder(&builder, "uuid"); return builder.obj(); } |