diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/bson/bsonmisc.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/bson/bsonmisc.cpp')
-rw-r--r-- | src/mongo/bson/bsonmisc.cpp | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/src/mongo/bson/bsonmisc.cpp b/src/mongo/bson/bsonmisc.cpp index 9e7be1b2353..b106121b590 100644 --- a/src/mongo/bson/bsonmisc.cpp +++ b/src/mongo/bson/bsonmisc.cpp @@ -31,87 +31,87 @@ namespace mongo { - int getGtLtOp(const BSONElement& e) { - if ( e.type() != Object ) - return BSONObj::Equality; +int getGtLtOp(const BSONElement& e) { + if (e.type() != Object) + return BSONObj::Equality; - BSONElement fe = e.embeddedObject().firstElement(); - return fe.getGtLtOp(); - } + BSONElement fe = e.embeddedObject().firstElement(); + return fe.getGtLtOp(); +} - bool fieldsMatch(const BSONObj& lhs, const BSONObj& rhs) { - BSONObjIterator l(lhs); - BSONObjIterator r(rhs); +bool fieldsMatch(const BSONObj& lhs, const BSONObj& rhs) { + BSONObjIterator l(lhs); + BSONObjIterator r(rhs); - while (l.more() && r.more()){ - if (strcmp(l.next().fieldName(), r.next().fieldName())) { - return false; - } + while (l.more() && r.more()) { + if (strcmp(l.next().fieldName(), r.next().fieldName())) { + return false; } - - return !(l.more() || r.more()); // false if lhs and rhs have diff nFields() - } - - Labeler::Label GT( "$gt" ); - Labeler::Label GTE( "$gte" ); - Labeler::Label LT( "$lt" ); - Labeler::Label LTE( "$lte" ); - Labeler::Label NE( "$ne" ); - Labeler::Label NIN( "$nin" ); - Labeler::Label BSIZE( "$size" ); - - GENOIDLabeler GENOID; - DateNowLabeler DATENOW; - NullLabeler BSONNULL; - UndefinedLabeler BSONUndefined; - - MinKeyLabeler MINKEY; - MaxKeyLabeler MAXKEY; - - BSONObjBuilderValueStream::BSONObjBuilderValueStream( BSONObjBuilder * builder ) { - _builder = builder; - } - - BSONObjBuilder& BSONObjBuilderValueStream::operator<<( const BSONElement& e ) { - _builder->appendAs( e , _fieldName ); - _fieldName = StringData(); - return *_builder; } - BufBuilder& BSONObjBuilderValueStream::subobjStart() { - StringData tmp = _fieldName; - _fieldName = StringData(); - return _builder->subobjStart(tmp); + return !(l.more() || r.more()); // false if lhs and rhs have diff nFields() +} + +Labeler::Label GT("$gt"); +Labeler::Label GTE("$gte"); +Labeler::Label LT("$lt"); +Labeler::Label LTE("$lte"); +Labeler::Label NE("$ne"); +Labeler::Label NIN("$nin"); +Labeler::Label BSIZE("$size"); + +GENOIDLabeler GENOID; +DateNowLabeler DATENOW; +NullLabeler BSONNULL; +UndefinedLabeler BSONUndefined; + +MinKeyLabeler MINKEY; +MaxKeyLabeler MAXKEY; + +BSONObjBuilderValueStream::BSONObjBuilderValueStream(BSONObjBuilder* builder) { + _builder = builder; +} + +BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const BSONElement& e) { + _builder->appendAs(e, _fieldName); + _fieldName = StringData(); + return *_builder; +} + +BufBuilder& BSONObjBuilderValueStream::subobjStart() { + StringData tmp = _fieldName; + _fieldName = StringData(); + return _builder->subobjStart(tmp); +} + +BufBuilder& BSONObjBuilderValueStream::subarrayStart() { + StringData tmp = _fieldName; + _fieldName = StringData(); + return _builder->subarrayStart(tmp); +} + +Labeler BSONObjBuilderValueStream::operator<<(const Labeler::Label& l) { + return Labeler(l, this); +} + +void BSONObjBuilderValueStream::endField(StringData nextFieldName) { + if (haveSubobj()) { + verify(_fieldName.rawData()); + _builder->append(_fieldName, subobj()->done()); + _subobj.reset(); } + _fieldName = nextFieldName; +} - BufBuilder& BSONObjBuilderValueStream::subarrayStart() { - StringData tmp = _fieldName; - _fieldName = StringData(); - return _builder->subarrayStart(tmp); - } - - Labeler BSONObjBuilderValueStream::operator<<( const Labeler::Label &l ) { - return Labeler( l, this ); - } +BSONObjBuilder* BSONObjBuilderValueStream::subobj() { + if (!haveSubobj()) + _subobj.reset(new BSONObjBuilder()); + return _subobj.get(); +} - void BSONObjBuilderValueStream::endField( StringData nextFieldName ) { - if ( haveSubobj() ) { - verify( _fieldName.rawData() ); - _builder->append( _fieldName, subobj()->done() ); - _subobj.reset(); - } - _fieldName = nextFieldName; - } - - BSONObjBuilder *BSONObjBuilderValueStream::subobj() { - if ( !haveSubobj() ) - _subobj.reset( new BSONObjBuilder() ); - return _subobj.get(); - } - - BSONObjBuilder& Labeler::operator<<( const BSONElement& e ) { - s_->subobj()->appendAs( e, l_.l_ ); - return *s_->_builder; - } +BSONObjBuilder& Labeler::operator<<(const BSONElement& e) { + s_->subobj()->appendAs(e, l_.l_); + return *s_->_builder; +} -} // namespace mongo +} // namespace mongo |