diff options
author | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2017-06-27 15:26:26 -0400 |
---|---|---|
committer | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2017-06-27 17:57:36 -0400 |
commit | 8aa235f5b5eb82223cee67433df4cb78e19d10c5 (patch) | |
tree | 6974625936875735fd0153d0739631cd64512814 /src/mongo/db/matcher/expression_parser.h | |
parent | 9c65741b29f592379be4114f651849e8dde856b6 (diff) | |
download | mongo-8aa235f5b5eb82223cee67433df4cb78e19d10c5.tar.gz |
SERVER-29587: Create $_internalSchemaMinItems and $_internalSchemaMaxItems MatchExpressions
Diffstat (limited to 'src/mongo/db/matcher/expression_parser.h')
-rw-r--r-- | src/mongo/db/matcher/expression_parser.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_parser.h b/src/mongo/db/matcher/expression_parser.h index 8141726251b..c39df98c77e 100644 --- a/src/mongo/db/matcher/expression_parser.h +++ b/src/mongo/db/matcher/expression_parser.h @@ -46,6 +46,11 @@ class OperationContext; class MatchExpressionParser { public: /** + * Constant double representation of 2^63. + */ + static const double kLongLongMaxPlusOneAsDouble; + + /** * caller has to maintain ownership obj * the tree has views (BSONElement) into obj */ @@ -56,6 +61,17 @@ public: return MatchExpressionParser(&extensionsCallback)._parse(obj, collator, topLevelCall); } + /** + * Parses a BSONElement of any numeric type into a positive long long, failing if the value + * is any of the following: + * + * - NaN + * - Too big or small to fit within a 64-bit signed integer. + * - A floating point number which is not integral. + */ + static StatusWith<long long> parseIntegerElementToPositiveLong(const char* name, + const BSONElement& elem); + private: MatchExpressionParser(const ExtensionsCallback* extensionsCallback) : _extensionsCallback(extensionsCallback) {} @@ -169,6 +185,15 @@ private: */ StatusWith<std::vector<uint32_t>> _parseBitPositionsArray(const BSONObj& theArray); + /** + * Parses the given BSONElement into a single integer argument and creates a MatchExpression + * of type 'T' that gets initialized with the resulting integer. + */ + template <class T> + StatusWithMatchExpression _parseInternalSchemaSingleIntegerArgument( + const char* name, const BSONElement& elem) const; + + // The maximum allowed depth of a query tree. Just to guard against stack overflow. static const int kMaximumTreeDepth; |