BSONObj::getIntField returns always int32. All numbers (32-bit integer
(type 16), 64-bit integer (type 18) and floating point (type 1)) get
converted to int32. If the field is another type, the
std::numeric_limits< int >::min()=-32767 gets returned.
If the value stored in the BSON object is bigger than INT_MAX=32767 you
will get an undefined behavior. So this operation is not save as long
you know exactly how big your numbers can become.
There is no direct way to retrieve an int64 (long long) from a BSONObj.
You have to get the BSONElement (getField) first. Than you can call
BSONElement::Long(), if you know your field is always from type 64-bit
integer or call BSONElement::numberLong() which converts from any number
type or returns 0 if it's not a number type.
Be careful: getField() only returns a kind of pointer into the BSONObj.
That means you have to store the BSONObj as long as you use the BSONElement.
David