summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_parser.h
diff options
context:
space:
mode:
authorNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-06-20 12:17:52 -0400
committerNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-06-27 12:10:12 -0400
commita92eb118cc8500a9c4286e8ef28cb26ea3f4e238 (patch)
treec922f2004397ac4b7441685610baf68a7eb46da0 /src/mongo/db/matcher/expression_parser.h
parent18bc61d22123da5897d275eb92576522a1bab4de (diff)
downloadmongo-a92eb118cc8500a9c4286e8ef28cb26ea3f4e238.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.h25
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;