diff options
Diffstat (limited to 'src/mongo/bson/util/bson_extract.h')
-rw-r--r-- | src/mongo/bson/util/bson_extract.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mongo/bson/util/bson_extract.h b/src/mongo/bson/util/bson_extract.h index eb047e8ffb6..dde7be26027 100644 --- a/src/mongo/bson/util/bson_extract.h +++ b/src/mongo/bson/util/bson_extract.h @@ -28,6 +28,7 @@ #pragma once #include <string> +#include <vector> #include "mongo/base/status.h" #include "mongo/base/string_data.h" @@ -37,6 +38,8 @@ namespace mongo { class BSONObj; class BSONElement; + class OID; + class OpTime; /** * Finds an element named "fieldName" in "object". @@ -100,6 +103,30 @@ namespace mongo { std::string* out); /** + * Finds an OpTime-typed element named "fieldName" in "object" and stores its value in "out". + * + * 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", and ErrorCodes::TypeMismatch + * if the type of the matching element is not OpTime. For return values other than + * Status::OK(), the resulting value of "*out" is undefined. + */ + Status bsonExtractOpTimeField(const BSONObj& object, + const StringData& fieldName, + OpTime* out); + + /** + * Finds an OID-typed element named "fieldName" in "object" and stores its value in "out". + * + * Returns Status::OK() and sets *out to the found element's OID value on success. Returns + * ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch + * if the type of the matching element is not OID. For return values other than Status::OK(), + * the resulting value of "*out" is undefined. + */ + Status bsonExtractOIDField(const BSONObj& object, + const StringData& fieldName, + OID* out); + + /** * Finds a bool-like element named "fieldName" in "object". * * If a field named "fieldName" is present, and is either a number or boolean type, stores the |