#include <bsonelement.h>
Public Member Functions | |
| const mongo::OID & | __oid () const |
| string | _asCode () const |
| double | _numberDouble () const |
| int | _numberInt () const |
| long long | _numberLong () const |
| OpTime | _opTime () const |
| vector< BSONElement > | Array () const |
| const char * | binData (int &len) const |
| const char * | binDataClean (int &len) const |
| BinDataType | binDataType () const |
| bool | Bool () const |
| bool | boolean () const |
| BSONElement (const char *d, int maxLen=-1) | |
| BSONElement () | |
| int | canonicalType () const |
| const char * | codeWScopeCode () const |
| BSONObj | codeWScopeObject () const |
| const char * | codeWScopeScopeData () const |
| Date_t | date () const |
| Date_t | Date () const |
| const char * | dbrefNS () const |
| const mongo::OID & | dbrefOID () const |
| double | Double () const |
| BSONObj | embeddedObject () const |
| BSONObj | embeddedObjectUserCheck () const |
| bool | eoo () const |
| const char * | fieldName () const |
| int | getGtLtOp (int def=0) const |
| int | Int () const |
| bool | isABSONObj () const |
| bool | isBoolean () const |
| bool | isNull () const |
| bool | isNumber () const |
| bool | isSimpleType () const |
| string | jsonString (JsonStringFormat format, bool includeFieldNames=true, int pretty=0) const |
| long long | Long () const |
| bool | mayEncapsulate () const |
| void | Null () const |
| double | number () const |
| double | Number () const |
| double | numberDouble () const |
| int | numberInt () const |
| long long | numberLong () const |
| BSONObj | Obj () const |
| int | objsize () const |
| mongo::OID | OID () const |
| bool | ok () const |
| void | OK () const |
| operator string () const | |
| bool | operator< (const BSONElement &other) const |
| bool | operator== (const BSONElement &r) const |
| BSONElement | operator[] (const string &field) const |
| const char * | rawdata () const |
| const char * | regex () const |
| const char * | regexFlags () const |
| int | size (int maxLen=-1) const |
| string | str () const |
| string | String () const |
| unsigned int | timestampInc () const |
| Date_t | timestampTime () const |
| void | toString (StringBuilder &s, bool includeFieldName=true, bool full=false) const |
| string | toString (bool includeFieldName=true, bool full=false) const |
| bool | trueValue () const |
| BSONType | type () const |
| void | Val (string &v) const |
| void | Val (double &v) const |
| void | Val (int &v) const |
| void | Val (mongo::OID &v) const |
| void | Val (BSONObj &v) const |
| void | Val (bool &v) const |
| void | Val (long long &v) const |
| void | Val (Date_t &v) const |
| void | validate () const |
| const char * | value () const |
| bool | valuesEqual (const BSONElement &r) const |
| int | valuesize () const |
| const char * | valuestr () const |
| const char * | valuestrsafe () const |
| int | valuestrsize () const |
| int | woCompare (const BSONElement &e, bool considerFieldName=true) const |
| BSONObj | wrap (const char *newName) const |
| BSONObj | wrap () const |
Private Member Functions | |
| const BSONElement & | chk (bool expr) const |
| const BSONElement & | chk (int t) const |
| int | fieldNameSize () const |
Private Attributes | |
| const char * | data |
| int | fieldNameSize_ |
| int | totalSize |
Friends | |
| class | BSONObj |
| class | BSONObjIterator |
BSONElement represents an "element" in a BSONObj. So for the object { a : 3, b : "abc" }, 'a : 3' is the first element (key+value).
The BSONElement object points into the BSONObj's data. Thus the BSONObj must stay in scope for the life of the BSONElement.
internals: <type><fieldName>
-------- size() ------------ -fieldNameSize- value() type()
Definition at line 52 of file bsonelement.h.
| mongo::BSONElement::BSONElement | ( | ) | [inline] |
Constructs an empty element
Definition at line 548 of file bsonelement.h.
| mongo::BSONElement::BSONElement | ( | const char * | d, | |
| int | maxLen = -1 | |||
| ) | [inline, explicit] |
Definition at line 370 of file bsonelement.h.
| const mongo::OID& mongo::BSONElement::__oid | ( | ) | const [inline] |
Retrieve the object ID stored in the object. You must ensure the element is of type jstOID first.
Definition at line 198 of file bsonelement.h.
| double mongo::BSONElement::_numberDouble | ( | ) | const [inline] |
Return double value for this field. MUST be NumberDouble type.
Definition at line 177 of file bsonelement.h.
| int mongo::BSONElement::_numberInt | ( | ) | const [inline] |
Return double value for this field. MUST be NumberInt type.
Definition at line 179 of file bsonelement.h.
| long long mongo::BSONElement::_numberLong | ( | ) | const [inline] |
Return double value for this field. MUST be NumberLong type.
Definition at line 181 of file bsonelement.h.
| vector<BSONElement> mongo::BSONElement::Array | ( | ) | const |
| const char* mongo::BSONElement::binData | ( | int & | len | ) | const [inline] |
Get raw binary data. Element must be of type BinData. Doesn't handle type 2 specially
Definition at line 251 of file bsonelement.h.
| const char* mongo::BSONElement::binDataClean | ( | int & | len | ) | const [inline] |
Get binary data. Element must be of type BinData. Handles type 2
Definition at line 258 of file bsonelement.h.
| BinDataType mongo::BSONElement::binDataType | ( | ) | const [inline] |
Definition at line 270 of file bsonelement.h.
| bool mongo::BSONElement::Bool | ( | ) | const [inline] |
Definition at line 65 of file bsonelement.h.
| bool mongo::BSONElement::boolean | ( | ) | const [inline] |
Definition at line 154 of file bsonelement.h.
| int mongo::BSONElement::canonicalType | ( | ) | const [inline] |
returns the tyoe of the element fixed for the main type the main purpose is numbers. any numeric type will return NumberDouble Note: if the order changes, indexes have to be re-built or than can be corruption
Definition at line 414 of file bsonelement.h.
| const BSONElement& mongo::BSONElement::chk | ( | bool | expr | ) | const [inline, private] |
Definition at line 407 of file bsonelement.h.
| const BSONElement& mongo::BSONElement::chk | ( | int | t | ) | const [inline, private] |
Definition at line 399 of file bsonelement.h.
| const char* mongo::BSONElement::codeWScopeCode | ( | ) | const [inline] |
Get javascript code of a CodeWScope data element.
Definition at line 233 of file bsonelement.h.
| BSONObj mongo::BSONElement::codeWScopeObject | ( | ) | const [inline] |
Definition at line 44 of file bson-inl.h.
| const char* mongo::BSONElement::codeWScopeScopeData | ( | ) | const [inline] |
Get the scope SavedContext of a CodeWScope data element.
Definition at line 237 of file bsonelement.h.
| Date_t mongo::BSONElement::date | ( | ) | const [inline] |
Retrieve a java style date value from the element. Ensure element is of type Date before calling.
Definition at line 161 of file bsonelement.h.
| Date_t mongo::BSONElement::Date | ( | ) | const [inline] |
Definition at line 60 of file bsonelement.h.
| const char* mongo::BSONElement::dbrefNS | ( | ) | const [inline] |
Definition at line 350 of file bsonelement.h.
| const mongo::OID& mongo::BSONElement::dbrefOID | ( | ) | const [inline] |
Definition at line 355 of file bsonelement.h.
| double mongo::BSONElement::Double | ( | ) | const [inline] |
Definition at line 62 of file bsonelement.h.
| BSONObj mongo::BSONElement::embeddedObject | ( | ) | const [inline] |
Get the embedded object this element holds.
Definition at line 39 of file bson-inl.h.
| BSONObj mongo::BSONElement::embeddedObjectUserCheck | ( | ) | const [inline] |
Definition at line 30 of file bson-inl.h.
| bool mongo::BSONElement::eoo | ( | ) | const [inline] |
Indicates if it is the end-of-object element, which is present at the end of every BSON object.
Definition at line 118 of file bsonelement.h.
| const char* mongo::BSONElement::fieldName | ( | ) | const [inline] |
field name of the element. e.g., for name : "Joe" "name" is the fieldname
Definition at line 135 of file bsonelement.h.
| int mongo::BSONElement::fieldNameSize | ( | ) | const [inline, private] |
Definition at line 390 of file bsonelement.h.
| int mongo::BSONElement::getGtLtOp | ( | int | def = 0 |
) | const |
0 == Equality, just not defined yet
| int mongo::BSONElement::Int | ( | ) | const [inline] |
Definition at line 64 of file bsonelement.h.
| bool mongo::BSONElement::isABSONObj | ( | ) | const [inline] |
True if this element can be a BSONObj
Definition at line 332 of file bsonelement.h.
| bool mongo::BSONElement::isBoolean | ( | ) | const [inline] |
Definition at line 149 of file bsonelement.h.
| bool mongo::BSONElement::isNull | ( | ) | const [inline] |
True if element is null.
Definition at line 201 of file bsonelement.h.
| bool mongo::BSONElement::isNumber | ( | ) | const [inline] |
True if element is of a numeric type.
Definition at line 481 of file bsonelement.h.
| bool mongo::BSONElement::isSimpleType | ( | ) | const [inline] |
True if number, string, bool, date, OID
Definition at line 492 of file bsonelement.h.
| string mongo::BSONElement::jsonString | ( | JsonStringFormat | format, | |
| bool | includeFieldNames = true, |
|||
| int | pretty = 0 | |||
| ) | const |
| long long mongo::BSONElement::Long | ( | ) | const [inline] |
Definition at line 63 of file bsonelement.h.
| bool mongo::BSONElement::mayEncapsulate | ( | ) | const [inline] |
True if this element may contain subobjects.
Definition at line 320 of file bsonelement.h.
| void mongo::BSONElement::Null | ( | ) | const [inline] |
Definition at line 68 of file bsonelement.h.
| double mongo::BSONElement::number | ( | ) | const [inline] |
Retrieve the numeric value of the element. If not of a numeric type, returns 0. Note: casts to double, data loss may occur with large (>52 bit) NumberLong values.
Definition at line 194 of file bsonelement.h.
| double mongo::BSONElement::Number | ( | ) | const [inline] |
Definition at line 61 of file bsonelement.h.
| double mongo::BSONElement::numberDouble | ( | ) | const [inline] |
Retrieve the numeric value of the element. If not of a numeric type, returns 0. Note: casts to double, data loss may occur with large (>52 bit) NumberLong values.
Definition at line 507 of file bsonelement.h.
| int mongo::BSONElement::numberInt | ( | ) | const [inline] |
Retrieve int value for the element safely. Zero returned if not a number.
Retrieve int value for the element safely. Zero returned if not a number. Converted to int if another numeric type.
Definition at line 521 of file bsonelement.h.
| long long mongo::BSONElement::numberLong | ( | ) | const [inline] |
Retrieve long value for the element safely. Zero returned if not a number.
Definition at line 535 of file bsonelement.h.
| BSONObj mongo::BSONElement::Obj | ( | ) | const [inline] |
Definition at line 575 of file bson-inl.h.
| int mongo::BSONElement::objsize | ( | ) | const [inline] |
Definition at line 212 of file bsonelement.h.
| mongo::OID mongo::BSONElement::OID | ( | ) | const [inline] |
Definition at line 67 of file bsonelement.h.
| bool mongo::BSONElement::ok | ( | ) | const [inline] |
Use ok() to check if a value is assigned: if( myObj["foo"].ok() ) ...
Definition at line 94 of file bsonelement.h.
| void mongo::BSONElement::OK | ( | ) | const [inline] |
Definition at line 69 of file bsonelement.h.
| mongo::BSONElement::operator string | ( | ) | const [inline] |
Definition at line 99 of file bsonelement.h.
| bool mongo::BSONElement::operator< | ( | const BSONElement & | other | ) | const [inline] |
Definition at line 362 of file bsonelement.h.
| bool mongo::BSONElement::operator== | ( | const BSONElement & | r | ) | const [inline] |
Returns true if elements are equal.
Definition at line 297 of file bsonelement.h.
| BSONElement mongo::BSONElement::operator[] | ( | const string & | field | ) | const [inline] |
retrieve a field within this element throws exception if *this is not an embedded object
Definition at line 577 of file bson-inl.h.
| const char* mongo::BSONElement::rawdata | ( | ) | const [inline] |
Definition at line 308 of file bsonelement.h.
| const char* mongo::BSONElement::regex | ( | ) | const [inline] |
Retrieve the regex string for a Regex element
Definition at line 278 of file bsonelement.h.
| const char* mongo::BSONElement::regexFlags | ( | ) | const [inline] |
Retrieve the regex flags (options) for a Regex element
Definition at line 284 of file bsonelement.h.
| int mongo::BSONElement::size | ( | int | maxLen = -1 |
) | const [inline] |
Size of the element.
| maxLen | If maxLen is specified, don't scan more than maxLen bytes to calculate size. |
Definition at line 345 of file bson-inl.h.
| string mongo::BSONElement::str | ( | ) | const [inline] |
Get the string value of the element. If not a string returns "".
Definition at line 228 of file bsonelement.h.
| string mongo::BSONElement::String | ( | ) | const [inline] |
These functions, which start with a capital letter, throw a UserException if the element is not of the required type. Example:
string foo = obj["foo"].String(); // exception if not a string type or DNE
Definition at line 59 of file bsonelement.h.
| unsigned int mongo::BSONElement::timestampInc | ( | ) | const [inline] |
Definition at line 346 of file bsonelement.h.
| Date_t mongo::BSONElement::timestampTime | ( | ) | const [inline] |
Definition at line 342 of file bsonelement.h.
| void mongo::BSONElement::toString | ( | StringBuilder & | s, | |
| bool | includeFieldName = true, |
|||
| bool | full = false | |||
| ) | const [inline] |
Definition at line 432 of file bson-inl.h.
| string mongo::BSONElement::toString | ( | bool | includeFieldName = true, |
|
| bool | full = false | |||
| ) | const [inline] |
Definition at line 427 of file bson-inl.h.
| bool mongo::BSONElement::trueValue | ( | ) | const [inline] |
Convert the value to boolean, regardless of its type, in a javascript-like fashion (i.e., treat zero and null as false).
Definition at line 459 of file bsonelement.h.
| BSONType mongo::BSONElement::type | ( | ) | const [inline] |
Returns the type of the element
Definition at line 102 of file bsonelement.h.
| void mongo::BSONElement::Val | ( | string & | v | ) | const [inline] |
Definition at line 89 of file bsonelement.h.
| void mongo::BSONElement::Val | ( | double & | v | ) | const [inline] |
Definition at line 88 of file bsonelement.h.
| void mongo::BSONElement::Val | ( | int & | v | ) | const [inline] |
Definition at line 87 of file bsonelement.h.
| void mongo::BSONElement::Val | ( | mongo::OID & | v | ) | const [inline] |
Definition at line 86 of file bsonelement.h.
| void mongo::BSONElement::Val | ( | BSONObj & | v | ) | const [inline] |
Definition at line 656 of file bson-inl.h.
| void mongo::BSONElement::Val | ( | bool & | v | ) | const [inline] |
Definition at line 84 of file bsonelement.h.
| void mongo::BSONElement::Val | ( | long long & | v | ) | const [inline] |
Definition at line 83 of file bsonelement.h.
| void mongo::BSONElement::Val | ( | Date_t & | v | ) | const [inline] |
populate v with the value of the element. If type does not match, throw exception. useful in templates -- see also BSONObj::Vals().
Definition at line 82 of file bsonelement.h.
| void mongo::BSONElement::validate | ( | ) | const [inline] |
Check that data is internally consistent.
Definition at line 306 of file bson-inl.h.
| const char* mongo::BSONElement::value | ( | ) | const [inline] |
raw data of the element's value (so be careful).
Definition at line 141 of file bsonelement.h.
| bool mongo::BSONElement::valuesEqual | ( | const BSONElement & | r | ) | const [inline] |
like operator== but doesn't check the fieldname, just the value.
Definition at line 292 of file bsonelement.h.
| int mongo::BSONElement::valuesize | ( | ) | const [inline] |
size in bytes of the element's value (when applicable).
Definition at line 145 of file bsonelement.h.
| const char* mongo::BSONElement::valuestr | ( | ) | const [inline] |
Get a string's value. Also gives you start of the real data for an embedded object. You must assure data is of an appropriate type first -- see also valuestrsafe().
Definition at line 219 of file bsonelement.h.
| const char* mongo::BSONElement::valuestrsafe | ( | ) | const [inline] |
Get the string value of the element. If not a string returns "".
Definition at line 224 of file bsonelement.h.
| int mongo::BSONElement::valuestrsize | ( | ) | const [inline] |
Size (length) of a string element. You must assure of type String first.
Definition at line 207 of file bsonelement.h.
| int mongo::BSONElement::woCompare | ( | const BSONElement & | e, | |
| bool | considerFieldName = true | |||
| ) | const |
Well ordered comparison.
| BSONObj mongo::BSONElement::wrap | ( | const char * | newName | ) | const [inline] |
Wrap this element up as a singleton object with a new name.
Definition at line 84 of file bson-inl.h.
| BSONObj mongo::BSONElement::wrap | ( | ) | const [inline] |
Wrap this element up as a singleton object.
Definition at line 78 of file bson-inl.h.
friend class BSONObj [friend] |
Definition at line 398 of file bsonelement.h.
friend class BSONObjIterator [friend] |
Definition at line 397 of file bsonelement.h.
const char* mongo::BSONElement::data [private] |
Definition at line 388 of file bsonelement.h.
int mongo::BSONElement::fieldNameSize_ [mutable, private] |
Definition at line 389 of file bsonelement.h.
int mongo::BSONElement::totalSize [mutable, private] |
Definition at line 395 of file bsonelement.h.