diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /src/mongo/db/matcher/schema/json_schema_parser.cpp | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'src/mongo/db/matcher/schema/json_schema_parser.cpp')
-rw-r--r-- | src/mongo/db/matcher/schema/json_schema_parser.cpp | 151 |
1 files changed, 73 insertions, 78 deletions
diff --git a/src/mongo/db/matcher/schema/json_schema_parser.cpp b/src/mongo/db/matcher/schema/json_schema_parser.cpp index dd51115e276..0608c2389b4 100644 --- a/src/mongo/db/matcher/schema/json_schema_parser.cpp +++ b/src/mongo/db/matcher/schema/json_schema_parser.cpp @@ -74,7 +74,12 @@ using findBSONTypeAliasFun = std::function<boost::optional<BSONType>(StringData) // Explicitly unsupported JSON Schema keywords. const std::set<StringData> unsupportedKeywords{ - "$ref"_sd, "$schema"_sd, "default"_sd, "definitions"_sd, "format"_sd, "id"_sd, + "$ref"_sd, + "$schema"_sd, + "default"_sd, + "definitions"_sd, + "format"_sd, + "id"_sd, }; constexpr StringData kNamePlaceholder = "i"_sd; @@ -176,9 +181,9 @@ StatusWithMatchExpression parseMaximum(StringData path, bool isExclusiveMaximum) { if (!maximum.isNumber()) { return {Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaMaximumKeyword - << "' must be a number")}; + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaMaximumKeyword + << "' must be a number")}; } if (path.empty()) { @@ -204,9 +209,9 @@ StatusWithMatchExpression parseMinimum(StringData path, bool isExclusiveMinimum) { if (!minimum.isNumber()) { return {Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaMinimumKeyword - << "' must be a number")}; + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaMinimumKeyword + << "' must be a number")}; } if (path.empty()) { @@ -252,9 +257,9 @@ StatusWithMatchExpression parsePattern(StringData path, InternalSchemaTypeExpression* typeExpr) { if (pattern.type() != BSONType::String) { return {Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaPatternKeyword - << "' must be a string")}; + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaPatternKeyword + << "' must be a string")}; } if (path.empty()) { @@ -273,16 +278,16 @@ StatusWithMatchExpression parseMultipleOf(StringData path, InternalSchemaTypeExpression* typeExpr) { if (!multipleOf.isNumber()) { return {Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaMultipleOfKeyword - << "' must be a number")}; + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaMultipleOfKeyword + << "' must be a number")}; } if (multipleOf.numberDecimal().isNegative() || multipleOf.numberDecimal().isZero()) { return {Status(ErrorCodes::FailedToParse, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaMultipleOfKeyword - << "' must have a positive value")}; + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaMultipleOfKeyword + << "' must have a positive value")}; } if (path.empty()) { return {std::make_unique<AlwaysTrueMatchExpression>()}; @@ -407,7 +412,7 @@ StatusWith<StringDataSet> parseRequired(BSONElement requiredElt) { << propertyName.type()}; } - const auto[it, didInsert] = properties.insert(propertyName.valueStringData()); + const auto [it, didInsert] = properties.insert(propertyName.valueStringData()); if (!didInsert) { return {ErrorCodes::FailedToParse, str::stream() << "$jsonSchema keyword '" @@ -460,9 +465,9 @@ StatusWithMatchExpression parseProperties(const boost::intrusive_ptr<ExpressionC bool ignoreUnknownKeywords) { if (propertiesElt.type() != BSONType::Object) { return {Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaPropertiesKeyword - << "' must be an object")}; + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaPropertiesKeyword + << "' must be an object")}; } auto propertiesObj = propertiesElt.embeddedObject(); @@ -471,8 +476,7 @@ StatusWithMatchExpression parseProperties(const boost::intrusive_ptr<ExpressionC if (property.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, str::stream() << "Nested schema for $jsonSchema property '" - << property.fieldNameStringData() - << "' must be an object"}; + << property.fieldNameStringData() << "' must be an object"}; } auto nestedSchemaMatch = _parse(expCtx, @@ -534,11 +538,11 @@ StatusWith<std::vector<PatternSchema>> parsePatternProperties( for (auto&& patternSchema : patternPropertiesElt.embeddedObject()) { if (patternSchema.type() != BSONType::Object) { return {Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaPatternPropertiesKeyword - << "' has property '" - << patternSchema.fieldNameStringData() - << "' which is not an object")}; + str::stream() + << "$jsonSchema keyword '" + << JSONSchemaParser::kSchemaPatternPropertiesKeyword + << "' has property '" << patternSchema.fieldNameStringData() + << "' which is not an object")}; } // Parse the nested schema using a placeholder as the path, since we intend on using the @@ -841,11 +845,11 @@ StatusWith<boost::optional<long long>> parseItems( for (auto subschema : itemsElt.embeddedObject()) { if (subschema.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaItemsKeyword - << "' requires that each element of the array is an " - "object, but found a " - << subschema.type()}; + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaItemsKeyword + << "' requires that each element of the array is an " + "object, but found a " + << subschema.type()}; } // We want to make an ExpressionWithPlaceholder for $_internalSchemaMatchArrayIndex, @@ -896,8 +900,7 @@ StatusWith<boost::optional<long long>> parseItems( } else { return {ErrorCodes::TypeMismatch, str::stream() << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaItemsKeyword - << "' must be an array or an object, not " - << itemsElt.type()}; + << "' must be an array or an object, not " << itemsElt.type()}; } return startIndexForAdditionalItems; @@ -1268,8 +1271,7 @@ Status translateScalarKeywords(StringMap<BSONElement>& keywordMap, return {ErrorCodes::FailedToParse, str::stream() << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaMaximumKeyword << "' must be a present if " - << JSONSchemaParser::kSchemaExclusiveMaximumKeyword - << " is present"}; + << JSONSchemaParser::kSchemaExclusiveMaximumKeyword << " is present"}; } if (auto minimumElt = keywordMap[JSONSchemaParser::kSchemaMinimumKeyword]) { @@ -1295,8 +1297,7 @@ Status translateScalarKeywords(StringMap<BSONElement>& keywordMap, return {ErrorCodes::FailedToParse, str::stream() << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaMinimumKeyword << "' must be a present if " - << JSONSchemaParser::kSchemaExclusiveMinimumKeyword - << " is present"}; + << JSONSchemaParser::kSchemaExclusiveMinimumKeyword << " is present"}; } return Status::OK(); @@ -1316,10 +1317,8 @@ Status translateEncryptionKeywords(StringMap<BSONElement>& keywordMap, if (encryptElt && encryptMetadataElt) { return Status(ErrorCodes::FailedToParse, str::stream() << "Cannot specify both $jsonSchema keywords '" - << JSONSchemaParser::kSchemaEncryptKeyword - << "' and '" - << JSONSchemaParser::kSchemaEncryptMetadataKeyword - << "'"); + << JSONSchemaParser::kSchemaEncryptKeyword << "' and '" + << JSONSchemaParser::kSchemaEncryptMetadataKeyword << "'"); } if (encryptMetadataElt) { @@ -1389,9 +1388,9 @@ Status validateMetadataKeywords(StringMap<BSONElement>& keywordMap) { if (auto titleElem = keywordMap[JSONSchemaParser::kSchemaTitleKeyword]) { if (titleElem.type() != BSONType::String) { return Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaTitleKeyword - << "' must be of type string"); + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaTitleKeyword + << "' must be of type string"); } } return Status::OK(); @@ -1446,16 +1445,16 @@ StatusWithMatchExpression _parse(const boost::intrusive_ptr<ExpressionContext>& << "' is not currently supported"); } else if (!ignoreUnknownKeywords) { return Status(ErrorCodes::FailedToParse, - str::stream() << "Unknown $jsonSchema keyword: " - << elt.fieldNameStringData()); + str::stream() + << "Unknown $jsonSchema keyword: " << elt.fieldNameStringData()); } continue; } if (it->second) { return Status(ErrorCodes::FailedToParse, - str::stream() << "Duplicate $jsonSchema keyword: " - << elt.fieldNameStringData()); + str::stream() + << "Duplicate $jsonSchema keyword: " << elt.fieldNameStringData()); } keywordMap[elt.fieldNameStringData()] = elt; @@ -1472,28 +1471,24 @@ StatusWithMatchExpression _parse(const boost::intrusive_ptr<ExpressionContext>& if (typeElem && bsonTypeElem) { return Status(ErrorCodes::FailedToParse, str::stream() << "Cannot specify both $jsonSchema keywords '" - << JSONSchemaParser::kSchemaTypeKeyword - << "' and '" - << JSONSchemaParser::kSchemaBsonTypeKeyword - << "'"); + << JSONSchemaParser::kSchemaTypeKeyword << "' and '" + << JSONSchemaParser::kSchemaBsonTypeKeyword << "'"); } else if (typeElem && encryptElem) { return Status(ErrorCodes::FailedToParse, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaEncryptKeyword - << "' cannot be used in conjunction with '" - << JSONSchemaParser::kSchemaTypeKeyword - << "', '" - << JSONSchemaParser::kSchemaEncryptKeyword - << "' implies type 'bsonType::BinData'"); + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaEncryptKeyword + << "' cannot be used in conjunction with '" + << JSONSchemaParser::kSchemaTypeKeyword << "', '" + << JSONSchemaParser::kSchemaEncryptKeyword + << "' implies type 'bsonType::BinData'"); } else if (bsonTypeElem && encryptElem) { return Status(ErrorCodes::FailedToParse, - str::stream() << "$jsonSchema keyword '" - << JSONSchemaParser::kSchemaEncryptKeyword - << "' cannot be used in conjunction with '" - << JSONSchemaParser::kSchemaBsonTypeKeyword - << "', '" - << JSONSchemaParser::kSchemaEncryptKeyword - << "' implies type 'bsonType::BinData'"); + str::stream() + << "$jsonSchema keyword '" << JSONSchemaParser::kSchemaEncryptKeyword + << "' cannot be used in conjunction with '" + << JSONSchemaParser::kSchemaBsonTypeKeyword << "', '" + << JSONSchemaParser::kSchemaEncryptKeyword + << "' implies type 'bsonType::BinData'"); } std::unique_ptr<InternalSchemaTypeExpression> typeExpr; @@ -1584,25 +1579,25 @@ StatusWith<MatcherTypeSet> JSONSchemaParser::parseTypeSet( for (auto&& typeArrayEntry : typeElt.embeddedObject()) { if (typeArrayEntry.type() != BSONType::String) { return {Status(ErrorCodes::TypeMismatch, - str::stream() << "$jsonSchema keyword '" - << typeElt.fieldNameStringData() - << "' array elements must be strings")}; + str::stream() + << "$jsonSchema keyword '" << typeElt.fieldNameStringData() + << "' array elements must be strings")}; } if (typeArrayEntry.valueStringData() == JSONSchemaParser::kSchemaTypeInteger) { return {ErrorCodes::FailedToParse, - str::stream() << "$jsonSchema type '" - << JSONSchemaParser::kSchemaTypeInteger - << "' is not currently supported."}; + str::stream() + << "$jsonSchema type '" << JSONSchemaParser::kSchemaTypeInteger + << "' is not currently supported."}; } auto insertionResult = aliases.insert(typeArrayEntry.valueStringData()); if (!insertionResult.second) { - return {Status(ErrorCodes::FailedToParse, - str::stream() << "$jsonSchema keyword '" - << typeElt.fieldNameStringData() - << "' has duplicate value: " - << typeArrayEntry.valueStringData())}; + return { + Status(ErrorCodes::FailedToParse, + str::stream() + << "$jsonSchema keyword '" << typeElt.fieldNameStringData() + << "' has duplicate value: " << typeArrayEntry.valueStringData())}; } } } |