diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2015-08-07 06:36:44 -0400 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2015-08-12 04:22:28 -0400 |
commit | 86a3e6352eb27fd2e6115299bcec5103a830fe36 (patch) | |
tree | 7f7f42491808e8c487e47a710deb445448d18a58 /src/mongo/bson/util/bson_extract.h | |
parent | 7bb09c0377f5160857617c38ab07955f8f4b03f6 (diff) | |
download | mongo-86a3e6352eb27fd2e6115299bcec5103a830fe36.tar.gz |
SERVER-19554 merge ReplSetMetadata and ReplicationMetadata
Diffstat (limited to 'src/mongo/bson/util/bson_extract.h')
-rw-r--r-- | src/mongo/bson/util/bson_extract.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/bson/util/bson_extract.h b/src/mongo/bson/util/bson_extract.h index fa7e3bbc9ab..c5e34d3e3ba 100644 --- a/src/mongo/bson/util/bson_extract.h +++ b/src/mongo/bson/util/bson_extract.h @@ -33,6 +33,7 @@ #include "mongo/base/status.h" #include "mongo/base/string_data.h" #include "mongo/bson/bsontypes.h" +#include "mongo/db/repl/optime.h" namespace mongo { @@ -94,6 +95,20 @@ Status bsonExtractIntegerField(const BSONObj& object, StringData fieldName, long */ Status bsonExtractStringField(const BSONObj& object, StringData fieldName, std::string* out); + +/** + * Finds an object-typed field named "fieldName" in "object" that represents an OpTime. + * + * The OpTime objects have two fields, a Timestamp ts and numeric term. + * + * Returns Status::OK() and sets *out to the found element's OpTime value on success. Returns + * ErrorCodes::NoSuchKey if there are no matches for "fieldName" or either subobject field is + * missing, and ErrorCodes::TypeMismatch if the type of the matching element is not Object, the ts + * subfield is not Timestamp, or the term subfield is not numeric. For return values other than + * Status::OK(), the resulting value of "*out" is undefined. + */ +Status bsonExtractOpTimeField(const BSONObj& object, StringData fieldName, repl::OpTime* out); + /** * Finds an Timestamp-typed element named "fieldName" in "object" and stores its value in "out". * |