• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ mongo::BSONObj类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中mongo::BSONObj的典型用法代码示例。如果您正苦于以下问题:C++ BSONObj类的具体用法?C++ BSONObj怎么用?C++ BSONObj使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BSONObj类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: MongoNamespace

MongoCollectionInfo::MongoCollectionInfo(mongo::BSONObj stats)
{
    _ns = MongoNamespace(QString::fromStdString(stats.getStringField("ns")));
    _sizeBytes = stats.getIntField("size");
    _count = stats.getIntField("count");
    _storageSizeBytes = stats.getIntField("storageSize");
}
开发者ID:AlPatsino,项目名称:robomongo,代码行数:7,代码来源:MongoCollectionInfo.cpp


示例2: assert

//-----------------------------------------------------------------------------
bool joint_c::fetch( Reveal::Core::joint_ptr joint, mongo::BSONObj bson ) {

  assert( joint );

  joint->id = bson.getField( FIELD_ID ).String();

  mongo::BSONObj bson_q = bson.getObjectField( FIELD_STATE_POSITION );
  std::vector<mongo::BSONElement> v_q;
  bson_q.elems( v_q );

  for( unsigned i = 0; i < v_q.size(); i++ )
    joint->state.q( i, v_q[i].Double() );

  mongo::BSONObj bson_dq = bson.getObjectField( FIELD_STATE_VELOCITY );

  std::vector<mongo::BSONElement> v_dq;
  bson_dq.elems( v_dq );

  for( unsigned i = 0; i < v_dq.size(); i++ )
    joint->state.dq( i, v_dq[i].Double() );

  mongo::BSONObj bson_u = bson.getObjectField( FIELD_CONTROL );
  std::vector<mongo::BSONElement> v_u;
  bson_u.elems( v_u );

  for( unsigned i = 0; i < v_u.size(); i++ )
    joint->control.u( i, v_u[i].Double() );

  return true;
}
开发者ID:jacquelinekay,项目名称:reveal,代码行数:31,代码来源:joint.cpp


示例3: JSSleep

 mongo::BSONObj JSSleep(const mongo::BSONObj &args){
     assert( args.nFields() == 1 );
     assert( args.firstElement().isNumber() );
     int ms = int( args.firstElement().number() );
     sleepms( ms );
     return undefined_;
 }
开发者ID:alanw,项目名称:mongo,代码行数:7,代码来源:utils.cpp


示例4: bigFiles

RepoBSON::RepoBSON(
	const mongo::BSONObj &obj,
	const std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> &binMapping)
	: mongo::BSONObj(obj),
	bigFiles(binMapping)
{
	std::vector<std::pair<std::string, std::string>> existingFiles;

	if (bigFiles.size() > 0)
	{
		mongo::BSONObjBuilder builder, arrbuilder;

		for (const auto & pair : bigFiles)
		{
			//append field name :file name
			arrbuilder << pair.first << pair.second.first;
		}

		if (obj.hasField(REPO_LABEL_OVERSIZED_FILES))
		{
			arrbuilder.appendElementsUnique(obj.getObjectField(REPO_LABEL_OVERSIZED_FILES));
		}


		builder.append(REPO_LABEL_OVERSIZED_FILES, arrbuilder.obj());
		builder.appendElementsUnique(obj);

		*this = builder.obj();
		bigFiles = binMapping;
	}
	


}
开发者ID:wsdflink,项目名称:3drepobouncer,代码行数:34,代码来源:repo_bson.cpp


示例5: return_bson

Datum return_bson(const mongo::BSONObj& b)
{
    std::size_t bson_size = b.objsize() + VARHDRSZ;
    bytea* new_bytea = (bytea *) palloc(bson_size);
    SET_VARSIZE(new_bytea, bson_size);
    std::memcpy(VARDATA(new_bytea), b.objdata(), b.objsize());
    PG_RETURN_BYTEA_P(new_bytea);
}
开发者ID:maciekgajewski,项目名称:postgresbson,代码行数:8,代码来源:pgbson_internal.cpp


