当前位置: 首页>>代码示例>>C++>>正文


C++ SharedPtr::documents方法代码示例

本文整理汇总了C++中poco::SharedPtr::documents方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr::documents方法的具体用法?C++ SharedPtr::documents怎么用?C++ SharedPtr::documents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在poco::SharedPtr的用法示例。


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

示例1: testCursorRequest

void MongoDBTest::testCursorRequest()
{
	Poco::MongoDB::Database db("team");
	Poco::SharedPtr<Poco::MongoDB::InsertRequest> insertRequest = db.createInsertRequest("numbers");
	for(int i = 0; i < 10000; ++i)
	{
		Document::Ptr doc = new Document();
		doc->add("number", i);
		insertRequest->documents().push_back(doc);
	}
	_mongo->sendRequest(*insertRequest);

	Poco::Int64 count = db.count(*_mongo, "numbers");
	assert(count == 10000);

	Poco::MongoDB::Cursor cursor("team", "numbers");

	int n = 0;
	Poco::MongoDB::ResponseMessage& response = cursor.next(*_mongo);
	while(1)
	{
		n += response.documents().size();
		if ( response.cursorID() == 0 )
			break;
		response = cursor.next(*_mongo);
	}
	assert(n == 10000);

	Poco::MongoDB::QueryRequest drop("team.$cmd");
	drop.setNumberToReturn(1);
	drop.selector().add("drop", std::string("numbers"));

	Poco::MongoDB::ResponseMessage responseDrop;
	_mongo->sendRequest(drop, responseDrop);
}
开发者ID:Kampbell,项目名称:poco,代码行数:35,代码来源:MongoDBTest.cpp

示例2: getLastErrorDoc

Poco::MongoDB::Document::Ptr Database::ensureIndex(Connection& connection, const std::string& collection, const std::string& indexName, Poco::MongoDB::Document::Ptr keys, bool unique, bool background, int version, int ttl)
{
	Poco::MongoDB::Document::Ptr index = new Poco::MongoDB::Document();
	index->add("ns", _dbname + ".players");
	index->add("name", indexName);
	index->add("key", keys);

	if ( version > 0 )
	{
		index->add("version", version);
	}

	if ( unique )
	{
		index->add("unique", true);
	}

	if ( background )
	{
		index->add("background", true);
	}

	if ( ttl > 0 )
	{
		index->add("expireAfterSeconds", ttl);
	}

	Poco::SharedPtr<Poco::MongoDB::InsertRequest> insertRequest = createInsertRequest("system.indexes");
	insertRequest->documents().push_back(index);
	connection.sendRequest(*insertRequest);

	insertRequest->documents().push_back(index);
	connection.sendRequest(*insertRequest);

	return getLastErrorDoc(connection);
}
开发者ID:Chingliu,项目名称:poco,代码行数:36,代码来源:Database.cpp

示例3: testCursorRequest

void MongoDBTest::testCursorRequest()
{
	if (!_connected)
	{
		std::cout << "Not connected, test skipped." << std::endl;
		return;
	}

	Poco::MongoDB::Database db("team");
	Poco::SharedPtr<Poco::MongoDB::InsertRequest> insertRequest = db.createInsertRequest("numbers");
	for(int i = 0; i < 10000; ++i)
	{
		Document::Ptr doc = new Document();
		doc->add("number", i);
		insertRequest->documents().push_back(doc);
	}
	_mongo.sendRequest(*insertRequest);

	double count = db.count(_mongo, "numbers");
	assert(count == 10000);

	Poco::MongoDB::Cursor cursor("team", "numbers");

	int n = 0;
	Poco::MongoDB::ResponseMessage& response = cursor.next(_mongo);
	while(1)
	{
		n += response.documents().size();
		if ( response.cursorID() == 0 )
			break;
		response = cursor.next(_mongo);
	}
	std::cout << "n= " << n << std::endl;
	assert(n == 10000);

	Poco::MongoDB::QueryRequest drop("team.$cmd");
	drop.setNumberToReturn(1);
	drop.selector().add("drop", std::string("numbers"));

	Poco::MongoDB::ResponseMessage responseDrop;
	_mongo.sendRequest(drop, responseDrop);

	if ( responseDrop.documents().size() > 0 )
	{
		std::cout << responseDrop.documents()[0]->toString(2) << std::endl;
	}
}
开发者ID:12307,项目名称:poco,代码行数:47,代码来源:MongoDBTest.cpp

示例4: sample1


//.........这里部分代码省略.........
		.add("firstname", "Marc")
		.add("birthyear", 1991);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Alba")
		.add("firstname", "Jordi")
		.add("birthyear", 1989);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Montoya")
		.add("firstname", "Martin")
		.add("birthyear", 1991);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Abidal")
		.add("firstname", "Eric")
		.add("birthyear", 1979);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Fontas")
		.add("firstname", "Andreu")
		.add("birthyear", 1989);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Messi")
		.add("firstname", "Lionel")
		.add("birthyear", 1987);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Puyol")
		.add("firstname", "Carles")
		.add("birthyear", 1978);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Piqué")
		.add("firstname", "Gerard")
		.add("birthyear", 1987);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Muniesa")
		.add("firstname", "Marc")
		.add("birthyear", 1992);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Fabrégas")
		.add("firstname", "Cesc")
		.add("birthyear", 1987);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Hernandez")
		.add("firstname", "Xavi")
		.add("birthyear", 1980);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Iniesta")
		.add("firstname", "Andres")
		.add("birthyear", 1984);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Alcantara")
		.add("firstname", "Thiago")
		.add("birthyear", 1991);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Dos Santos")
		.add("firstname", "Jonathan")
		.add("birthyear", 1990);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Mascherano")
		.add("firstname", "Javier")
		.add("birthyear", 1984);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Busquets")
		.add("firstname", "Sergio")
		.add("birthyear", 1988);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Adriano")
		.add("firstname", "")
		.add("birthyear", 1984);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Song")
		.add("firstname", "Alex")
		.add("birthyear", 1987);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Villa")
		.add("firstname", "David")
		.add("birthyear", 1981);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Sanchez")
		.add("firstname", "Alexis")
		.add("birthyear", 1988);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Pedro")
		.add("firstname", "")
		.add("birthyear", 1987);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Cuenca")
		.add("firstname", "Isaac")
		.add("birthyear", 1991);
	insertPlayerRequest->addNewDocument()
		.add("lastname", "Tello")
		.add("firstname", "Cristian")
		.add("birthyear", 1991);

	std::cout << insertPlayerRequest->documents().size() << std::endl;

	connection.sendRequest(*insertPlayerRequest);
	std::string lastError = db.getLastError(connection);
	if ( !lastError.empty() )
	{
		std::cout << "Last Error: " << db.getLastError(connection) << std::endl;
	}
}
开发者ID:12307,项目名称:poco,代码行数:101,代码来源:SQLToMongo.cpp


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