summaryrefslogtreecommitdiff
path: root/bson
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-09-29 10:09:08 -0700
committerAaron <aaron@10gen.com>2010-09-29 11:14:53 -0700
commit2a4c95a3f44b12968f819e77799c8b0af9434625 (patch)
tree999eb5a253ae56a11af67e65dc57788afab87a36 /bson
parent1549d5295ab6a1d96b2f692c2f11006f16e82f89 (diff)
downloadmongo-2a4c95a3f44b12968f819e77799c8b0af9434625.tar.gz
SERVER-394 bsonobjbuilder allow returning newly appended element, in one case
Diffstat (limited to 'bson')
-rw-r--r--bson/bsonobjbuilder.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/bson/bsonobjbuilder.h b/bson/bsonobjbuilder.h
index c52f56e9c59..548af86fb12 100644
--- a/bson/bsonobjbuilder.h
+++ b/bson/bsonobjbuilder.h
@@ -119,6 +119,14 @@ namespace mongo {
return *this;
}
+ /** append an element but with a new name, and make resulting element available */
+ BSONObjBuilder& appendAs(const BSONElement& e, const StringData& fieldName, BSONElement &newElt) {
+ int len = _b.len();
+ BSONObjBuilder& ret = appendAs( e, fieldName );
+ newElt = BSONElement( _b.grow( 0 ) - ( _b.len() - len ) );
+ return ret;
+ }
+
/** add a subobject as a member */
BSONObjBuilder& append(const StringData& fieldName, BSONObj subObj) {
_b.appendNum((char) Object);
@@ -692,6 +700,10 @@ namespace mongo {
fill( name );
append( e );
}
+
+ void appendAs( const BSONElement &e, const char *name, BSONElement &newElt ) {
+ massert( 13493, "not implemented", false );
+ }
private:
void fill( const StringData& name ) {