示例6:

    MongoCollectionInfo::MongoCollectionInfo(mongo::BSONObj stats):_ns(QString::fromStdString(stats.getStringField("ns")))
    {
        // if "size" and "storageSize" are of type Int32 or Int64, they
        // will be converted to double by "numberDouble()" function.
        _sizeBytes = stats.getField("size").numberDouble();
        _storageSizeBytes = stats.getField("storageSize").numberDouble();

        _count = stats.getIntField("count");
    }
开发者ID:strogo,项目名称:robomongo,代码行数:9,代码来源:MongoCollectionInfo.cpp


示例7: native_sleep

    static BSONObj native_sleep( const mongo::BSONObj& args, void* data ) {
        uassert( 16259,
                 "sleep takes a single numeric argument -- sleep(milliseconds)",
                 args.nFields() == 1 && args.firstElement().isNumber() );
        sleepmillis( static_cast<long long>( args.firstElement().number() ) );

        BSONObjBuilder b;
        b.appendUndefined( "" );
        return b.obj();
    }
开发者ID:AK-Dominator,项目名称:mongo,代码行数:10,代码来源:utils.cpp


示例8: map

//-----------------------------------------------------------------------------
bool trial_c::map( Reveal::Core::trial_ptr& trial, mongo::BSONObj obj ) { 

  trial = Reveal::Core::trial_ptr( new Reveal::Core::trial_c() );

  trial->scenario_id = obj.getField( "scenario_id" ).String();
  trial->t = obj.getField( "t" ).Double();

  model_c::fetch( trial, obj );

  return true;
}
开发者ID:jacquelinekay,项目名称:reveal,代码行数:12,代码来源:trial.cpp


示例9: goodReplStatus

/** Good if one primary and rest secondaries and arbiters */
static bool goodReplStatus (mongo::BSONObj &info) {
	if (!info.getField("ok").trueValue()) return false;
	vector<mongo::BSONElement> ms = info.getField("members").Array();
	bool primary = false;
	for (unsigned i = 0; i < ms.size(); i++) {
		int state = ms[i].Obj().getIntField("state");
		if (state == 1) {primary = true; continue;}
		if (state != 2 && state != 7) return false;
	}
	return primary;
}
开发者ID:TonyGen,项目名称:mongoDeploy-cpp,代码行数:12,代码来源:mongoDeploy.cpp


示例10: fromjson

std::list<mongo::BSONObj> TransformComputable::compute_transform(mongo::BSONObj query, std::string collection)
{
  //get positions in other frames
  BSONObjBuilder query_other_frames;
  query_other_frames.appendElements(query.removeField("frame").removeField("allow_tf"));
  query_other_frames.append("frame", fromjson("{$exists:true}"));
  QResCursor cur = robot_memory_->query(query_other_frames.obj(), collection);

  //transform them is possible
  std::list<mongo::BSONObj> res;
  std::string target_frame = query.getField("frame").String();
  while(cur->more())
  {
    BSONObj pos = cur->next();
    if(pos.hasField("frame") && pos.hasField("translation") && pos.hasField("rotation"))
    {
      std::string src_frame = pos.getField("frame").String();
      Time now(0, 0);
      if(tf_->can_transform(target_frame.c_str(), src_frame.c_str(), now))
      {
        BSONObjBuilder res_pos;
        std::vector<BSONElement> src_trans = pos.getField("translation").Array();
        std::vector<BSONElement> src_rot = pos.getField("rotation").Array();
        fawkes::tf::Transform pose_tf(fawkes::tf::Quaternion(src_rot[0].Double(), src_rot[1].Double(), src_rot[2].Double(), src_rot[3].Double()),
          fawkes::tf::Vector3(src_trans[0].Double(), src_trans[1].Double(), src_trans[2].Double()));
        fawkes::tf::Stamped<fawkes::tf::Pose> src_stamped_pose(pose_tf, Time(0, 0), src_frame.c_str());
        fawkes::tf::Stamped<fawkes::tf::Pose> res_stamped_pose;
        tf_->transform_pose(target_frame.c_str(), src_stamped_pose, res_stamped_pose);

        res_pos.appendElements(pos.removeField("frame").removeField("translation").removeField("rotation").removeField("_id"));
        res_pos.append("frame", target_frame);
        res_pos.append("allow_tf", true);
        BSONArrayBuilder arrb_trans;
        arrb_trans.append(res_stamped_pose.getOrigin().x());
        arrb_trans.append(res_stamped_pose.getOrigin().y());
        arrb_trans.append(res_stamped_pose.getOrigin().z());
        res_pos.append("translation", arrb_trans.arr());
        BSONArrayBuilder arrb_rot;
        arrb_rot.append(res_stamped_pose.getRotation().x());
        arrb_rot.append(res_stamped_pose.getRotation().y());
        arrb_rot.append(res_stamped_pose.getRotation().z());
        arrb_rot.append(res_stamped_pose.getRotation().w());
        res_pos.append("rotation", arrb_rot.arr());
        res.push_back(res_pos.obj());
      }
//      else
//      {
//        logger_->log_info(name_, "Cant transform %s to %s", src_frame.c_str(), target_frame.c_str());
//      }
    }
  }
  return res;
}
开发者ID:timn,项目名称:fawkes,代码行数:53,代码来源:transform_computable.cpp


