#include <bsonobjbuilder.h>
Classes | |
struct | ForceExplicitString |
Public Member Functions | |
template<class T > | |
BSONObjBuilder & | append (const StringData &fieldName, const list< T > &vals) |
template<class T > | |
BSONObjBuilder & | append (const StringData &fieldName, const vector< T > &vals) |
BSONObjBuilder & | append (const StringData &fieldName, const string &str) |
BSONObjBuilder & | append (const StringData &fieldName, const char *str) |
BSONObjBuilder & | append (const StringData &fieldName, const char *str, int len) |
BSONObjBuilder & | append (const StringData &fieldName, Date_t dt) |
BSONObjBuilder & | append (const StringData &fieldName, OID oid) |
BSONObjBuilder & | append (const StringData &fieldName, double n) |
BSONObjBuilder & | append (const StringData &fieldName, long long n) |
BSONObjBuilder & | append (const StringData &fieldName, unsigned n) |
BSONObjBuilder & | append (const StringData &fieldName, int n) |
BSONObjBuilder & | append (const StringData &fieldName, bool val) |
BSONObjBuilder & | append (const StringData &fieldName, BSONArray arr) |
BSONObjBuilder & | append (const StringData &fieldName, BSONObj subObj) |
BSONObjBuilder & | append (const BSONElement &e) |
BSONObjBuilder & | appendArray (const StringData &fieldName, const BSONObj &subObj) |
BSONObjBuilder & | appendAs (const BSONElement &e, const StringData &fieldName) |
bool | appendAsNumber (const StringData &fieldName, const string &data) |
BSONObjBuilder & | appendBinData (const StringData &fieldName, int len, BinDataType type, const unsigned char *data) |
BSONObjBuilder & | appendBinData (const StringData &fieldName, int len, BinDataType type, const char *data) |
BSONObjBuilder & | appendBinDataArrayDeprecated (const char *fieldName, const char *data, int len) |
BSONObjBuilder & | appendBool (const StringData &fieldName, int val) |
BSONObjBuilder & | appendCode (const StringData &fieldName, const StringData &code) |
BSONObjBuilder & | appendCodeWScope (const StringData &fieldName, const StringData &code, const BSONObj &scope) |
BSONObjBuilder & | appendDate (const StringData &fieldName, Date_t dt) |
BSONObjBuilder & | appendDBRef (const StringData &fieldName, const StringData &ns, const OID &oid) |
BSONObjBuilder & | appendElements (BSONObj x) |
BSONObjBuilder & | appendElementsUnique (BSONObj x) |
BSONObjBuilder & | appendIntOrLL (const StringData &fieldName, long long n) |
void | appendKeys (const BSONObj &keyPattern, const BSONObj &values) |
void | appendMaxForType (const StringData &fieldName, int type) |
BSONObjBuilder & | appendMaxKey (const StringData &fieldName) |
void | appendMinForType (const StringData &fieldName, int type) |
BSONObjBuilder & | appendMinKey (const StringData &fieldName) |
BSONObjBuilder & | appendNull (const StringData &fieldName) |
BSONObjBuilder & | appendNumber (const StringData &fieldName, long long l) |
BSONObjBuilder & | appendNumber (const StringData &fieldName, size_t n) |
BSONObjBuilder & | appendNumber (const StringData &fieldName, double d) |
BSONObjBuilder & | appendNumber (const StringData &fieldName, int n) |
BSONObjBuilder & | appendObject (const StringData &fieldName, const char *objdata, int size=0) |
BSONObjBuilder & | appendOID (const StringData &fieldName, OID *oid=0, bool generateIfBlank=false) |
BSONObjBuilder & | appendRegex (const StringData &fieldName, const StringData ®ex, const StringData &options="") |
BSONObjBuilder & | appendSymbol (const StringData &fieldName, const StringData &symbol) |
BSONObjBuilder & | appendTimestamp (const StringData &fieldName, unsigned long long time, unsigned int inc) |
BSONObjBuilder & | appendTimestamp (const StringData &fieldName, unsigned long long val) |
BSONObjBuilder & | appendTimestamp (const StringData &fieldName) |
BSONObjBuilder & | appendTimeT (const StringData &fieldName, time_t dt) |
void | appendUndefined (const StringData &fieldName) |
void | appendWhere (const StringData &code, const BSONObj &scope) |
BSONObj | asTempObj () |
BSONObjBuilder (const BSONSizeTracker &tracker) | |
BSONObjBuilder (BufBuilder &baseBuilder) | |
BSONObjBuilder (int initsize=512) | |
void | decouple () |
char * | decouple (int &l) |
BSONObj | done () |
void | doneFast () |
BSONObjBuilder & | genOID () |
bool | hasField (const StringData &name) const |
BSONObjIterator | iterator () const |
int | len () const |
BSONObj | obj () |
template<typename T > | |
BSONObjBuilder & | operator<< (const BSONFieldValue< T > &v) |
template<typename T > | |
BSONObjBuilderValueStream & | operator<< (const BSONField< T > &f) |
Labeler | operator<< (const Labeler::Label &l) |
BSONObjBuilderValueStream & | operator<< (const ForceExplicitString &name) |
BSONObjBuilder & | operator<< (GENOIDLabeler) |
BSONObjBuilderValueStream & | operator<< (const char *name) |
bool | owned () const |
BufBuilder & | subarrayStart (const StringData &fieldName) |
BufBuilder & | subobjStart (const StringData &fieldName) |
~BSONObjBuilder () | |
Static Public Member Functions | |
static string | numStr (int i) |
Private Member Functions | |
char * | _done () |
Private Attributes | |
BufBuilder & | _b |
BufBuilder | _buf |
bool | _doneCalled |
int | _offset |
BSONObjBuilderValueStream | _s |
BSONSizeTracker * | _tracker |
Static Private Attributes | |
static const string | numStrs [100] |
Utility for creating a BSONObj. See also the BSON() and BSON_ARRAY() macros.
Definition at line 81 of file bsonobjbuilder.h.
mongo::BSONObjBuilder::BSONObjBuilder | ( | int | initsize = 512 |
) | [inline] |
initsize | this is just a hint as to the final size of the object |
Definition at line 84 of file bsonobjbuilder.h.
mongo::BSONObjBuilder::BSONObjBuilder | ( | BufBuilder & | baseBuilder | ) | [inline] |
baseBuilder | construct a BSONObjBuilder using an existing BufBuilder |
Definition at line 90 of file bsonobjbuilder.h.
mongo::BSONObjBuilder::BSONObjBuilder | ( | const BSONSizeTracker & | tracker | ) | [inline] |
Definition at line 94 of file bsonobjbuilder.h.
mongo::BSONObjBuilder::~BSONObjBuilder | ( | ) | [inline] |
Definition at line 98 of file bsonobjbuilder.h.
char* mongo::BSONObjBuilder::_done | ( | ) | [inline, private] |
Definition at line 627 of file bsonobjbuilder.h.
BSONObjBuilder & mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
const list< T > & | vals | |||
) | [inline] |
Definition at line 753 of file bsonobjbuilder.h.
BSONObjBuilder & mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
const vector< T > & | vals | |||
) | [inline] |
Append an array of values.
Definition at line 744 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
const string & | str | |||
) | [inline] |
Append a string element
Definition at line 382 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
const char * | str | |||
) | [inline] |
Append a string element
Definition at line 378 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
const char * | str, | |||
int | len | |||
) | [inline] |
Append a string element. len DOES include terminating nul
Definition at line 370 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
Date_t | dt | |||
) | [inline] |
Definition at line 345 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
OID | oid | |||
) | [inline] |
Append a BSON Object ID.
fieldName | Field name, e.g., "_id". |
Definition at line 302 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
double | n | |||
) | [inline] |
Append a double element
Definition at line 265 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
long long | n | |||
) | [inline] |
Append a NumberLong
Definition at line 209 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
unsigned | n | |||
) | [inline] |
Append a 32 bit unsigned element - cast to a signed int.
Definition at line 204 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
int | n | |||
) | [inline] |
Append a 32 bit integer element
Definition at line 196 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
bool | val | |||
) | [inline] |
Append a boolean element
Definition at line 188 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
BSONArray | arr | |||
) | [inline] |
Definition at line 167 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const StringData & | fieldName, | |
BSONObj | subObj | |||
) | [inline] |
add a subobject as a member
Definition at line 127 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::append | ( | const BSONElement & | e | ) | [inline] |
append element to the object we are building
Definition at line 111 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendArray | ( | const StringData & | fieldName, | |
const BSONObj & | subObj | |||
) | [inline] |
add a subobject as a member with type Array. Thus arr object should have "0", "1", ... style fields in it.
Definition at line 161 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendAs | ( | const BSONElement & | e, | |
const StringData & | fieldName | |||
) | [inline] |
append an element but with a new name
Definition at line 118 of file bsonobjbuilder.h.
bool mongo::BSONObjBuilder::appendAsNumber | ( | const StringData & | fieldName, | |
const string & | data | |||
) |
tries to append the data as a number
BSONObjBuilder& mongo::BSONObjBuilder::appendBinData | ( | const StringData & | fieldName, | |
int | len, | |||
BinDataType | type, | |||
const unsigned char * | data | |||
) | [inline] |
Definition at line 464 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendBinData | ( | const StringData & | fieldName, | |
int | len, | |||
BinDataType | type, | |||
const char * | data | |||
) | [inline] |
Append a binary data element
fieldName | name of the field | |
len | length of the binary data in bytes | |
subtype | subtype information for the data. |
data | the byte array |
Definition at line 456 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendBinDataArrayDeprecated | ( | const char * | fieldName, | |
const char * | data, | |||
int | len | |||
) | [inline] |
Subtype 2 is deprecated. Append a BSON bindata bytearray element.
data | a byte array | |
len | the length of data |
Definition at line 474 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendBool | ( | const StringData & | fieldName, | |
int | val | |||
) | [inline] |
Append a boolean element
Definition at line 180 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendCode | ( | const StringData & | fieldName, | |
const StringData & | code | |||
) | [inline] |
Definition at line 361 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendCodeWScope | ( | const StringData & | fieldName, | |
const StringData & | code, | |||
const BSONObj & | scope | |||
) | [inline] |
Append to the BSON object a field of type CodeWScope. This is a javascript code fragment accompanied by some scope that goes with it.
Definition at line 487 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendDate | ( | const StringData & | fieldName, | |
Date_t | dt | |||
) | [inline] |
Append a date.
dt | a Java-style 64 bit date value, that is the number of milliseconds since January 1, 1970, 00:00:00 GMT |
Definition at line 331 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendDBRef | ( | const StringData & | fieldName, | |
const StringData & | ns, | |||
const OID & | oid | |||
) | [inline] |
Definition at line 440 of file bsonobjbuilder.h.
BSONObjBuilder & mongo::BSONObjBuilder::appendElements | ( | BSONObj | x | ) | [inline] |
add all the fields from the object specified to this object
Definition at line 113 of file bson-inl.h.
BSONObjBuilder & mongo::BSONObjBuilder::appendElementsUnique | ( | BSONObj | x | ) | [inline] |
add all the fields from the object specified to this object if they don't exist already
Definition at line 124 of file bson-inl.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendIntOrLL | ( | const StringData & | fieldName, | |
long long | n | |||
) | [inline] |
appends a number. if n < max(int)/2 then uses int, otherwise long long
Definition at line 217 of file bsonobjbuilder.h.
void mongo::BSONObjBuilder::appendMaxForType | ( | const StringData & | fieldName, | |
int | type | |||
) |
BSONObjBuilder& mongo::BSONObjBuilder::appendMaxKey | ( | const StringData & | fieldName | ) | [inline] |
Definition at line 408 of file bsonobjbuilder.h.
void mongo::BSONObjBuilder::appendMinForType | ( | const StringData & | fieldName, | |
int | type | |||
) |
these are the min/max when comparing, not strict min/max elements for a given type
BSONObjBuilder& mongo::BSONObjBuilder::appendMinKey | ( | const StringData & | fieldName | ) | [inline] |
Definition at line 402 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendNull | ( | const StringData & | fieldName | ) | [inline] |
Append a Null element to the object
Definition at line 395 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendNumber | ( | const StringData & | fieldName, | |
long long | l | |||
) | [inline] |
Definition at line 251 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendNumber | ( | const StringData & | fieldName, | |
size_t | n | |||
) | [inline] |
Definition at line 240 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendNumber | ( | const StringData & | fieldName, | |
double | d | |||
) | [inline] |
Definition at line 236 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendNumber | ( | const StringData & | fieldName, | |
int | n | |||
) | [inline] |
appendNumber is a series of method for appending the smallest sensible type mostly for JS
Definition at line 232 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendObject | ( | const StringData & | fieldName, | |
const char * | objdata, | |||
int | size = 0 | |||
) | [inline] |
add a subobject as a member
Definition at line 135 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendOID | ( | const StringData & | fieldName, | |
OID * | oid = 0 , |
|||
bool | generateIfBlank = false | |||
) | [inline] |
Append a BSON Object ID (OID type).
Definition at line 281 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendRegex | ( | const StringData & | fieldName, | |
const StringData & | regex, | |||
const StringData & | options = "" | |||
) | [inline] |
Append a regular expression value
regex | the regular expression pattern | |
regex | options such as "i" or "g" |
Definition at line 353 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendSymbol | ( | const StringData & | fieldName, | |
const StringData & | symbol | |||
) | [inline] |
Definition at line 386 of file bsonobjbuilder.h.
BSONObjBuilder & mongo::BSONObjBuilder::appendTimestamp | ( | const StringData & | fieldName, | |
unsigned long long | time, | |||
unsigned int | inc | |||
) | [inline] |
BSONObjBuilder& mongo::BSONObjBuilder::appendTimestamp | ( | const StringData & | fieldName, | |
unsigned long long | val | |||
) | [inline] |
Definition at line 422 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendTimestamp | ( | const StringData & | fieldName | ) | [inline] |
Definition at line 415 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::appendTimeT | ( | const StringData & | fieldName, | |
time_t | dt | |||
) | [inline] |
Append a time_t date.
dt | a C-style 32 bit date value, that is the number of seconds since January 1, 1970, 00:00:00 GMT |
Definition at line 321 of file bsonobjbuilder.h.
void mongo::BSONObjBuilder::appendUndefined | ( | const StringData & | fieldName | ) | [inline] |
Definition at line 497 of file bsonobjbuilder.h.
void mongo::BSONObjBuilder::appendWhere | ( | const StringData & | code, | |
const BSONObj & | scope | |||
) | [inline] |
Definition at line 503 of file bsonobjbuilder.h.
BSONObj mongo::BSONObjBuilder::asTempObj | ( | ) | [inline] |
Peek at what is in the builder, but leave the builder ready for more appends. The returned object is only valid until the next modification or destruction of the builder. Intended use case: append a field if not already there.
Definition at line 550 of file bsonobjbuilder.h.
void mongo::BSONObjBuilder::decouple | ( | ) | [inline] |
Definition at line 565 of file bsonobjbuilder.h.
char* mongo::BSONObjBuilder::decouple | ( | int & | l | ) | [inline] |
Definition at line 558 of file bsonobjbuilder.h.
BSONObj mongo::BSONObjBuilder::done | ( | ) | [inline] |
Fetch the object we have built. BSONObjBuilder still frees the object when the builder goes out of scope -- very important to keep in mind. Use obj() if you would like the BSONObj to last longer than the builder.
Definition at line 537 of file bsonobjbuilder.h.
void mongo::BSONObjBuilder::doneFast | ( | ) | [inline] |
Definition at line 542 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::genOID | ( | ) | [inline] |
Generate and assign an object id for the _id field. _id should be the first element in the object for good performance.
Definition at line 313 of file bsonobjbuilder.h.
bool mongo::BSONObjBuilder::hasField | ( | const StringData & | name | ) | const [inline] |
Definition at line 227 of file bson-inl.h.
BSONObjIterator mongo::BSONObjBuilder::iterator | ( | ) | const [inline] |
Definition at line 221 of file bson-inl.h.
int mongo::BSONObjBuilder::len | ( | ) | const [inline] |
Definition at line 624 of file bsonobjbuilder.h.
static string mongo::BSONObjBuilder::numStr | ( | int | i | ) | [inline, static] |
Definition at line 571 of file bsonobjbuilder.h.
BSONObj mongo::BSONObjBuilder::obj | ( | ) | [inline] |
destructive The returned BSONObj will free the buffer when it is finished.
Definition at line 525 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::operator<< | ( | const BSONFieldValue< T > & | v | ) | [inline] |
Definition at line 611 of file bsonobjbuilder.h.
BSONObjBuilderValueStream& mongo::BSONObjBuilder::operator<< | ( | const BSONField< T > & | f | ) | [inline] |
Definition at line 605 of file bsonobjbuilder.h.
Labeler mongo::BSONObjBuilder::operator<< | ( | const Labeler::Label & | l | ) | [inline] |
Definition at line 599 of file bsonobjbuilder.h.
BSONObjBuilderValueStream& mongo::BSONObjBuilder::operator<< | ( | const ForceExplicitString & | name | ) | [inline] |
Stream oriented way to add field names and values.
Definition at line 595 of file bsonobjbuilder.h.
BSONObjBuilder& mongo::BSONObjBuilder::operator<< | ( | GENOIDLabeler | ) | [inline] |
Stream oriented way to add field names and values.
Definition at line 586 of file bsonobjbuilder.h.
BSONObjBuilderValueStream& mongo::BSONObjBuilder::operator<< | ( | const char * | name | ) | [inline] |
Stream oriented way to add field names and values.
Definition at line 580 of file bsonobjbuilder.h.
bool mongo::BSONObjBuilder::owned | ( | ) | const [inline] |
Definition at line 618 of file bsonobjbuilder.h.
BufBuilder& mongo::BSONObjBuilder::subarrayStart | ( | const StringData & | fieldName | ) | [inline] |
add header for a new subarray and return bufbuilder for writing to the subarray's body
Definition at line 173 of file bsonobjbuilder.h.
BufBuilder& mongo::BSONObjBuilder::subobjStart | ( | const StringData & | fieldName | ) | [inline] |
add header for a new subobject and return bufbuilder for writing to the subobject's body
Definition at line 152 of file bsonobjbuilder.h.
BufBuilder& mongo::BSONObjBuilder::_b [private] |
Definition at line 642 of file bsonobjbuilder.h.
BufBuilder mongo::BSONObjBuilder::_buf [private] |
Definition at line 643 of file bsonobjbuilder.h.
bool mongo::BSONObjBuilder::_doneCalled [private] |
Definition at line 647 of file bsonobjbuilder.h.
int mongo::BSONObjBuilder::_offset [private] |
Definition at line 644 of file bsonobjbuilder.h.
Definition at line 645 of file bsonobjbuilder.h.
BSONSizeTracker* mongo::BSONObjBuilder::_tracker [private] |
Definition at line 646 of file bsonobjbuilder.h.
const string mongo::BSONObjBuilder::numStrs[100] [static, private] |
Definition at line 649 of file bsonobjbuilder.h.