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


C++ StoreQueryResult::end方法代码示例

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


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

示例1: ipFind

// Find users with <ip>
vector<size_t> ipFind( database *database, string IP_ ) {
    socketTCP		socket("0.0.0.0");
    string			domain, ip, ipTmp;
	vector<size_t>	members;
	size_t			pos;
    // Resolve domain/ip
    ip      = socket.hostnameLookup( IP_ );	
    domain  = socket.ipLookup( IP_ );	

	if(!ip.size()) {

		// Remove after *
		size_t	pos = IP_.find("*");
		if(pos != string::npos) {
			
			IP_ = IP_.substr(0, pos);
		}

		ip = IP_;
	}

	// Get a list of similar ips
	StoreQueryResult			IPs = database->ipFind( ip );
	StoreQueryResult::iterator	ipIT;
	Row							IPRow;

	if( !IPs.size() )
		IPs = database->ipFind( domain );

	if(IPs.size() ) {

		// Add each matching member to the vector
		for( ipIT = IPs.begin(); ipIT != IPs.end(); ipIT++ ) {
			IPRow = *ipIT;
			members.push_back( (size_t) IPRow["memberID"] );
		}
		return members;
	}

	// Now get all IPs, resolve them all and try and match

	IPs = database->ipsRead(0);
	for( ipIT = IPs.begin(); ipIT != IPs.end(); ipIT++ ) {
		IPRow = *ipIT;
		
		ipTmp = (string) IPRow["ip"];
		if( (pos = ipTmp.find("*")) != string::npos) {
			ipTmp = ipTmp.substr(0, pos-1);
			if( ip.find( ipTmp) != string::npos )
				members.push_back( (size_t) IPRow["memberID"] );
		}

		ipTmp     = socket.hostnameLookup( ipTmp );

		if( ip == ipTmp )
			members.push_back( (size_t) IPRow["memberID"] );
	}

	return members;
}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:61,代码来源:stdafx.cpp

示例2: removeFolderChildren

// Recursive Function
void _ftpEntry::removeFolderChildren( size_t folderID ) {
    Connection                     *sqlConnect = dbConnect();
    bool							isDone						= false;
	Query							serverQuery					= sqlConnect->query();
	StoreQueryResult				serverResults;
	StoreQueryResult::iterator		storeQueryIT;
    size_t                          ID;

    // Find all folders that parent us
    serverQuery << "select * from ServerFolders where parentID = "      << quote << folderID;
    serverQuery.execute();

    // 
    for(storeQueryIT = serverResults.begin(); storeQueryIT != serverResults.end(); storeQueryIT++ ) {
        
        // Remove all children from this parent
        ID = (size_t) (*storeQueryIT)["folderID"];
        removeFolderChildren( ID );
        
        // Now remove the parent
        serverQuery.str("");
	    serverQuery << "delete from ServerFolders where folderID = "	<< quote << ID;
        serverQuery.execute();
    }

    delete sqlConnect;
}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:28,代码来源:ftpEntry.cpp

示例3:

int
run()
{
	c.connect("crowdify", "localhost", "root", "root");


	create_test_data();

	stringstream qs;
	qs.clear();
	qs.str(string());
	qs << "SELECT * FROM clients;";
	Query q = c.query(qs.str());

	StoreQueryResult r = q.store();
	StoreQueryResult::iterator it;
	
	struct sockaddr_in sin;
	char *username, *password;
	for (it = r.begin(); it != r.end(); it++) {
		Row r = *it;
		run_client(r[0]);
	}

	print_query("select * from blocks;");
	print_query("select * from files;");
	print_query("select * from clients;");
	print_query("select * from filestoblocks;");
	print_query("select * from directoriestofiles;");
	print_query("select * from clientstodirectories;");

	return 0;
}
开发者ID:mffigueroa,项目名称:crowdify,代码行数:33,代码来源:main.cpp

示例4: ipValidate