示例11: DoHost

void Processer::DoHost(const std::string& grid,const std::string& cluster,mongo::BSONObj& host)
{
	std::string host_id;
	std::cout << host << std::endl;
	if(host.hasField("host_ID") && host.hasField("heartbeat"))
	{
        //deal the record with host level
        //do not need to cut it off
        DBModules::iterator iter = db_modules_.begin();
        for(;iter!=db_modules_.end();++iter)
        {
            iter->handler(host.objdata(),host.objsize(),NULL);
        }

	//	host_id = host.getStringField("host_ID");
	//	std::vector<mongo::BSONElement> ele;
	//	host.elems(ele);
	//	for(int i=0;i<ele.size();i++)
	//	{
	//		if((!strcmp(ele[i].fieldName(),"host_ID")) || 
	//				(!strcmp(ele[i].fieldName(),"heartbeat")))
	//		{
	//			continue;
	//		}
	//		else
	//		{
	//			std::string ds_name = ele[i].fieldName();
	//			std::string path;
	//			if(grid!="")
	//				path = grid + '/' + cluster + '/' + host_id;
	//			else
	//				path = cluster + '/' + host_id;
	//			mongo::BSONObj obj = ele[i].wrap();
	//			std::cout << obj << std::endl;

	//			std::list<void(*)(const char*,int,const char*)>::iterator iter;
	//			iter = callback_[ds_name].begin();
	//			for(;iter!=callback_[ds_name].end();++iter)
	//			{
	//				(*iter)(obj.objdata(),obj.objsize(),path.c_str());
	//			}
	//		}
	//	}
	}
	else
	{
		std::stringstream oss;
		oss << "This data is illegal! Drop!!";
		LOG4CXX_WARN(log_,oss.str());
	}
}
开发者ID:keyboard-man,项目名称:kelp,代码行数:51,代码来源:processer.cpp


示例12: map

//-----------------------------------------------------------------------------
bool solution_c::map( Reveal::Core::solution_ptr& solution, mongo::BSONObj obj, Reveal::Core::solution_c::type_e type ) { 
  solution = Reveal::Core::solution_ptr( new Reveal::Core::solution_c( type ) );

  if( type == Reveal::Core::solution_c::CLIENT )
    solution->experiment_id = obj.getField( "experiment_id" ).String();
  solution->scenario_id = obj.getField( "scenario_id" ).String();
  solution->t = obj.getField( "t" ).Double();
  if( type == Reveal::Core::solution_c::CLIENT )
    solution->real_time = obj.getField( "real_time" ).Double();

  model_c::fetch( solution, obj );

  return true;
}
开发者ID:jacquelinekay,项目名称:reveal,代码行数:15,代码来源:solution.cpp


