Browse Source

ref #3293: Filled ExistsMatchExpression.js

Brennan Chesley 12 years ago
parent
commit
57fa7683c7
1 changed files with 24 additions and 82 deletions
  1. 24 82
      lib/pipeline/matcher/ExistsMatchExpression.js

+ 24 - 82
lib/pipeline/matcher/ExistsMatchExpression.js

@@ -1,32 +1,11 @@
-"use strict"
-
+"use strict";
 
+var LeafMatchExpression = require('./LeafMatchExpression');
 
 // Autogenerated by cport.py on 2013-09-17 14:37
-var ExistsMatchExpression = module.exports = function (){
-
-}, klass = ExistsMatchExpression, base =  Object  , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
-
-
-
-
-
-/**
- * 
- * This documentation was automatically generated. Please update when you touch this function.
- * @method ExistsMatchExpression
- * @param
- *
- */
-proto.ExistsMatchExpression = function ExistsMatchExpression( /*  EXISTS  */ ){
-// File: expression_leaf.h lines: 216-215
-//         ExistsMatchExpression() : LeafMatchExpression( EXISTS ){}
-
-
-
-
-}
-
+var ExistsMatchExpression = module.exports = function ExistsMatchExpression(){
+	this._matchType = 'EXISTS';
+}, klass = ExistsMatchExpression, base =  LeafMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
 
 /**
  * 
@@ -35,23 +14,10 @@ proto.ExistsMatchExpression = function ExistsMatchExpression( /*  EXISTS  */ ){
  * @param
  *
  */
-proto.debugString = function debugString( /*  StringBuilder& debug, int level  */ ){
-
+proto.debugString = function debugString( level ) { //  StringBuilder& debug, int level
 // File: expression_leaf.cpp lines: 286-294
-//     void ExistsMatchExpression::debugString( StringBuilder& debug, int level ) const {
-//         _debugAddSpace( debug, level );
-//         debug << path() << " exists";
-//         MatchExpression::TagData* td = getTag();
-//         if (NULL != td) {
-//             debug << " ";
-//             td->debugString(&debug);
-//         }
-//         debug << "\n";
-//     }
-
-
-
-}
+	return this._debugAddSpace( level ) + this.path() + " exists" + (this.getTag() ? " " + this.getTag().debugString() : "") + "\n";	
+};
 
 
 /**
@@ -61,20 +27,13 @@ proto.debugString = function debugString( /*  StringBuilder& debug, int level  *
  * @param
  *
  */
-proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
-
+proto.equivalent = function equivalent( other ) { //  const MatchExpression* other
 // File: expression_leaf.cpp lines: 297-302
-//     bool ExistsMatchExpression::equivalent( const MatchExpression* other ) const {
-//         if ( matchType() != other->matchType() )
-//             return false;
-// 
-//         const ExistsMatchExpression* realOther = static_cast<const ExistsMatchExpression*>( other );
-//         return path() == realOther->path();
-//     }
-
-
-
-}
+	if(this._matchType != other._matchType)	{
+		return false;
+	}
+	return this.path() == other.path();
+};
 
 
 /**
@@ -84,16 +43,10 @@ proto.equivalent = function equivalent( /*  const MatchExpression* other  */ ){
  * @param
  *
  */
-proto.init = function init( /*  const StringData& path  */ ){
-
+proto.init = function init( path ) { //  const StringData& path
 // File: expression_leaf.cpp lines: 278-279
-//     Status ExistsMatchExpression::init( const StringData& path ) {
-//         return initPath( path );
-//     }
-
-
-
-}
+	return this.initPath( path );
+};
 
 
 /**
@@ -103,16 +56,10 @@ proto.init = function init( /*  const StringData& path  */ ){
  * @param
  *
  */
-proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElement& e  */ ){
-
+proto.matchesSingleElement = function matchesSingleElement( e ) { //  const BSONElement& e
 // File: expression_leaf.cpp lines: 282-283
-//     bool ExistsMatchExpression::matchesSingleElement( const BSONElement& e ) const {
-//         return !e.eoo();
-//     }
-
-
-
-}
+	return !(typeof(e) == 'object') || Object.keys(e).length > 0;
+};
 
 
 /**
@@ -124,13 +71,8 @@ proto.matchesSingleElement = function matchesSingleElement( /*  const BSONElemen
  */
 proto.shallowClone = function shallowClone( /*  */ ){
 // File: expression_leaf.h lines: 220-223
-//         virtual LeafMatchExpression* shallowClone() const {
-//             ExistsMatchExpression* e = new ExistsMatchExpression();
-//             e->init( path() );
-//             return e;
-//         }
-
-
-
+	var e = new ExistsMatchExpression();
+	e.init(this.path());
+	return e;
+};
 
-}