summaryrefslogtreecommitdiff
path: root/src/mongo/idl
diff options
context:
space:
mode:
authorMohammad Dashti <mdashti@gmail.com>2021-04-10 19:29:51 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-10 20:05:27 +0000
commit2ff1849ef0c5b8d9ea59853e9e205d3e7b4581e1 (patch)
treebc60f74ec87a5d4f1fe51e03f80b64caa3b1ca62 /src/mongo/idl
parentccca10b25ab33f15a90c7c60996a054b9f8cc458 (diff)
downloadmongo-2ff1849ef0c5b8d9ea59853e9e205d3e7b4581e1.tar.gz
SERVER-54925 Move away from using Bson_serialization_type “any”
Diffstat (limited to 'src/mongo/idl')
-rw-r--r--src/mongo/idl/basic_types.h26
-rw-r--r--src/mongo/idl/idl_parser.cpp16
-rw-r--r--src/mongo/idl/idl_parser.h16
3 files changed, 58 insertions, 0 deletions
diff --git a/src/mongo/idl/basic_types.h b/src/mongo/idl/basic_types.h
index c02366d3c5f..62e191a9bf5 100644
--- a/src/mongo/idl/basic_types.h
+++ b/src/mongo/idl/basic_types.h
@@ -47,6 +47,10 @@ namespace mongo {
*/
class OptionalBool {
public:
+ /**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
static OptionalBool parseFromBSON(BSONElement element) {
uassert(ErrorCodes::TypeMismatch,
str::stream() << "Field '" << element.fieldNameStringData()
@@ -76,6 +80,9 @@ public:
/**
* Serialize this object as a field in a document. If _value is empty, omit the field.
+ *
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
*/
void serializeToBSON(StringData fieldName, BSONObjBuilder* builder) const {
if (_value) {
@@ -85,6 +92,9 @@ public:
/**
* Serialize this object as an element of a BSON array. If _value is empty, omit the entry.
+ *
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
*/
void serializeToBSON(BSONArrayBuilder* builder) const {
if (_value) {
@@ -112,6 +122,10 @@ private:
*/
class IDLAnyType {
public:
+ /**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
static IDLAnyType parseFromBSON(const BSONElement& element) {
return IDLAnyType(element);
}
@@ -119,10 +133,18 @@ public:
IDLAnyType() = default;
IDLAnyType(const BSONElement& element) : _element(element) {}
+ /**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
void serializeToBSON(StringData fieldName, BSONObjBuilder* builder) const {
builder->appendAs(_element, fieldName);
}
+ /**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
void serializeToBSON(BSONArrayBuilder* builder) const {
builder->append(_element);
}
@@ -141,6 +163,10 @@ protected:
*/
class IDLAnyTypeOwned : public IDLAnyType {
public:
+ /**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
static IDLAnyTypeOwned parseFromBSON(const BSONElement& element) {
return IDLAnyTypeOwned(element);
}
diff --git a/src/mongo/idl/idl_parser.cpp b/src/mongo/idl/idl_parser.cpp
index 9cad14bffca..de0ffd40852 100644
--- a/src/mongo/idl/idl_parser.cpp
+++ b/src/mongo/idl/idl_parser.cpp
@@ -341,14 +341,26 @@ std::vector<std::vector<std::uint8_t>> transformVector(const std::vector<ConstDa
return output;
}
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
void noOpSerializer(bool, StringData fieldName, BSONObjBuilder* bob) {}
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
void serializeBSONWhenNotEmpty(BSONObj obj, StringData fieldName, BSONObjBuilder* bob) {
if (!obj.isEmpty()) {
bob->append(fieldName, obj);
}
}
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
BSONObj parseOwnedBSON(BSONElement element) {
uassert(ErrorCodes::TypeMismatch,
str::stream() << "Expected field " << element.fieldNameStringData()
@@ -357,6 +369,10 @@ BSONObj parseOwnedBSON(BSONElement element) {
return element.Obj().getOwned();
}
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
bool parseBoolean(BSONElement element) {
uassert(ErrorCodes::TypeMismatch,
str::stream() << "Expected field " << element.fieldNameStringData()
diff --git a/src/mongo/idl/idl_parser.h b/src/mongo/idl/idl_parser.h
index 47096c0d117..316ccd06c7e 100644
--- a/src/mongo/idl/idl_parser.h
+++ b/src/mongo/idl/idl_parser.h
@@ -289,12 +289,28 @@ std::vector<std::string> transformVector(const std::vector<StringData>& input);
std::vector<ConstDataRange> transformVector(const std::vector<std::vector<std::uint8_t>>& input);
std::vector<std::vector<std::uint8_t>> transformVector(const std::vector<ConstDataRange>& input);
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
void noOpSerializer(bool, StringData fieldName, BSONObjBuilder* bob);
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
void serializeBSONWhenNotEmpty(BSONObj obj, StringData fieldName, BSONObjBuilder* bob);
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
BSONObj parseOwnedBSON(BSONElement element);
+/**
+ * IMPORTANT: The method should not be modified, as API version input/output guarantees could
+ * break because of it.
+ */
bool parseBoolean(BSONElement element);
} // namespace mongo