示例13: QUERY

std::string CjsonExporter::toCjson(const mongo::BSONObj &mongoChemObj)
{
  // Follow the database link and convert to CJSON.
  MongoDatabase *db = MongoDatabase::instance();
  if (!db)
    return "";

  mongo::BSONObj structure = mongoChemObj.getObjectField("3dStructure");
  if (!structure.hasField("$ref") || !structure.hasField("$id")
      || !structure.getField("$id").isSimpleType()) {
    return "";
  }
  std::auto_ptr<mongo::DBClientCursor> cursor =
      db->query(db->databaseName() + "." + structure.getStringField("$ref"),
                QUERY("_id" << structure.getField("$id").OID()), 1);
  mongo::BSONObj object;
  if (cursor->more())
    object = cursor->next();
  else
    return "";

  std::vector<std::string> toCopy;
  toCopy.push_back("name");
  toCopy.push_back("inchi");
  toCopy.push_back("formula");
  toCopy.push_back("properties");
  mongo::BSONObjBuilder builder;

  for (size_t i = 0; i < toCopy.size(); i++) {
    mongo::BSONElement field = mongoChemObj.getField(toCopy[i]);
    if (!field.eoo())
      builder.append(field);
  }
  toCopy.clear();
  toCopy.push_back("atoms");
  toCopy.push_back("bonds");
  for (size_t i = 0; i < toCopy.size(); i++) {
    mongo::BSONElement field = object.getField(toCopy[i]);
    if (!field.eoo())
      builder.append(field);
  }

  // Add the chemical JSON version field.
  builder.append("chemical json", 0);

  mongo::BSONObj obj = builder.obj();

  return obj.jsonString(mongo::Strict);
}
开发者ID:OpenChemistry,项目名称:mongochem,代码行数:49,代码来源:cjsonexporter.cpp


示例14: stitch_support_v1_update

    stitch_support_v1_update(mongo::ServiceContext::UniqueClient client,
                             mongo::BSONObj updateExpr,
                             mongo::BSONArray arrayFilters,
                             stitch_support_v1_matcher* matcher,
                             stitch_support_v1_collator* collator)
        : client(std::move(client)),
          opCtx(this->client->makeOperationContext()),
          updateExpr(updateExpr.getOwned()),
          arrayFilters(arrayFilters.getOwned()),
          matcher(matcher),
          updateDriver(new mongo::ExpressionContext(
              opCtx.get(), collator ? collator->collator.get() : nullptr)) {
        std::vector<mongo::BSONObj> arrayFilterVector;
        for (auto&& filter : this->arrayFilters) {
            arrayFilterVector.push_back(filter.embeddedObject());
        }
        this->parsedFilters = uassertStatusOK(mongo::ParsedUpdate::parseArrayFilters(
            arrayFilterVector, this->opCtx.get(), collator ? collator->collator.get() : nullptr));

        // Initializing the update as single-document allows document-replacement updates.
        bool multi = false;

        updateDriver.parse(this->updateExpr, parsedFilters, multi);

        uassert(51037,
                "Updates with a positional operator require a matcher object.",
                matcher || !updateDriver.needMatchDetails());
    }
开发者ID:hanumantmk,项目名称:mongo,代码行数:28,代码来源:stitch_support.cpp


示例15: _objBsonToJson

void CMetadata::_objBsonToJson(rapidjson::Value& json, mongo::BSONObj& bson)
{
	std::vector<mongo::BSONElement> values;
	bson.elems(values);
	for (uint i = 0; i<values.size(); ++i) {
		this->_fieldBsonToJson(json, values[i].fieldName(), bson);
	}
}
开发者ID:songjundev,项目名称:b,代码行数:8,代码来源:metadata.cpp


示例16: fromBson