bool ipValidate( database *database, string IP, size_t memberID ) {
    socketTCP    socket("0.0.0.0");
    string       domain;

    // Resolve domain/ip
    IP      = socket.hostnameLookup(IP);		// Current Connect Client IP
    domain  = socket.ipLookup( IP );			// Resolve the clients IP

    // Get any IP/Host matches for this member's ID / Connected IP/Domain
    StoreQueryResult    IPs        = database->ipsRead( memberID, IP );
    StoreQueryResult    Domains    = database->ipsRead( memberID, domain );

    // Did we find any?
    if(!IPs.empty())
        return true;

    if(!Domains.empty())
        return true;

	if(!IP.size())
		return false;

    // Nope, so we need to get all IPs/Domains for this user from the database
    // Remove all wildcards and check the domain for matches
    Domains = database->ipsRead( memberID );
 
    StoreQueryResult::iterator   addressIT;
    string                       testName;
    string                       resolvedIP;
    string::iterator             sIT;
    Row                          row;

    for( addressIT = Domains.begin(); addressIT != Domains.end(); addressIT++ ) {
        row = *addressIT;

        // Get an address to test
        testName = (string) row["ip"];   

        // Resolve the name from the database, and try it against the connected IP
        resolvedIP = socket.hostnameLookup( testName );
		
        if( ! IP.compare( resolvedIP ) )
            return true;

        // Remove wildcards
        sIT = remove( testName.begin(), testName.end(), '*' );
        if(sIT != testName.end())
            testName.erase(sIT);

        // Check against the connected IP
        if( IP.find( testName ) != string::npos )
            return true;

        // Check against the connected domain name
        if( domain.find( testName ) != string::npos )
            return true;
    }

    return false;
}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:60,代码来源:stdafx.cpp

示例5: actionMIA

void IRCBot::actionMIA( ircChannel pChannel, irc_reply_data *hostd, string pParameters ) {
	size_t			count = 1;
	size_t			lastOnline;
	bool			active, showAll = false;

	if( pParameters == "all" )
		showAll = true;

	StoreQueryResult			members =	_db->membersReadSeen( true );
	StoreQueryResult::iterator	memberIT;
	Row							member;

	for(memberIT = members.begin(); memberIT != members.end(); memberIT++ ) {
		stringstream		irc;
		
		member = *memberIT;

		active = (bool) member["active"];
		if( !showAll && !active )
			continue;

		if( _smokingman->thepipeGet()->userOnline( ((size_t) member["memberID"] ) ) != userOFFLINE )
			continue;

		lastOnline = (size_t) member["lastOnline"];
		irc << count << ". " << ((string) member["nameUser"]) << " : " << timeCalc( time(0) - lastOnline );
		speak( "LastOn", irc, pChannel );

		++count;
	}

}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:32,代码来源:IRCBot.cpp

示例6: Order

/**
   @brief Return the list of all orders of a given user
 
   @param[in] pp    An instance of User
 
   @return    A vector of Order
 */
vector<Order *> & Order::ordersForUser(User & pp)
{
    vector<Order *> *orders = new vector<Order *>;
    
    // get an instance of the database
    Database& db = Database::instance();
    
    try {
        // ask Database for a valid connection to mySQL
        Connection *conn = db.getConnection();
        
        // obtain an instance of mysqlpp::Query and init it
        Query q = conn->query();
        q << "SELECT * FROM orders WHERE uid = " << pp.uniqueID()
          << " ORDER BY oid, date";
        
        StoreQueryResult res = q.store();
        if (!res.empty()) {
            orders->reserve(res.num_rows());
            StoreQueryResult::const_iterator it;

            for (it = res.begin(); it != res.end(); it++){
                Row row = *it;
                orders->push_back(new Order(row));
            }
        }
    } catch (std::exception &e) {
        cerr << "an error occurred: " << e.what() << endl;
    }
    
    return *orders;
}
开发者ID:unixo,项目名称:SENG,代码行数:39,代码来源:Order.cpp

示例7: products

/**
   @brief Returns the list of products (and requested quantity) of an order
 
   @return    A std::map where the key is product ID and the value the quantity
 */
map<int, int>& Order::products()
{
    map<int, int> *prd = NULL;
    
    // get an instance of the database
    Database& db = Database::instance();
    
    try {
        // ask Database for a valid connection to mySQL
        Connection *conn = db.getConnection();
        
        // obtain an instance of mysqlpp::Query and init it
        Query q = conn->query();
        q << "SELECT * FROM order_details WHERE oid = "
        << valueForKey(KEY_ORD_OID);            
        
        StoreQueryResult res = q.store();
        if (!res.empty()) {
            prd = new map<int, int>;
            StoreQueryResult::const_iterator it;
            
            for (it = res.begin(); it != res.end(); it++){
                Row row = *it;
                int key = atoi(row["pid"]);
                int qty = atoi(row["qty"]);
                (*prd)[key] = qty;
            }
        }
    } catch (std::exception &e) {
        cerr << "an error occurred: " << e.what() << endl;
    }
    
    return *prd;
}
开发者ID:unixo,项目名称:SENG,代码行数:39,代码来源:Order.cpp

