Skip to content

Commit

Permalink
SERVER-6400 rename *Expression* to *MatchExpression* to avoid conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Apr 29, 2013
1 parent 1bba087 commit dab9c1a
Show file tree
Hide file tree
Showing 21 changed files with 996 additions and 996 deletions.
4 changes: 2 additions & 2 deletions src/mongo/db/matcher/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@

namespace mongo {

string Expression::toString() const {
string MatchExpression::toString() const {
StringBuilder buf;
debugString( buf, 0 );
return buf.str();
}

void Expression::_debugAddSpace( StringBuilder& debug, int level ) const {
void MatchExpression::_debugAddSpace( StringBuilder& debug, int level ) const {
for ( int i = 0; i < level; i++ )
debug << " ";
}
Expand Down
10 changes: 5 additions & 5 deletions src/mongo/db/matcher/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

namespace mongo {

class TreeExpression;
class TreeMatchExpression;

class Expression {
MONGO_DISALLOW_COPYING( Expression );
class MatchExpression {
MONGO_DISALLOW_COPYING( MatchExpression );

public:
Expression(){}
virtual ~Expression(){}
MatchExpression(){}
virtual ~MatchExpression(){}

/**
* determins if the doc matches the expression
Expand Down
42 changes: 21 additions & 21 deletions src/mongo/db/matcher/expression_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace mongo {

// ----------

Status AllExpression::init( const StringData& path ) {
Status AllMatchExpression::init( const StringData& path ) {
_path = path;
return Status::OK();
}

bool AllExpression::matches( const BSONObj& doc, MatchDetails* details ) const {
bool AllMatchExpression::matches( const BSONObj& doc, MatchDetails* details ) const {
FieldRef path;
path.parse(_path);

Expand Down Expand Up @@ -61,7 +61,7 @@ namespace mongo {
return _match( all );
}

bool AllExpression::matchesSingleElement( const BSONElement& e ) const {
bool AllMatchExpression::matchesSingleElement( const BSONElement& e ) const {
if ( _arrayEntries.size() == 0 )
return false;

Expand All @@ -84,7 +84,7 @@ namespace mongo {
return _match( all );
}

bool AllExpression::_match( const BSONElementSet& all ) const {
bool AllMatchExpression::_match( const BSONElementSet& all ) const {

if ( all.size() == 0 )
return _arrayEntries.singleNull();
Expand Down Expand Up @@ -114,14 +114,14 @@ namespace mongo {
return true;
}

void AllExpression::debugString( StringBuilder& debug, int level ) const {
void AllMatchExpression::debugString( StringBuilder& debug, int level ) const {
_debugAddSpace( debug, level );
debug << _path << " $all TODO\n";
}

// -------

bool ArrayMatchingExpression::matches( const BSONObj& doc, MatchDetails* details ) const {
bool ArrayMatchingMatchExpression::matches( const BSONObj& doc, MatchDetails* details ) const {

FieldRef path;
path.parse(_path);
Expand Down Expand Up @@ -163,7 +163,7 @@ namespace mongo {
return false;
}

bool ArrayMatchingExpression::matchesSingleElement( const BSONElement& e ) const {
bool ArrayMatchingMatchExpression::matchesSingleElement( const BSONElement& e ) const {
if ( e.type() != Array )
return false;
return matchesArray( e.Obj(), NULL );
Expand All @@ -172,15 +172,15 @@ namespace mongo {

// -------

Status ElemMatchObjectExpression::init( const StringData& path, const Expression* sub ) {
Status ElemMatchObjectMatchExpression::init( const StringData& path, const MatchExpression* sub ) {
_path = path;
_sub.reset( sub );
return Status::OK();
}



bool ElemMatchObjectExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
bool ElemMatchObjectMatchExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
BSONObjIterator i( anArray );
while ( i.more() ) {
BSONElement inner = i.next();
Expand All @@ -196,7 +196,7 @@ namespace mongo {
return false;
}

void ElemMatchObjectExpression::debugString( StringBuilder& debug, int level ) const {
void ElemMatchObjectMatchExpression::debugString( StringBuilder& debug, int level ) const {
_debugAddSpace( debug, level );
debug << _path << " $elemMatch\n";
_sub->debugString( debug, level + 1 );
Expand All @@ -205,30 +205,30 @@ namespace mongo {

// -------

ElemMatchValueExpression::~ElemMatchValueExpression() {
ElemMatchValueMatchExpression::~ElemMatchValueMatchExpression() {
for ( unsigned i = 0; i < _subs.size(); i++ )
delete _subs[i];
_subs.clear();
}

Status ElemMatchValueExpression::init( const StringData& path, const Expression* sub ) {
Status ElemMatchValueMatchExpression::init( const StringData& path, const MatchExpression* sub ) {
init( path );
add( sub );
return Status::OK();
}

Status ElemMatchValueExpression::init( const StringData& path ) {
Status ElemMatchValueMatchExpression::init( const StringData& path ) {
_path = path;
return Status::OK();
}


void ElemMatchValueExpression::add( const Expression* sub ) {
void ElemMatchValueMatchExpression::add( const MatchExpression* sub ) {
verify( sub );
_subs.push_back( sub );
}

bool ElemMatchValueExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
bool ElemMatchValueMatchExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
BSONObjIterator i( anArray );
while ( i.more() ) {
BSONElement inner = i.next();
Expand All @@ -243,15 +243,15 @@ namespace mongo {
return false;
}

bool ElemMatchValueExpression::_arrayElementMatchesAll( const BSONElement& e ) const {
bool ElemMatchValueMatchExpression::_arrayElementMatchesAll( const BSONElement& e ) const {
for ( unsigned i = 0; i < _subs.size(); i++ ) {
if ( !_subs[i]->matchesSingleElement( e ) )
return false;
}
return true;
}

void ElemMatchValueExpression::debugString( StringBuilder& debug, int level ) const {
void ElemMatchValueMatchExpression::debugString( StringBuilder& debug, int level ) const {
_debugAddSpace( debug, level );
debug << _path << " $elemMatch\n";
for ( unsigned i = 0; i < _subs.size(); i++ ) {
Expand All @@ -273,7 +273,7 @@ namespace mongo {
return Status::OK();
}

void AllElemMatchOp::add( const ArrayMatchingExpression* expr ) {
void AllElemMatchOp::add( const ArrayMatchingMatchExpression* expr ) {
verify( expr );
_list.push_back( expr );
}
Expand Down Expand Up @@ -322,19 +322,19 @@ namespace mongo {

// ---------

Status SizeExpression::init( const StringData& path, int size ) {
Status SizeMatchExpression::init( const StringData& path, int size ) {
_path = path;
_size = size;
return Status::OK();
}

bool SizeExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
bool SizeMatchExpression::matchesArray( const BSONObj& anArray, MatchDetails* details ) const {
if ( _size < 0 )
return false;
return anArray.nFields() == _size;
}

void SizeExpression::debugString( StringBuilder& debug, int level ) const {
void SizeMatchExpression::debugString( StringBuilder& debug, int level ) const {
_debugAddSpace( debug, level );
debug << _path << " $size : " << _size << "\n";
}
Expand Down
34 changes: 17 additions & 17 deletions src/mongo/db/matcher/expression_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace mongo {
/**
* this SHOULD extend from ArrayMatchingExpression
* this SHOULD extend from ArrayMatchingMatchExpression
* the only reason it can't is
> db.foo.insert( { x : 5 } )
Expand All @@ -40,7 +40,7 @@ namespace mongo {
* the { x : 5} doc should NOT match
*
*/
class AllExpression : public Expression {
class AllMatchExpression : public MatchExpression {
public:
Status init( const StringData& path );
ArrayFilterEntries* getArrayFilterEntries() { return &_arrayEntries; }
Expand All @@ -58,9 +58,9 @@ namespace mongo {
};


class ArrayMatchingExpression : public Expression {
class ArrayMatchingMatchExpression : public MatchExpression {
public:
virtual ~ArrayMatchingExpression(){}
virtual ~ArrayMatchingMatchExpression(){}

virtual bool matches( const BSONObj& doc, MatchDetails* details ) const;

Expand All @@ -76,44 +76,44 @@ namespace mongo {
};


class ElemMatchObjectExpression : public ArrayMatchingExpression {
class ElemMatchObjectMatchExpression : public ArrayMatchingMatchExpression {
public:
Status init( const StringData& path, const Expression* sub );
Status init( const StringData& path, const MatchExpression* sub );

bool matchesArray( const BSONObj& anArray, MatchDetails* details ) const;

virtual void debugString( StringBuilder& debug, int level ) const;
private:
boost::scoped_ptr<const Expression> _sub;
boost::scoped_ptr<const MatchExpression> _sub;
};

class ElemMatchValueExpression : public ArrayMatchingExpression {
class ElemMatchValueMatchExpression : public ArrayMatchingMatchExpression {
public:
virtual ~ElemMatchValueExpression();
virtual ~ElemMatchValueMatchExpression();

Status init( const StringData& path );
Status init( const StringData& path, const Expression* sub );
void add( const Expression* sub );
Status init( const StringData& path, const MatchExpression* sub );
void add( const MatchExpression* sub );

bool matchesArray( const BSONObj& anArray, MatchDetails* details ) const;

virtual void debugString( StringBuilder& debug, int level ) const;
private:
bool _arrayElementMatchesAll( const BSONElement& e ) const;

std::vector< const Expression* > _subs;
std::vector< const MatchExpression* > _subs;
};


/**
* i'm suprised this isn't a regular AllExpression
* i'm suprised this isn't a regular AllMatchExpression
*/
class AllElemMatchOp : public Expression {
class AllElemMatchOp : public MatchExpression {
public:
virtual ~AllElemMatchOp();

Status init( const StringData& path );
void add( const ArrayMatchingExpression* expr );
void add( const ArrayMatchingMatchExpression* expr );

virtual bool matches( const BSONObj& doc, MatchDetails* details ) const;

Expand All @@ -127,10 +127,10 @@ namespace mongo {
bool _allMatch( const BSONObj& anArray ) const;

StringData _path;
std::vector< const ArrayMatchingExpression* > _list;
std::vector< const ArrayMatchingMatchExpression* > _list;
};

class SizeExpression : public ArrayMatchingExpression {
class SizeMatchExpression : public ArrayMatchingMatchExpression {
public:
Status init( const StringData& path, int size );

Expand Down
Loading

0 comments on commit dab9c1a

Please sign in to comment.