summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_where_noop.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/matcher/expression_where_noop.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/matcher/expression_where_noop.cpp')
-rw-r--r--src/mongo/db/matcher/expression_where_noop.cpp150
1 files changed, 74 insertions, 76 deletions
diff --git a/src/mongo/db/matcher/expression_where_noop.cpp b/src/mongo/db/matcher/expression_where_noop.cpp
index d7f5a3c74e1..d505542e818 100644
--- a/src/mongo/db/matcher/expression_where_noop.cpp
+++ b/src/mongo/db/matcher/expression_where_noop.cpp
@@ -35,104 +35,102 @@
namespace mongo {
- using std::unique_ptr;
- using std::string;
-
- /**
- * Bogus no-op $where match expression to parse $where in mongos,
- * since mongos doesn't have script engine to compile JS functions.
- *
- * Linked into mongos, instead of the real WhereMatchExpression.
- */
- class WhereNoOpMatchExpression : public MatchExpression {
- public:
- WhereNoOpMatchExpression() : MatchExpression( WHERE ){ }
- virtual ~WhereNoOpMatchExpression(){}
-
- Status init( StringData theCode );
-
- virtual bool matches( const MatchableDocument* doc, MatchDetails* details = 0 ) const {
- return false;
- }
-
- virtual bool matchesSingleElement( const BSONElement& e ) const {
- return false;
- }
+using std::unique_ptr;
+using std::string;
- virtual MatchExpression* shallowClone() const {
- WhereNoOpMatchExpression* e = new WhereNoOpMatchExpression();
- e->init(_code);
- if ( getTag() ) {
- e->setTag(getTag()->clone());
- }
- return e;
- }
+/**
+ * Bogus no-op $where match expression to parse $where in mongos,
+ * since mongos doesn't have script engine to compile JS functions.
+ *
+ * Linked into mongos, instead of the real WhereMatchExpression.
+ */
+class WhereNoOpMatchExpression : public MatchExpression {
+public:
+ WhereNoOpMatchExpression() : MatchExpression(WHERE) {}
+ virtual ~WhereNoOpMatchExpression() {}
- virtual void debugString( StringBuilder& debug, int level = 0 ) const;
+ Status init(StringData theCode);
- virtual void toBSON(BSONObjBuilder* out) const;
+ virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const {
+ return false;
+ }
- virtual bool equivalent( const MatchExpression* other ) const ;
+ virtual bool matchesSingleElement(const BSONElement& e) const {
+ return false;
+ }
- virtual void resetTag() { setTag(NULL); }
+ virtual MatchExpression* shallowClone() const {
+ WhereNoOpMatchExpression* e = new WhereNoOpMatchExpression();
+ e->init(_code);
+ if (getTag()) {
+ e->setTag(getTag()->clone());
+ }
+ return e;
+ }
- private:
- string _code;
- };
+ virtual void debugString(StringBuilder& debug, int level = 0) const;
- Status WhereNoOpMatchExpression::init(StringData theCode ) {
- if ( theCode.size() == 0 )
- return Status( ErrorCodes::BadValue, "code for $where cannot be empty" );
+ virtual void toBSON(BSONObjBuilder* out) const;
- _code = theCode.toString();
+ virtual bool equivalent(const MatchExpression* other) const;
- return Status::OK();
+ virtual void resetTag() {
+ setTag(NULL);
}
- void WhereNoOpMatchExpression::debugString( StringBuilder& debug, int level ) const {
- _debugAddSpace( debug, level );
- debug << "$where (only in mongos)\n";
+private:
+ string _code;
+};
- _debugAddSpace( debug, level + 1 );
- debug << "code: " << _code << "\n";
- }
+Status WhereNoOpMatchExpression::init(StringData theCode) {
+ if (theCode.size() == 0)
+ return Status(ErrorCodes::BadValue, "code for $where cannot be empty");
- void WhereNoOpMatchExpression::toBSON(BSONObjBuilder* out) const {
- out->append("$where", _code);
- }
+ _code = theCode.toString();
- bool WhereNoOpMatchExpression::equivalent( const MatchExpression* other ) const {
- if ( matchType() != other->matchType() )
- return false;
- const WhereNoOpMatchExpression* noopOther = static_cast<const WhereNoOpMatchExpression*>(other);
- return _code == noopOther->_code;
- }
+ return Status::OK();
+}
+void WhereNoOpMatchExpression::debugString(StringBuilder& debug, int level) const {
+ _debugAddSpace(debug, level);
+ debug << "$where (only in mongos)\n";
- // -----------------
+ _debugAddSpace(debug, level + 1);
+ debug << "code: " << _code << "\n";
+}
- WhereCallbackNoop::WhereCallbackNoop() {
+void WhereNoOpMatchExpression::toBSON(BSONObjBuilder* out) const {
+ out->append("$where", _code);
+}
- }
+bool WhereNoOpMatchExpression::equivalent(const MatchExpression* other) const {
+ if (matchType() != other->matchType())
+ return false;
+ const WhereNoOpMatchExpression* noopOther = static_cast<const WhereNoOpMatchExpression*>(other);
+ return _code == noopOther->_code;
+}
- StatusWithMatchExpression WhereCallbackNoop::parseWhere(const BSONElement& where) const {
+// -----------------
- unique_ptr<WhereNoOpMatchExpression> exp( new WhereNoOpMatchExpression() );
- if ( where.type() == String || where.type() == Code ) {
- Status s = exp->init( where.valuestr() );
- if ( !s.isOK() )
- return StatusWithMatchExpression( s );
- return StatusWithMatchExpression( exp.release() );
- }
+WhereCallbackNoop::WhereCallbackNoop() {}
- if ( where.type() == CodeWScope ) {
- Status s = exp->init( where.codeWScopeCode() );
- if ( !s.isOK() )
- return StatusWithMatchExpression( s );
- return StatusWithMatchExpression( exp.release() );
- }
+StatusWithMatchExpression WhereCallbackNoop::parseWhere(const BSONElement& where) const {
+ unique_ptr<WhereNoOpMatchExpression> exp(new WhereNoOpMatchExpression());
+ if (where.type() == String || where.type() == Code) {
+ Status s = exp->init(where.valuestr());
+ if (!s.isOK())
+ return StatusWithMatchExpression(s);
+ return StatusWithMatchExpression(exp.release());
+ }
- return StatusWithMatchExpression( ErrorCodes::BadValue, "$where got bad type" );
+ if (where.type() == CodeWScope) {
+ Status s = exp->init(where.codeWScopeCode());
+ if (!s.isOK())
+ return StatusWithMatchExpression(s);
+ return StatusWithMatchExpression(exp.release());
}
+
+ return StatusWithMatchExpression(ErrorCodes::BadValue, "$where got bad type");
+}
}