void CMetadata::fromBson(mongo::BSONObj& bson)
{
	std::vector<mongo::BSONElement> elements;
	bson.elems(elements);
	for (uint i = 0; i<elements.size(); ++i) {
		this->_fieldBsonToJson(m_members, elements[i].fieldName(), bson);
	}
}
开发者ID:songjundev,项目名称:b,代码行数:8,代码来源:metadata.cpp


示例17: stitch_support_v1_matcher

 stitch_support_v1_matcher(mongo::ServiceContext::UniqueClient client,
                           const mongo::BSONObj& filterBSON,
                           stitch_support_v1_collator* collator)
     : client(std::move(client)),
       opCtx(this->client->makeOperationContext()),
       matcher(filterBSON.getOwned(),
               new mongo::ExpressionContext(opCtx.get(),
                                            collator ? collator->collator.get() : nullptr)){};
开发者ID:hanumantmk,项目名称:mongo,代码行数:8,代码来源:stitch_support.cpp


示例18: RepoNodeAbstract

repo::core::RepoNodeTexture::RepoNodeTexture(const mongo::BSONObj &obj)
    : RepoNodeAbstract(obj)
    , data(NULL)
{
	//
	// Width
	//
    if (obj.hasField(REPO_LABEL_WIDTH))
        width = obj.getField(REPO_LABEL_WIDTH).numberInt();

	//
	// Height
	//
    if (obj.hasField(REPO_LABEL_HEIGHT))
        height = obj.getField(REPO_LABEL_HEIGHT).numberInt();

	//
	// Format
	//
	if (obj.hasField(REPO_NODE_LABEL_EXTENSION)) {
		extension = obj.getField(REPO_NODE_LABEL_EXTENSION).str();
		name += "." + extension; // assimp needs full names with extension
	}

	//
	// Bit depth
	//
	//if (obj.hasField(REPO_NODE_LABEL_BIT_DEPTH))
	//	bitDepth = obj.getField(REPO_NODE_LABEL_BIT_DEPTH).numberInt();

	//
	// Data
	//
    if (obj.hasField(REPO_LABEL_DATA) &&
		obj.hasField(REPO_NODE_LABEL_DATA_BYTE_COUNT))
	{

        std::cerr << "Texture" << std::endl;
		data = new std::vector<char>();
		RepoTranscoderBSON::retrieve(
            obj.getField(REPO_LABEL_DATA),
			obj.getField(REPO_NODE_LABEL_DATA_BYTE_COUNT).numberInt(),
			data);
	}	
}
开发者ID:3drepo,项目名称:3drepocore,代码行数:45,代码来源:repo_node_texture.cpp


示例19: _ns

    MongoCollectionInfo::MongoCollectionInfo(mongo::BSONObj stats) : _ns(stats.getStringField("ns"))
    {
        // if "size" and "storageSize" are of type Int32 or Int64, they
        // will be converted to double by "numberDouble()" function.
        _sizeBytes = BsonUtils::getField<mongo::NumberDouble>(stats,"size");
        _storageSizeBytes = BsonUtils::getField<mongo::NumberDouble>(stats,"storageSize");

        // NumberLong because of mongodb can have very big collections
        _count = BsonUtils::getField<mongo::NumberLong>(stats,"count");
    }
开发者ID:davidau,项目名称:robomongo,代码行数:10,代码来源:MongoCollectionInfo.cpp


示例20: saveDocument

    void MongoClient::saveDocument(const mongo::BSONObj &obj, const MongoNamespace &ns)
    {
        mongo::BSONElement id = obj.getField("_id");
        mongo::BSONObjBuilder builder;
        builder.append(id);
        mongo::BSONObj bsonQuery = builder.obj();
        mongo::Query query(bsonQuery);

        _dbclient->update(ns.toString(), query, obj, true, false);
        checkLastErrorAndThrow(ns.databaseName());
    }
开发者ID:gsimsek,项目名称:robomongo,代码行数:11,代码来源:MongoClient.cpp



注:本文中的mongo::BSONObj类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ mongo::DBClientConnection类代码示例发布时间:2022-05-31
下一篇:
C++ mongo::BSONElement类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap