diff options
Diffstat (limited to 'db/jsobj.cpp')
-rw-r--r-- | db/jsobj.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/jsobj.cpp b/db/jsobj.cpp index dcb7744..9644a87 100644 --- a/db/jsobj.cpp +++ b/db/jsobj.cpp @@ -753,6 +753,21 @@ namespace mongo { return n; } + bool BSONObj::couldBeArray() const { + BSONObjIterator i( *this ); + int index = 0; + while( i.moreWithEOO() ){ + BSONElement e = i.next(); + if( e.eoo() ) break; + + // TODO: If actually important, may be able to do int->char* much faster + if( strcmp( e.fieldName(), ((string)( str::stream() << index )).c_str() ) != 0 ) + return false; + index++; + } + return true; + } + BSONObj BSONObj::clientReadable() const { BSONObjBuilder b; BSONObjIterator i( *this ); |