summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-07-15 14:19:58 -0400
committerJudah Schvimer <judah@mongodb.com>2017-02-03 13:14:29 -0500
commit95eb8d262ca2d10e9c3db59ba26f44b86b9d7846 (patch)
tree165768873b8dd8bfff24cb9388c8fc88fc15f3a3 /src
parent4307a147acc248ba93bac5a98c004778afc2d540 (diff)
downloadmongo-95eb8d262ca2d10e9c3db59ba26f44b86b9d7846.tar.gz
SERVER-25069 added Timestamp::toBSON()
(cherry picked from commit 31d1c5473e1c5e21646267bd81cb1afbab677672)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/bson/timestamp.cpp8
-rw-r--r--src/mongo/bson/timestamp.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/bson/timestamp.cpp b/src/mongo/bson/timestamp.cpp
index 2abd3a8990a..232aff04128 100644
--- a/src/mongo/bson/timestamp.cpp
+++ b/src/mongo/bson/timestamp.cpp
@@ -34,6 +34,7 @@
#include <limits>
#include <sstream>
+#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/util/time_support.h"
namespace mongo {
@@ -70,4 +71,11 @@ std::string Timestamp::toString() const {
ss << std::hex << secs << ':' << i;
return ss.str();
}
+
+
+BSONObj Timestamp::toBSON() const {
+ BSONObjBuilder bldr;
+ bldr.append("", *this);
+ return bldr.obj();
+}
}
diff --git a/src/mongo/bson/timestamp.h b/src/mongo/bson/timestamp.h
index 1dc04973efb..39c0eb572a8 100644
--- a/src/mongo/bson/timestamp.h
+++ b/src/mongo/bson/timestamp.h
@@ -34,6 +34,8 @@
namespace mongo {
+class BSONObj;
+
/**
* Timestamp: A combination of a count of seconds since the POSIX epoch plus an ordinal value.
*/
@@ -112,6 +114,7 @@ public:
// Append the BSON representation of this Timestamp to the given BufBuilder with the given
// name. This lives here because Timestamp manages its own serialization format.
void append(BufBuilder& builder, const StringData& fieldName) const;
+ BSONObj toBSON() const;
private:
std::tuple<unsigned, unsigned> tie() const {