|
|
@@ -1,10 +1,11 @@
|
|
|
-"use strict"
|
|
|
-
|
|
|
+"use strict";
|
|
|
|
|
|
+var MatchExpression = require('./MatchExpression');
|
|
|
+var ElementPath = require('./ElementPath');
|
|
|
|
|
|
// Autogenerated by cport.py on 2013-09-17 14:37
|
|
|
-var TypeMatchExpression = module.exports = function (){
|
|
|
-
|
|
|
+var TypeMatchExpression = module.exports = function TypeMatchExpression(){
|
|
|
+ this._matchType = 'TYPE_OPERATOR';
|
|
|
}, klass = TypeMatchExpression, base = Object , proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
|
|
|
@@ -25,45 +26,6 @@ proto._path = undefined;
|
|
|
|
|
|
proto._type = undefined;
|
|
|
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 338-338
|
|
|
-// ElementPath _elementPath;
|
|
|
-
|
|
|
-proto._elementPath = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 337-337
|
|
|
-// StringData _path;
|
|
|
-
|
|
|
-proto._path = undefined;
|
|
|
-
|
|
|
-
|
|
|
-// File: expression_leaf.h lines: 339-339
|
|
|
-// int _type;
|
|
|
-
|
|
|
-proto._type = undefined;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * This documentation was automatically generated. Please update when you touch this function.
|
|
|
- * @method TypeMatchExpression
|
|
|
- * @param
|
|
|
- *
|
|
|
- */
|
|
|
-proto.TypeMatchExpression = function TypeMatchExpression( /* TYPE_OPERATOR */ ){
|
|
|
-// File: expression_leaf.h lines: 307-306
|
|
|
-// TypeMatchExpression() : MatchExpression( TYPE_OPERATOR ){}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* This documentation was automatically generated. Please update when you touch this function.
|
|
|
@@ -71,23 +33,10 @@ proto.TypeMatchExpression = function TypeMatchExpression( /* TYPE_OPERATOR */
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.debugString = function debugString( /* StringBuilder& debug, int level */ ){
|
|
|
-
|
|
|
+proto.debugString = function debugString( level ) { // StringBuilder& debug, int level
|
|
|
// File: expression_leaf.cpp lines: 335-343
|
|
|
-// void TypeMatchExpression::debugString( StringBuilder& debug, int level ) const {
|
|
|
-// _debugAddSpace( debug, level );
|
|
|
-// debug << _path << " type: " << _type;
|
|
|
-// MatchExpression::TagData* td = getTag();
|
|
|
-// if (NULL != td) {
|
|
|
-// debug << " ";
|
|
|
-// td->debugString(&debug);
|
|
|
-// }
|
|
|
-// debug << "\n";
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._debugAddSapce( level ) + this.path() + " type: " + this._type + (this.getTag() ? this.getTag().debugString() : '' ) + "\n";
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -97,20 +46,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: 347-352
|
|
|
-// bool TypeMatchExpression::equivalent( const MatchExpression* other ) const {
|
|
|
-// if ( matchType() != other->matchType() )
|
|
|
-// return false;
|
|
|
-//
|
|
|
-// const TypeMatchExpression* realOther = static_cast<const TypeMatchExpression*>( other );
|
|
|
-// return _path == realOther->_path && _type == realOther->_type;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ if( other._matchType != 'TYPE_OPERATOR' ) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return this._path == other._path && this._type == other._type;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -122,12 +64,8 @@ proto.equivalent = function equivalent( /* const MatchExpression* other */ ){
|
|
|
*/
|
|
|
proto.getData = function getData( /* */ ){
|
|
|
// File: expression_leaf.h lines: 328-327
|
|
|
-// int getData() const { return _type; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._type;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -137,18 +75,12 @@ proto.getData = function getData( /* */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.init = function init( /* const StringData& path, int type */ ){
|
|
|
-
|
|
|
+proto.init = function init( path,type ) { // const StringData& path, int type
|
|
|
// File: expression_leaf.cpp lines: 308-311
|
|
|
-// Status TypeMatchExpression::init( const StringData& path, int type ) {
|
|
|
-// _path = path;
|
|
|
-// _type = type;
|
|
|
-// return _elementPath.init( _path );
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ this._path = path;
|
|
|
+ this._type = type;
|
|
|
+ return this._elementPath.init( path );
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -158,8 +90,8 @@ proto.init = function init( /* const StringData& path, int type */ ){
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.matches = function matches( /* const MatchableDocument* doc, MatchDetails* details */ ){
|
|
|
-
|
|
|
+/*
|
|
|
+proto.matches = function matches( doc,details ) { // const MatchableDocument* doc, MatchDetails* details
|
|
|
// File: expression_leaf.cpp lines: 318-332
|
|
|
// bool TypeMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
|
|
|
// boost::scoped_ptr<ElementIterator> cursor( doc->getIterator( _elementPath ) );
|
|
|
@@ -177,10 +109,37 @@ proto.matches = function matches( /* const MatchableDocument* doc, MatchDetails
|
|
|
// }
|
|
|
// return false;
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ var tDoc = ElementPath.objAtPath( doc, this._path );
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+};*/
|
|
|
+
|
|
|
+klass.typeNumber = function typeNumber( e ){
|
|
|
+ if(e === undefined)
|
|
|
+ return 6;
|
|
|
+ if(e === null)
|
|
|
+ return 10;
|
|
|
+ if(typeof(e) == 'number')
|
|
|
+ return 1;
|
|
|
+ if(typeof(e) == 'string')
|
|
|
+ return 2;
|
|
|
+ if(typeof(e) == 'boolean')
|
|
|
+ return 8;
|
|
|
+ if(typeof(e) == 'object') {
|
|
|
+ if(e instanceof Array)
|
|
|
+ return 4;
|
|
|
+ if(e instanceof Regexp)
|
|
|
+ return 11;
|
|
|
+ if(e instanceof Date)
|
|
|
+ return 9;
|
|
|
+ if(e.constructor.name == 'MinKey')
|
|
|
+ return -1;
|
|
|
+ if(e.construcor.name == 'MAxKey')
|
|
|
+ return 127;
|
|
|
+ }
|
|
|
+ return 42; // Can't tell
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -190,16 +149,10 @@ proto.matches = function matches( /* const MatchableDocument* doc, MatchDetails
|
|
|
* @param
|
|
|
*
|
|
|
*/
|
|
|
-proto.matchesSingleElement = function matchesSingleElement( /* const BSONElement& e */ ){
|
|
|
-
|
|
|
+proto.matchesSingleElement = function matchesSingleElement( e ) { // const BSONElement& e
|
|
|
// File: expression_leaf.cpp lines: 314-315
|
|
|
-// bool TypeMatchExpression::matchesSingleElement( const BSONElement& e ) const {
|
|
|
-// return e.type() == _type;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return klass.typeNumber( e ) == this._type;
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -211,12 +164,8 @@ proto.matchesSingleElement = function matchesSingleElement( /* const BSONElemen
|
|
|
*/
|
|
|
proto.path = function path( /* */ ){
|
|
|
// File: expression_leaf.h lines: 330-329
|
|
|
-// virtual const StringData path() const { return _path; }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+ return this._path();
|
|
|
+};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -233,8 +182,8 @@ proto.shallowClone = function shallowClone( /* */ ){
|
|
|
// e->init(_path, _type);
|
|
|
// return e;
|
|
|
// }
|
|
|
+ var e = new TypeMatchExpression();
|
|
|
+ e.init( this._path,this._type );
|
|
|
+ return e;
|
|
|
+};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|