diff options
author | dwight <dwight@Dwights-MacBook-2.local> | 2009-01-10 18:29:09 -0500 |
---|---|---|
committer | dwight <dwight@Dwights-MacBook-2.local> | 2009-01-10 18:29:09 -0500 |
commit | aeef0a9d3d333409a3de6433fb3e298bab41561a (patch) | |
tree | 107844f9365eea0f130f1c49afffe71615fd4233 /db/jsobj.h | |
parent | 8428e6cbda95390bc28717b3aafaee3803f80b60 (diff) | |
parent | 6184c2086bf28d850d323ff4cd06b9fbc7c25c2f (diff) | |
download | mongo-aeef0a9d3d333409a3de6433fb3e298bab41561a.tar.gz |
Merge branch 'master' of ssh://git.10gen.com/data/gitroot/p
Conflicts:
client/dbclient.cpp
client/dbclient.h
Diffstat (limited to 'db/jsobj.h')
-rw-r--r-- | db/jsobj.h | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/db/jsobj.h b/db/jsobj.h index f78cf43bbb7..a9796872097 100644 --- a/db/jsobj.h +++ b/db/jsobj.h @@ -45,7 +45,6 @@ enum BSONType {MinKey=-1, EOO=0, NumberDouble=1, String=2, Object=3, Array=4, Bi NumberInt = 16, JSTypeMax=16, MaxKey=127 - }; /* subtypes of BinData. @@ -71,9 +70,9 @@ public: stringstream s; s << hex; s.fill( '0' ); - s.width( 8 ); + s.width( 16 ); s << a; - s.width( 4 ); + s.width( 8 ); s << b; s << dec; return s.str(); @@ -325,12 +324,6 @@ public: b.append((void *) objdata(), objsize()); } - /* switch the buffer's ownership to us. */ - void iWillFree() { - assert( !details->owned() ); - details->refCount = 1; - } - // Readable representation of a 10gen object. string toString() const; @@ -362,6 +355,10 @@ public: }; BSONElement getField(const char *name) const; /* return has eoo() true if no match */ + bool hasField( const char * name )const { + return ! getField( name ).eoo(); + } + // returns "" if DNE or wrong type const char * getStringField(const char *name); @@ -522,19 +519,21 @@ public: b.append((void *) e.value(), e.valuesize()); } - /* add object as a member with type Array. Thus arr object should have "0", "1", ... - style fields in it. - */ - void appendArray(const char *fieldName, const BSONObj &arr ) { - marshalArray(fieldName, arr); - } - /* add a subobject as a member */ void append(const char *fieldName, BSONObj subObj) { b.append((char) Object); b.append(fieldName); b.append((void *) subObj.objdata(), subObj.objsize()); } + + /* add a subobject as a member with type Array. Thus arr object should have "0", "1", ... + style fields in it. + */ + void appendArray(const char *fieldName, BSONObj subObj) { + b.append((char) Array); + b.append(fieldName); + b.append((void *) subObj.objdata(), subObj.objsize()); + } void appendBool(const char *fieldName, int val) { b.append((char) Bool); @@ -664,6 +663,12 @@ public: b.decouple(); // post done() call version. be sure jsobj frees... } + static string numStr( int i ) { + stringstream o; + o << i; + return o.str(); + } + private: // Append the provided arr object as an array. void marshalArray( const char *fieldName, const BSONObj &arr ) { @@ -672,12 +677,6 @@ private: b.append( (void *) arr.objdata(), arr.objsize() ); } - string numStr( int i ) const { - stringstream o; - o << i; - return o.str(); - } - char* _done() { b.append((char) EOO); char *data = b.buf(); |