本文整理汇总了C++中BSONElement::regex方法的典型用法代码示例。如果您正苦于以下问题:C++ BSONElement::regex方法的具体用法?C++ BSONElement::regex怎么用?C++ BSONElement::regex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSONElement
的用法示例。
在下文中一共展示了BSONElement::regex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LeafMatchExpression
RegexMatchExpression::RegexMatchExpression(StringData path, const BSONElement& e)
: LeafMatchExpression(REGEX, path),
_regex(e.regex()),
_flags(e.regexFlags()),
_re(new pcrecpp::RE(_regex.c_str(), flags2options(_flags.c_str()))) {
uassert(ErrorCodes::BadValue, "regex not a regex", e.type() == RegEx);
_init();
}
示例2: _parseRegexElement
StatusWithMatchExpression MatchExpressionParser::_parseRegexElement( const char* name,
const BSONElement& e ) {
if ( e.type() != RegEx )
return StatusWithMatchExpression( ErrorCodes::BadValue, "not a regex" );
std::auto_ptr<RegexMatchExpression> temp( new RegexMatchExpression() );
Status s = temp->init( name, e.regex(), e.regexFlags() );
if ( !s.isOK() )
return StatusWithMatchExpression( s );
return StatusWithMatchExpression( temp.release() );
}
示例3: csvString
// Gets the string representation of a BSON object that can be correctly written to a CSV file
string csvString (const BSONElement& object) {
const char* binData; // Only used with BinData type
switch (object.type()) {
case MinKey:
return "$MinKey";
case MaxKey:
return "$MaxKey";
case NumberInt:
case NumberDouble:
case NumberLong:
case Bool:
return object.toString(false);
case String:
case Symbol:
return csvEscape(object.toString(false), true);
case Object:
return csvEscape(object.jsonString(Strict, false));
case Array:
return csvEscape(object.jsonString(Strict, false));
case BinData:
int len;
binData = object.binDataClean(len);
return toHex(binData, len);
case jstOID:
return "ObjectID(" + object.OID().toString() + ")"; // OIDs are always 24 bytes
case Date:
return timeToISOString(object.Date() / 1000);
case Timestamp:
return csvEscape(object.jsonString(Strict, false));
case RegEx:
return csvEscape("/" + string(object.regex()) + "/" + string(object.regexFlags()));
case Code:
return csvEscape(object.toString(false));
case CodeWScope:
if (string(object.codeWScopeScopeDataUnsafe()) == "") {
return csvEscape(object.toString(false));
} else {
return csvEscape(object.jsonString(Strict, false));
}
case EOO:
case Undefined:
case DBRef:
case jstNULL:
cerr << "Invalid BSON object type for CSV output: " << object.type() << endl;
return "";
}
// Can never get here
verify(false);
return "";
}
示例4: matchesSingleElement
bool RegexMatchExpression::matchesSingleElement( const BSONElement& e ) const {
//log() << "RegexMatchExpression::matchesSingleElement _regex: " << _regex << " e: " << e << std::endl;
switch (e.type()) {
case String:
case Symbol:
//if (rm._prefix.empty())
return _re->PartialMatch(e.valuestr());
//else
//return !strncmp(e.valuestr(), rm._prefix.c_str(), rm._prefix.size());
case RegEx:
return _regex == e.regex() && _flags == e.regexFlags();
default:
return false;
}
}
示例5: matchesSingleElement
bool RegexMatchExpression::matchesSingleElement(const BSONElement& e) const {
switch (e.type()) {
case String:
case Symbol: {
// String values stored in documents can contain embedded NUL bytes. We construct a
// pcrecpp::StringPiece instance using the full length of the string to avoid truncating
// 'data' early.
pcrecpp::StringPiece data(e.valuestr(), e.valuestrsize() - 1);
return _re->PartialMatch(data);
}
case RegEx:
return _regex == e.regex() && _flags == e.regexFlags();
default:
return false;
}
}
示例6: _parseRegexDocument
StatusWithMatchExpression MatchExpressionParser::_parseRegexDocument( const char* name,
const BSONObj& doc ) {
string regex;
string regexOptions;
BSONObjIterator i( doc );
while ( i.more() ) {
BSONElement e = i.next();
switch ( e.getGtLtOp() ) {
case BSONObj::opREGEX:
if ( e.type() == String ) {
regex = e.String();
}
else if ( e.type() == RegEx ) {
regex = e.regex();
regexOptions = e.regexFlags();
}
else {
return StatusWithMatchExpression( ErrorCodes::BadValue,
"$regex has to be a string" );
}
break;
case BSONObj::opOPTIONS:
if ( e.type() != String )
return StatusWithMatchExpression( ErrorCodes::BadValue,
"$options has to be a string" );
regexOptions = e.String();
break;
default:
break;
}
}
std::auto_ptr<RegexMatchExpression> temp( new RegexMatchExpression() );
Status s = temp->init( name, regex, regexOptions );
if ( !s.isOK() )
return StatusWithMatchExpression( s );
return StatusWithMatchExpression( temp.release() );
}
示例7: switch
Local<v8::Object> mongoToV8( BSONObj & m , bool array ){
Local<v8::Object> o;
if ( array )
o = v8::Array::New();
else
o = v8::Object::New();
mongo::BSONObj sub;
for ( BSONObjIterator i(m); i.more(); ) {
BSONElement f = i.next();
if ( f.eoo() )
break;
Local<Value> v;
switch ( f.type() ){
case mongo::Code:
cout << "warning, code saved in database just turned into string right now" << endl;
case mongo::String:
o->Set( v8::String::New( f.fieldName() ) , v8::String::New( f.valuestr() ) );
break;
case mongo::jstOID: {
v8::Function * idCons = getObjectIdCons();
v8::Handle<v8::Value> argv[1];
argv[0] = v8::String::New( f.__oid().str().c_str() );
o->Set( v8::String::New( f.fieldName() ) ,
idCons->NewInstance( 1 , argv ) );
break;
}
case mongo::NumberDouble:
case mongo::NumberInt:
o->Set( v8::String::New( f.fieldName() ) , v8::Number::New( f.number() ) );
break;
case mongo::Array:
case mongo::Object:
sub = f.embeddedObject();
o->Set( v8::String::New( f.fieldName() ) , mongoToV8( sub , f.type() == mongo::Array ) );
break;
case mongo::Date:
o->Set( v8::String::New( f.fieldName() ) , v8::Date::New( f.date() ) );
break;
case mongo::Bool:
o->Set( v8::String::New( f.fieldName() ) , v8::Boolean::New( f.boolean() ) );
break;
case mongo::jstNULL:
o->Set( v8::String::New( f.fieldName() ) , v8::Null() );
break;
case mongo::RegEx: {
v8::Function * regex = getNamedCons( "RegExp" );
v8::Handle<v8::Value> argv[2];
argv[0] = v8::String::New( f.regex() );
argv[1] = v8::String::New( f.regexFlags() );
o->Set( v8::String::New( f.fieldName() ) , regex->NewInstance( 2 , argv ) );
break;
}
case mongo::BinData: {
Local<v8::Object> b = v8::Object::New();
int len;
f.binData( len );
b->Set( v8::String::New( "subtype" ) , v8::Number::New( f.binDataType() ) );
b->Set( v8::String::New( "length" ) , v8::Number::New( len ) );
o->Set( v8::String::New( f.fieldName() ) , b );
break;
};
case mongo::Timestamp: {
Local<v8::Object> sub = v8::Object::New();
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
o->Set( v8::String::New( f.fieldName() ) , sub );
break;
}
default:
cout << "can't handle type: ";
cout << f.type() << " ";
cout << f.toString();
cout << endl;
break;
}
}
//.........这里部分代码省略.........
示例8: compareElementValues
/* must be same type! */
int compareElementValues(const BSONElement& l, const BSONElement& r) {
int f;
double x;
switch ( l.type() ) {
case EOO:
case Undefined:
case jstNULL:
case MaxKey:
case MinKey:
f = l.type() - r.type();
if ( f<0 ) return -1;
return f==0 ? 0 : 1;
case Bool:
return *l.value() - *r.value();
case Timestamp:
case Date:
if ( l.date() < r.date() )
return -1;
return l.date() == r.date() ? 0 : 1;
case NumberInt:
case NumberDouble: {
double left = l.number();
double right = r.number();
bool lNan = !( left <= numeric_limits< double >::max() &&
left >= -numeric_limits< double >::max() );
bool rNan = !( right <= numeric_limits< double >::max() &&
right >= -numeric_limits< double >::max() );
if ( lNan ) {
if ( rNan ) {
return 0;
} else {
return -1;
}
} else if ( rNan ) {
return 1;
}
x = left - right;
if ( x < 0 ) return -1;
return x == 0 ? 0 : 1;
}
case jstOID:
return memcmp(l.value(), r.value(), 12);
case Code:
case Symbol:
case String:
/* todo: utf version */
return strcmp(l.valuestr(), r.valuestr());
case Object:
case Array:
return l.embeddedObject().woCompare( r.embeddedObject() );
case DBRef:
case BinData: {
int lsz = l.valuesize();
int rsz = r.valuesize();
if ( lsz - rsz != 0 ) return lsz - rsz;
return memcmp(l.value(), r.value(), lsz);
}
case RegEx:
{
int c = strcmp(l.regex(), r.regex());
if ( c )
return c;
return strcmp(l.regexFlags(), r.regexFlags());
}
default:
out() << "compareElementValues: bad type " << (int) l.type() << endl;
assert(false);
}
return -1;
}
示例9: init
Status RegexMatchExpression::init(StringData path, const BSONElement& e) {
if (e.type() != RegEx)
return Status(ErrorCodes::BadValue, "regex not a regex");
return init(path, e.regex(), e.regexFlags());
}
示例10: assert
Handle<v8::Value> mongoToV8Element( const BSONElement &f ) {
assert( !f.eoo() );
switch ( f.type() ){
case mongo::Code:
cout << "warning, code saved in database just turned into string right now" << endl;
case mongo::String:
return v8::String::New( f.valuestr() );
case mongo::jstOID: {
v8::Function * idCons = getObjectIdCons();
v8::Handle<v8::Value> argv[1];
argv[0] = v8::String::New( f.__oid().str().c_str() );
return idCons->NewInstance( 1 , argv );
}
case mongo::NumberDouble:
case mongo::NumberInt:
return v8::Number::New( f.number() );
case mongo::Array:
case mongo::Object:
return mongoToV8( f.embeddedObject() , f.type() == mongo::Array );
case mongo::Date:
return v8::Date::New( f.date() );
case mongo::Bool:
return v8::Boolean::New( f.boolean() );
case mongo::jstNULL:
return v8::Null();
case mongo::RegEx: {
v8::Function * regex = getNamedCons( "RegExp" );
v8::Handle<v8::Value> argv[2];
argv[0] = v8::String::New( f.regex() );
argv[1] = v8::String::New( f.regexFlags() );
return regex->NewInstance( 2 , argv );
break;
}
case mongo::BinData: {
Local<v8::Object> b = v8::Object::New();
int len;
f.binData( len );
b->Set( v8::String::New( "subtype" ) , v8::Number::New( f.binDataType() ) );
b->Set( v8::String::New( "length" ) , v8::Number::New( len ) );
return b;
};
case mongo::Timestamp: {
Local<v8::Object> sub = v8::Object::New();
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
return sub;
}
case mongo::MinKey:
// TODO: make a special type
return v8::String::New( "MinKey" );
case mongo::MaxKey:
// TODO: make a special type
return v8::String::New( "MaxKey" );
case mongo::Undefined:
return v8::Undefined();
default:
cout << "can't handle type: ";
cout << f.type() << " ";
cout << f.toString();
cout << endl;
break;
}
return v8::Undefined();
}
示例11: jsonString
//.........这里部分代码省略.........
}
s << "{ \"$binary\" : \"";
char *start = ( char * )( elem.value() ) + sizeof( int ) + 1;
base64::encode( s , start , len );
s << "\", \"$type\" : \"" << hex;
s.width( 2 );
s.fill( '0' );
s << type << dec;
s << "\" }";
break;
}
case mongo::Date:
if ( format == Strict )
s << "{ \"$date\" : ";
else
s << "ISODate(";
if( pretty ) {
Date_t d = elem.date();
long long ms = (long long) d.millis;
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
boost::posix_time::time_duration diff = boost::posix_time::millisec(ms);
boost::posix_time::ptime time = epoch + diff;
std::string timestr = miutil::isotimeString(time, true, true);
s << '"' << timestr << '"';
/* if( d == 0 ) s << '0';
else
//P s << '"' << elem.date().toString() << '"';
s << '"' << elem.date().millis << '"';*/
}
else
s << elem.date();
if ( format == Strict )
s << " }";
else
s << ")";
break;
case RegEx:
if ( format == Strict ) {
s << "{ \"$regex\" : \"" << escape( elem.regex() );
s << "\", \"$options\" : \"" << elem.regexFlags() << "\" }";
}
else {
s << "/" << escape( elem.regex() , true ) << "/";
// FIXME Worry about alpha order?
for ( const char *f = elem.regexFlags(); *f; ++f ) {
switch ( *f ) {
case 'g':
case 'i':
case 'm':
s << *f;
default:
break;
}
}
}
break;
case CodeWScope: {
BSONObj scope = elem.codeWScopeObject();
if ( ! scope.isEmpty() ) {
s << "{ \"$code\" : " << elem._asCode() << " , "
<< " \"$scope\" : " << scope.jsonString() << " }";
break;
}
}
case Code:
s << elem._asCode();
break;
case Timestamp:
if ( format == TenGen ) {
s << "Timestamp(" << ( elem.timestampTime() / 1000 ) << ", " << elem.timestampInc() << ")";
}
else {
s << "{ \"$timestamp\" : { \"t\" : " << ( elem.timestampTime() / 1000 ) << ", \"i\" : " << elem.timestampInc() << " } }";
}
break;
case MinKey:
s << "{ \"$minKey\" : 1 }";
break;
case MaxKey:
s << "{ \"$maxKey\" : 1 }";
break;
default:
StringBuilder ss;
ss << "Cannot create a properly formatted JSON string with "
<< "element: " << elem.toString() << " of type: " << elem.type();
string message = ss.str();
//massert( 10312 , message.c_str(), false );
}
return s.str();
}
示例12: lua_push_value
void lua_push_value(lua_State *L, const BSONElement &elem) {
int type = elem.type();
switch(type) {
case mongo::Undefined:
lua_pushnil(L);
break;
case mongo::NumberInt:
lua_pushinteger(L, elem.numberInt());
break;
case mongo::NumberLong:
case mongo::NumberDouble:
lua_pushnumber(L, elem.number());
break;
case mongo::Bool:
lua_pushboolean(L, elem.boolean());
break;
case mongo::String:
lua_pushstring(L, elem.valuestr());
break;
case mongo::Array:
bson_to_array(L, elem.embeddedObject());
break;
case mongo::Object:
bson_to_table(L, elem.embeddedObject());
break;
case mongo::Date:
push_bsontype_table(L, mongo::Date);
lua_pushnumber(L, elem.date());
lua_rawseti(L, -2, 1);
break;
case mongo::Timestamp:
push_bsontype_table(L, mongo::Date);
lua_pushnumber(L, elem.timestampTime());
lua_rawseti(L, -2, 1);
break;
case mongo::Symbol:
push_bsontype_table(L, mongo::Symbol);
lua_pushstring(L, elem.valuestr());
lua_rawseti(L, -2, 1);
break;
case mongo::RegEx:
push_bsontype_table(L, mongo::RegEx);
lua_pushstring(L, elem.regex());
lua_rawseti(L, -2, 1);
lua_pushstring(L, elem.regexFlags());
lua_rawseti(L, -2, 2);
break;
case mongo::jstOID:
push_bsontype_table(L, mongo::jstOID);
lua_pushstring(L, elem.__oid().str().c_str());
lua_rawseti(L, -2, 1);
break;
case mongo::jstNULL:
push_bsontype_table(L, mongo::jstNULL);
break;
case mongo::EOO:
break;
default:
luaL_error(L, LUAMONGO_UNSUPPORTED_BSON_TYPE, bson_name(type));
}
}
示例13: compareElementValues
/* must be same type when called, unless both sides are #s
*/
int compareElementValues(const BSONElement& l, const BSONElement& r) {
int f;
double x;
switch ( l.type() ) {
case EOO:
case Undefined:
case jstNULL:
case MaxKey:
case MinKey:
f = l.canonicalType() - r.canonicalType();
if ( f<0 ) return -1;
return f==0 ? 0 : 1;
case Bool:
return *l.value() - *r.value();
case Timestamp:
case Date:
if ( l.date() < r.date() )
return -1;
return l.date() == r.date() ? 0 : 1;
case NumberLong:
if( r.type() == NumberLong ) {
long long L = l._numberLong();
long long R = r._numberLong();
if( L < R ) return -1;
if( L == R ) return 0;
return 1;
}
// else fall through
case NumberInt:
case NumberDouble: {
double left = l.number();
double right = r.number();
bool lNan = !( left <= numeric_limits< double >::max() &&
left >= -numeric_limits< double >::max() );
bool rNan = !( right <= numeric_limits< double >::max() &&
right >= -numeric_limits< double >::max() );
if ( lNan ) {
if ( rNan ) {
return 0;
} else {
return -1;
}
} else if ( rNan ) {
return 1;
}
x = left - right;
if ( x < 0 ) return -1;
return x == 0 ? 0 : 1;
}
case jstOID:
return memcmp(l.value(), r.value(), 12);
case Code:
case Symbol:
case String:
/* todo: utf version */
return strcmp(l.valuestr(), r.valuestr());
case Object:
case Array:
return l.embeddedObject().woCompare( r.embeddedObject() );
case DBRef: {
int lsz = l.valuesize();
int rsz = r.valuesize();
if ( lsz - rsz != 0 ) return lsz - rsz;
return memcmp(l.value(), r.value(), lsz);
}
case BinData: {
int lsz = l.objsize(); // our bin data size in bytes, not including the subtype byte
int rsz = r.objsize();
if ( lsz - rsz != 0 ) return lsz - rsz;
return memcmp(l.value()+4, r.value()+4, lsz+1);
}
case RegEx:
{
int c = strcmp(l.regex(), r.regex());
if ( c )
return c;
return strcmp(l.regexFlags(), r.regexFlags());
}
case CodeWScope : {
f = l.canonicalType() - r.canonicalType();
if ( f )
return f;
f = strcmp( l.codeWScopeCode() , r.codeWScopeCode() );
if ( f )
return f;
f = strcmp( l.codeWScopeScopeData() , r.codeWScopeScopeData() );
if ( f )
return f;
return 0;
}
default:
out() << "compareElementValues: bad type " << (int) l.type() << endl;
assert(false);
}
return -1;
}
示例14: compareElements
//.........这里部分代码省略.........
return compareLongs(l._numberLong(), r._numberLong());
case NumberInt:
return compareLongs(l._numberLong(), r._numberInt());
case NumberDouble:
return compareLongToDouble(l._numberLong(), r._numberDouble());
case NumberDecimal:
return compareLongToDecimal(l._numberLong(), r._numberDecimal());
default:
MONGO_UNREACHABLE;
}
}
case BSONType::NumberDouble: {
switch (r.type()) {
case NumberDouble:
return compareDoubles(l._numberDouble(), r._numberDouble());
case NumberInt:
return compareDoubles(l._numberDouble(), r._numberInt());
case NumberLong:
return compareDoubleToLong(l._numberDouble(), r._numberLong());
case NumberDecimal:
return compareDoubleToDecimal(l._numberDouble(), r._numberDecimal());
default:
MONGO_UNREACHABLE;
}
}
case BSONType::NumberDecimal: {
switch (r.type()) {
case NumberDecimal:
return compareDecimals(l._numberDecimal(), r._numberDecimal());
case NumberInt:
return compareDecimalToInt(l._numberDecimal(), r._numberInt());
case NumberLong:
return compareDecimalToLong(l._numberDecimal(), r._numberLong());
case NumberDouble:
return compareDecimalToDouble(l._numberDecimal(), r._numberDouble());
default:
MONGO_UNREACHABLE;
}
}
case BSONType::jstOID:
return memcmp(l.value(), r.value(), OID::kOIDSize);
case BSONType::Code:
return compareElementStringValues(l, r);
case BSONType::Symbol:
case BSONType::String: {
if (comparator) {
return comparator->compare(l.valueStringData(), r.valueStringData());
} else {
return compareElementStringValues(l, r);
}
}
case BSONType::Object:
case BSONType::Array: {
return l.embeddedObject().woCompare(
r.embeddedObject(),
BSONObj(),
rules | BSONElement::ComparisonRules::kConsiderFieldName,
comparator);
}
case BSONType::DBRef: {
int lsz = l.valuesize();
int rsz = r.valuesize();
if (lsz - rsz != 0)
return lsz - rsz;
return memcmp(l.value(), r.value(), lsz);
}
case BSONType::BinData: {
int lsz = l.objsize(); // our bin data size in bytes, not including the subtype byte
int rsz = r.objsize();
if (lsz - rsz != 0)
return lsz - rsz;
return memcmp(l.value() + 4, r.value() + 4, lsz + 1 /*+1 for subtype byte*/);
}
case BSONType::RegEx: {
int c = strcmp(l.regex(), r.regex());
if (c)
return c;
return strcmp(l.regexFlags(), r.regexFlags());
}
case BSONType::CodeWScope: {
int cmp = StringData(l.codeWScopeCode(), l.codeWScopeCodeLen() - 1)
.compare(StringData(r.codeWScopeCode(), r.codeWScopeCodeLen() - 1));
if (cmp)
return cmp;
// When comparing the scope object, we should consider field names. Special string
// comparison semantics do not apply to strings nested inside the CodeWScope scope
// object, so we do not pass through the string comparator.
return l.codeWScopeObject().woCompare(
r.codeWScopeObject(),
BSONObj(),
rules | BSONElement::ComparisonRules::kConsiderFieldName);
}
}
MONGO_UNREACHABLE;
}
示例15: newFunction
Handle<v8::Value> mongoToV8Element( const BSONElement &f ) {
Local< v8::ObjectTemplate > internalFieldObjects = v8::ObjectTemplate::New();
internalFieldObjects->SetInternalFieldCount( 1 );
switch ( f.type() ){
case mongo::Code:
return newFunction( f.valuestr() );
case CodeWScope:
if ( f.codeWScopeObject().isEmpty() )
log() << "warning: CodeWScope doesn't transfer to db.eval" << endl;
return newFunction( f.codeWScopeCode() );
case mongo::String:
return v8::String::New( f.valuestr() );
case mongo::jstOID:
return newId( f.__oid() );
case mongo::NumberDouble:
case mongo::NumberInt:
return v8::Number::New( f.number() );
case mongo::Array:
case mongo::Object:
return mongoToV8( f.embeddedObject() , f.type() == mongo::Array );
case mongo::Date:
return v8::Date::New( f.date() );
case mongo::Bool:
return v8::Boolean::New( f.boolean() );
case mongo::EOO:
case mongo::jstNULL:
case mongo::Undefined: // duplicate sm behavior
return v8::Null();
case mongo::RegEx: {
v8::Function * regex = getNamedCons( "RegExp" );
v8::Handle<v8::Value> argv[2];
argv[0] = v8::String::New( f.regex() );
argv[1] = v8::String::New( f.regexFlags() );
return regex->NewInstance( 2 , argv );
break;
}
case mongo::BinData: {
int len;
const char *data = f.binData( len );
v8::Function* binData = getNamedCons( "BinData" );
v8::Handle<v8::Value> argv[3];
argv[0] = v8::Number::New( len );
argv[1] = v8::Number::New( f.binDataType() );
argv[2] = v8::String::New( data, len );
return binData->NewInstance( 3, argv );
};
case mongo::Timestamp: {
Local<v8::Object> sub = internalFieldObjects->NewInstance();
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
sub->SetInternalField( 0, v8::Uint32::New( f.type() ) );
return sub;
}
case mongo::NumberLong: {
Local<v8::Object> sub = internalFieldObjects->NewInstance();
unsigned long long val = f.numberLong();
v8::Function* numberLong = getNamedCons( "NumberLong" );
v8::Handle<v8::Value> argv[2];
argv[0] = v8::Integer::New( val >> 32 );
argv[1] = v8::Integer::New( (unsigned long)(val & 0x00000000ffffffff) );
return numberLong->NewInstance( 2, argv );
}
case mongo::MinKey: {
Local<v8::Object> sub = internalFieldObjects->NewInstance();
sub->Set( v8::String::New( "$MinKey" ), v8::Boolean::New( true ) );
sub->SetInternalField( 0, v8::Uint32::New( f.type() ) );
return sub;
}
case mongo::MaxKey: {
Local<v8::Object> sub = internalFieldObjects->NewInstance();
sub->Set( v8::String::New( "$MaxKey" ), v8::Boolean::New( true ) );
sub->SetInternalField( 0, v8::Uint32::New( f.type() ) );
return sub;
}
case mongo::DBRef: {
v8::Function* dbPointer = getNamedCons( "DBPointer" );
v8::Handle<v8::Value> argv[2];
argv[0] = v8::String::New( f.dbrefNS() );
//.........这里部分代码省略.........