示例8: checkDBFolders

void _ftpEntry::checkDBFolders() {
	bool							isDone						= false;
	Query							serverQuery					= _sqlConnection->query();
	StoreQueryResult				serverResults;
	StoreQueryResult::iterator		storeQueryIT;
	vector<_ftpEntry*>::iterator	entryIT;

	// Nothing to do here...
	if( directorys.empty() )
		return;

	// Get a list of all the directorys that we parent
	serverQuery << "select * from ServerFolders where serverID = " << quote << _serverID;
	serverQuery << " AND parentID = "	<< quote << _folderID;

	// Do the query
	serverResults	= serverQuery.store();

	// None?
	if( !serverResults.size() )
		return;

	// We now have to check each DB result, against the results in directorys vector
	for(storeQueryIT = serverResults.begin(); storeQueryIT != serverResults.end(); storeQueryIT++ , isDone = false) {

		for( entryIT = directorys.begin(); entryIT != directorys.end(); entryIT++) {

			// Does this directory still exist?
			if((*entryIT)->getName() == (string) (*storeQueryIT)["name"]) {
				isDone = true;	// Yes it exists
				break;
			}	// parentID check
		}	// entryIT

		// Deleted?
		if(!isDone) {
			// Yes, remove the entry from the DB

            removeFolderChildren( (size_t) (*storeQueryIT)["folderID"] );
			serverQuery.str("");
			serverQuery << "delete from ServerFolders where folderID = "	<< quote << (*storeQueryIT)["folderID"];

			// bye bye :)
			serverQuery.execute();

		}	// !isDone

	}	// storeQueryIT

}	// checkDBFolders
开发者ID:segrax,项目名称:KiLLARMY,代码行数:50,代码来源:ftpEntry.cpp

示例9: testPrepare

bool IRCBot::testPrepare() {
	StoreQueryResult			 ircBots = _db->ircBotReadAll();
	StoreQueryResult::iterator	 ircIT;
	stringstream				 ircs;
	size_t						 sleepTime = 500, count = 0;
	Row							 irc, ircBot;
	_ircMii						*botMii;

	if(ircBots.empty())
		return false;

	// loop through and start each server test
	for( ircIT = ircBots.begin(); ircIT != ircBots.end(); ++ircIT, ++count ) {
		
		ircBot = *ircIT;
		irc = _db->ircRead( (size_t) ircBot["ircID"] );
		if(irc.empty())
			return false;

		botMii = _Miis->ircMiiLoad( (string) irc["nick"] );
		if(botMii) {
			botMii->ircBotRowLoad();
			botMii->silentSet();
			
			botTestAdd( botMii, 0 );
		} else {
			stringstream ircs;
			ircs << "Bot " << ( (string) irc["nick"] ) << " is not online.";
			speak("Test", ircs, _testChannel);
		}

		Sleep(sleepTime);

		// Every 4, sleep triple time
		if(count == 4) {
			Sleep(sleepTime*2);
			count=0;
		}
	}

	// Nothing to do?
	if(_testMiis.empty()) {
		stringstream ircs;
		ircs << "No bots to test.";
		speak("Test", ircs, _testChannel);
		return false;
	}

	return true;
}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:50,代码来源:IRCBot.cpp

示例10: print_query

int print_query(const char *q) {
	Query q2 = c.query(q);

	StoreQueryResult r = q2.store();
	StoreQueryResult::iterator it;
	
	for (it = r.begin(); it != r.end(); it++) {
		Row r = *it;
		cout << " " << r[0] << endl;
	}
	cout << endl;

	return 0;
}
开发者ID:mffigueroa,项目名称:crowdify,代码行数:14,代码来源:main.cpp

示例11: actionTotalTime

void IRCBot::actionTotalTime( ircChannel pChannel, irc_reply_data *hostd, string pParameters ) {
	size_t			count = 1;
	time_t			timeOnline;
	bool			active, showAll = false;

	if( pParameters == "all" )
		showAll = true;

	StoreQueryResult			members =	_db->memberTimeOnGet( false );
	StoreQueryResult::iterator	memberIT;
	Row							member;

	for(memberIT = members.begin(); memberIT != members.end(); memberIT++ ) {
		
		member = *memberIT;

		active = (bool) member["active"];
		if( !showAll && !active )
			continue;

		timeOnline = (time_t) member["timeOnline"];

		/*
		if( _smokingman->thepipeGet()->userOnline( ((size_t) member["memberID"] ) ) != userOFFLINE ) {
			client *user = _smokingman->thepipeGet()->userClient(((size_t) member["memberID"] ) );

			time_t addTime = time(0) - user->connectedTimeGet();

			timeOnline += addTime;
		}*/

		if(timeOnline > 0) {
			stringstream		irc;
			irc << count << ". " << ((string) member["nameUser"]) << " : " << timeCalc( timeOnline );
			speak( "TotalTime", irc, pChannel );

			++count;
		}
	}

}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:41,代码来源:IRCBot.cpp

示例12: items

static vector<Item> handle_get_inventory(const StoreQueryResult& result)
{
	typedef mysqlpp::StoreQueryResult::const_iterator ResultIt;

	vector<Item> items(16);

	for(ResultIt i = result.begin(), end = result.end(); i != end; ++i)
	{
		const Row& row = *i;
		Item item;

		item.cid = row["id"];
		item.itemid = row["itemid"];

		if(row["rental"])
		{
			// TODO(Jacob): Handle item.RentHour
		}

		items.push_back(item);
	}

	return items;
}
开发者ID:ElMoustache,项目名称:GoGo,代码行数:24,代码来源:GetInventory.cpp

示例13: actionOnline

void IRCBot::actionOnline( ircChannel pChannel, irc_reply_data *hostd, string pParameters ) {
	vector<size_t>					 doneMembers;
	vector<time_t>					 times;
	vector<time_t>::iterator		 timesIT;
	stringstream					 irc;

	StoreQueryResult				 members = _db->membersRead(0);
	StoreQueryResult::iterator		 memberIT;
	Row								 member;
	
	time_t							 timeOnline;
	client							*userClient = 0;
	size_t							 memberID = 0;

	for(memberIT = members.begin(); memberIT != members.end(); memberIT++ ) {
	
		member = *memberIT;
		memberID = (size_t) member["memberID"];

		//  Get the client
		userClient = _smokingman->thepipeGet()->userClient( memberID );
		if(!userClient)
			continue;
		// Calc the time online
		timeOnline = userClient->connectedTimeGet();

		times.push_back( timeOnline );
		userClient = 0;
	}

	// Sort the times
	sort( times.begin(), times.end() );

	size_t							 count = 1;

	// Output the result
	for(timesIT = times.begin(); timesIT != times.end(); timesIT++ ) {
		timeOnline = *timesIT;

		for(memberIT = members.begin(); memberIT != members.end(); memberIT++ ) {
			member = *memberIT;
			memberID = (size_t) member["memberID"];

			userClient = _smokingman->thepipeGet()->userClient( memberID );
			if(!userClient)
				continue;

			if( find( doneMembers.begin(), doneMembers.end(), memberID ) != doneMembers.end() )
				continue;

			if( timeOnline == userClient->connectedTimeGet() ) {
				doneMembers.push_back( memberID );
				irc << count << ". " << userClient->moduleGet<moduleAuth>(modAUTH)->memberUserNameGet() << " : " << timeCalc( time(0) - timeOnline );
				speak( "Online", irc, pChannel );
				irc.str("");
				++count;
				break;
			}
				
		}
	}
}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:62,代码来源:IRCBot.cpp

示例14: actionSearch

void IRCBot::actionSearch( ircChannel pChannel, irc_reply_data *hostd, string pParameters ) {
	StoreQueryResult				 serverResults;
	StoreQueryResult::iterator		 resultIT;
	bool							 modeFiles = false;
	stringstream					 irc;
	string							 serverShort;
	if(readServerName(pParameters.substr(0, pParameters.find(" "))) != 0)
		serverShort = parameterGet(pParameters);

	string							 searchTerm = parameterGet(pParameters);
	string							 resultName, next;

	Row								 server, search, folder;

	size_t searchServerID;
	size_t serverID	= readServerName( serverShort );
	size_t folderID = 0, count = 0, parentID = 0;

	searchServerID = serverID;
	if(!searchTerm.size()) {
		speak("search", "syntax wrong, usage", pChannel);
		speak("search", "folder: !search <term>", pChannel);
		speak("search", "files:  !search <term> file", pChannel);
		speak("search", "serverSpecific: !search <server shortname> <term>", pChannel);

		return;
	}

	while(pParameters.size()) {
		next = parameterGet(pParameters);

		if(next[0] == 'f' && pParameters.size() == 0) {
			modeFiles = true;
		} else {
			searchTerm.append(" ");
			searchTerm.append(next);
		}
	}

	if(modeFiles) {
		serverResults = _db->searchFiles( searchTerm );
	} else 
		serverResults = _db->searchFolders( searchTerm, readServerName(serverShort.c_str()) );
	
	if(!serverResults.size()) {
		irc << "No results for query '" << searchTerm << "'";
		speak("search", irc, pChannel);
		return;
	}

	// Have results to parse
	for( resultIT = serverResults.begin(); resultIT != serverResults.end(); resultIT++ ) {
		irc.str("");
		search = *resultIT;

		if(count > 10)
			break;

		if(modeFiles) {
			folderID	= (size_t) search["folderID"];
			folder		= _db->folderRead( folderID );

			serverID = (size_t) folder["serverID"];
			if(searchServerID && serverID != searchServerID)
				continue;

			server = _db->serverRead( serverID );
			serverShort = (string) server["nameShort"];
			resultName  = (string) search["name"];

			irc << "[" << serverShort << "]: " << resultName << " in ";

			parentID = (size_t) folder["parentID"];


		} else {
			serverID = (size_t) search["serverID"];
			server =  _db->serverRead( serverID );
			serverShort = (string) server["nameShort"];
			resultName = (string) search["name"];
			parentID = (size_t) search["parentID"];

			folder = search;
			irc << "[" << serverShort << "]: " << resultName << " in ";
		}

		if(parentID) {
			search = _db->folderRead( parentID );
				if(!search.empty())
					if((string) search["name"] != "/")
						irc << ((string) search["name"]);

		}
		if(modeFiles)
			irc << "/" << ((string) folder["name"]);

		speak("search", irc, pChannel);
		count++;
	}

//.........这里部分代码省略.........
开发者ID:segrax,项目名称:KiLLARMY,代码行数:101,代码来源:IRCBot.cpp

示例15: strdup

int
run_client(int cid)
{
	stringstream qs;
	struct sockaddr_in sin;
	char *username, *password;
	StoreQueryResult r;
	StoreQueryResult::iterator it;
	try {
		qs << "SELECT * FROM clients WHERE cid=" << cid << ";";
		Query q = c.query(qs.str());

		r = q.store();
		
		for (it = r.begin(); it != r.end(); it++) {
			Row r = *it;
			cout << " " << r[0] << " " << r[1] << " " << r[2] << " " << r[3] << endl;
			sin.sin_addr.s_addr = r[1];
			username = strdup(r[2]);
			password = strdup(r[3]);
		}
	}
	catch (const mysqlpp::BadQuery& er) {
		cerr << "no clients found: " << er.what() << endl;
		return 1;
	}

	libssh2_init(0);

	int sock = socket(AF_INET, SOCK_STREAM, 0);

	sin.sin_family = AF_INET;
	sin.sin_port = htons(22);

	if (connect(sock, (struct sockaddr*)(&sin), sizeof(struct sockaddr_in)) != 0) {
		cerr << "failed to connect" << endl;
		return 1;
	}

	ssh_session = libssh2_session_init();

	libssh2_session_set_blocking(ssh_session, 1);

	if (libssh2_session_handshake(ssh_session, sock)) {
		cerr << "handshake failed" << endl;
		return 1;
	}

	if (libssh2_userauth_password(ssh_session, username, password)) {
		cerr << "couldn't authenticate user" << endl;
		return 1;
	}

	Query q = c.query("CREATE TABLE IF NOT EXISTS directories (did INT AUTO_INCREMENT PRIMARY KEY NOT NULL, path VARCHAR(4096), uid SMALLINT, gid SMALLINT, perm SMALLINT);");
	q.execute();

	q = c.query("CREATE TABLE IF NOT EXISTS clientstodirectories (cid INT, did INT);");
	q.execute();


	try {
		qs.clear();
		qs.str(string());
		qs << "SELECT * FROM clientstodirectories WHERE cid=" << cid << ";";
		cerr << qs.str() << endl;
		q = c.query(qs.str());
		
		r = q.store();

		for (it = r.begin(); it != r.end(); it++) {
			Row r = *it;
			ssh_ftw(r[1]);
		}
	}
	catch (const mysqlpp::BadQuery& er) {
		cerr << "no clients found: " << er.what() << endl;
		return 1;
	}

	libssh2_session_disconnect(ssh_session, "bye");

	libssh2_session_free(ssh_session);

	libssh2_exit();

	return 0;
}
开发者ID:mffigueroa,项目名称:crowdify,代码行数:87,代码来源:main.cpp


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