本文整理汇总了C++中UserList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ UserList::end方法的具体用法?C++ UserList::end怎么用?C++ UserList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserList
的用法示例。
在下文中一共展示了UserList::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
STATE StateNetwork::Update()
{
if(m_pNetworkControler && (m_pNetworkControler->GetNetworkState() == CLIENT))
{
m_pNetworkControler->ReceivePacket();
SmartPointer<PacketAddr> pAddr;
if((pAddr = m_pNetworkControler->GetPacket()) != NULL)
{
if( pAddr->m_Packet.Protocolid() == CONNECT_REQ)
{
UserInfomationPacketMaker pkMaker;
pkMaker.SetPacket(&pAddr->m_Packet);
UserList lst = pkMaker.OutPutUserInformation();
UserList::iterator iter;
for(iter = lst.begin(); iter != lst.end(); iter++)
{
//여기에다가 이미 존재하는 유져가 있을경우 AddUser를 호출하지 않게 만들어야 함...
m_pNetworkControler->AddUser((*iter));
delete (*iter);
}
lst.clear();
m_pNetworkControler->SetMyUserID(pAddr->m_Packet.ID());
return STATE_WAITINGROOM;
}
}
}
if(m_bSelectState)
return STATE_WAITINGROOM;
else
return STATE_NONE;
}
示例2: getUserList
//向客户端发送所有的用户信息
void getUserList(sockaddr_in sender)
{
int len = (int)clientList.size();
sendto(primarySock,(const char *)&len,sizeof(len),0,(SOCKADDR *)&sender,sizeof(sender));
for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator)
{
sendto(primarySock,(const char *)(*UserIterator),sizeof(stUserListNode),0,(SOCKADDR *)&sender,sizeof(sender));
}
}
示例3: GetUser
stUserListNode GetUser(char *username)
{
for(UserList::iterator UserIterator=ClientList.begin();
UserIterator!=ClientList.end();
++UserIterator)
{
if( strcmp( ((*UserIterator)->userName), username) == 0 )
return *(*UserIterator);
}
throw Exception("not find this user");
}
示例4: removeSelected
void UploadQueueFrame::removeSelected() {
int i = -1;
UserList RemoveUsers;
while((i = ctrlList.GetNextItem(i, LVNI_SELECTED)) != -1) {
// Ok let's cheat here, if you try to remove more users here is not working :(
RemoveUsers.push_back(((UploadQueueItem*)ctrlList.getItemData(i))->getUser());
}
for(auto i = RemoveUsers.begin(); i != RemoveUsers.end(); ++i) {
UploadManager::getInstance()->clearUserFiles(*i, true);
}
updateStatus();
}
示例5: GetUser
stUserListNode GetUser(char *userName)
{
for (auto ClientList_iter = ClientList.begin(); ClientList_iter != ClientList.end(); ++ClientList_iter)
{
if (strcmp((*ClientList_iter)->userName, userName) == 0)
return *(*ClientList_iter);
}
std::cout << "can not find user: " << userName << std::endl;
exit(0);
}
示例6: removeUser
void removeUser(char *name)
{
stUserListNode *removeNode;
removeNode = getUser(name);
clientList.remove(removeNode);
for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator)
{
stUserListNode *tmpNode = (stUserListNode *)(*UserIterator);
u_long ip = htonl(tmpNode->ip);
cout << "username :" << tmpNode->stUserName <<" ip:"<<inet_ntoa(*(in_addr *)&ip) <<" port:"<<tmpNode->port <<endl;
}
}
示例7: getUser
stUserListNode* getUser(char *name)
{
stUserListNode *node = NULL;
stUserListNode *removeNode = NULL;
for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator)
{
node = (stUserListNode *)(*UserIterator);
if(strcmp(node->stUserName,name) == 0)
{
removeNode = node;
break;
}
}
return removeNode;
}
示例8: clientLogin
/**
用户登陆时,记录用户信息
并输出所有登陆的用户信息
*/
void clientLogin(stMessage *message, sockaddr_in *sender)
{
cout << "client connected :" << message->message.loginMessage.stUserName <<endl;
stUserListNode *node = new stUserListNode;
strcpy(node->stUserName,message->message.loginMessage.stUserName);
node->ip = ntohl(sender->sin_addr.S_un.S_addr);
node->port = ntohs(sender->sin_port);
clientList.push_back(node);
cout << "total client is " << clientList.size() <<endl;
for(UserList::iterator UserIterator = clientList.begin(); UserIterator != clientList.end(); ++UserIterator)
{
stUserListNode *tmpNode = (stUserListNode *)(*UserIterator);
u_long ip = htonl(tmpNode->ip);
cout << "username :" << tmpNode->stUserName <<" ip:"<<inet_ntoa(*(in_addr *)&ip) <<" port:"<<tmpNode->port <<endl;
}
}
示例9: limitList
void EditUsers::limitList()
{
WContainerWidget* list = new WContainerWidget;
bindWidget("user-list",list);
typedef dbo::collection<dbo::ptr<User> > UserList;
dbo::Transaction t(session_);
UserList users = session_.find<User>().where("name like ?").bind("%"+limitEdit_->text()+"%").orderBy("name");
for (UserList::const_iterator i = users.begin(); i != users.end(); ++i) {
WText* t = new WText((*i)->name, list);
t->setStyleClass("link");
new WBreak(list);
t->clicked().connect(boost::bind(&EditUsers::onUserClicked, this, (*i).id()));
}
if (!users.size())
new WText(tr("no-users-found"),list);
}
示例10: processAllocStack
bool DeadObjectElimination::processAllocStack(AllocStackInst *ASI) {
// Trivial types don't have destructors. Let's try to zap this AllocStackInst.
if (!ASI->getElementType().isTrivial(ASI->getModule()))
return false;
UserList UsersToRemove;
if (hasUnremovableUsers(ASI, UsersToRemove)) {
DEBUG(llvm::dbgs() << " Found a use that cannot be zapped...\n");
return false;
}
// Remove the AllocRef and all of its users.
removeInstructions(
ArrayRef<SILInstruction*>(UsersToRemove.begin(), UsersToRemove.end()));
DEBUG(llvm::dbgs() << " Success! Eliminating alloc_stack.\n");
++DeadAllocStackEliminated;
return true;
}
示例11: processAllocRef
bool DeadObjectElimination::processAllocRef(AllocRefInst *ARI) {
// Ok, we have an alloc_ref. Check the cache to see if we have already
// computed the destructor behavior for its SILType.
bool HasSideEffects;
SILType Type = ARI->getType();
auto CacheSearchResult = DestructorAnalysisCache.find(Type);
if (CacheSearchResult != DestructorAnalysisCache.end()) {
// Ok we found a value in the cache.
HasSideEffects = CacheSearchResult->second;
} else {
// We did not find a value in the cache for our destructor. Analyze the
// destructor to make sure it has no side effects. For now this only
// supports alloc_ref of classes so any alloc_ref with a reference type
// that is not a class this will return false for. Once we have analyzed
// it, set Behavior to that value and insert the value into the Cache.
//
// TODO: We should be able to handle destructors that do nothing but release
// members of the object.
HasSideEffects = doesDestructorHaveSideEffects(ARI);
DestructorAnalysisCache[Type] = HasSideEffects;
}
if (HasSideEffects) {
DEBUG(llvm::dbgs() << " Destructor had side effects. \n");
return false;
}
// Our destructor has no side effects, so if we can prove that no loads
// escape, then we can completely remove the use graph of this alloc_ref.
UserList UsersToRemove;
if (hasUnremovableUsers(ARI, UsersToRemove)) {
DEBUG(llvm::dbgs() << " Found a use that cannot be zapped...\n");
return false;
}
// Remove the AllocRef and all of its users.
removeInstructions(
ArrayRef<SILInstruction*>(UsersToRemove.begin(), UsersToRemove.end()));
DEBUG(llvm::dbgs() << " Success! Eliminating alloc_ref.\n");
++DeadAllocRefEliminated;
return true;
}
示例12: onRemove
LRESULT UploadQueueFrame::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
if(usingUserMenu) {
UserPtr User = getSelectedUser();
if(User) {
UploadManager::getInstance()->clearUserFiles(User);
}
} else {
int i = -1;
UserList RemoveUsers;
while((i = ctrlList.GetNextItem(i, LVNI_SELECTED)) != -1) {
RemoveUsers.push_back(((UploadQueueItem*)ctrlList.getItemData(i))->getUser());
}
for(UserList::const_iterator i = RemoveUsers.begin(); i != RemoveUsers.end(); ++i) {
UploadManager::getInstance()->clearUserFiles(*i);
}
}
updateStatus();
return 0;
}
示例13: LimitList
/* ****************************************************************************
* Limit List
*/
void EditUsers::LimitList()
{
Wt::WContainerWidget* list = new Wt::WContainerWidget;
bindWidget("user-list",list);
typedef Wt::Dbo::collection<Wt::Dbo::ptr<User> > UserList;
Wt::Dbo::Transaction t(session_);
UserList users = session_.find<User>().where("name like ?").bind("%"+limitEdit_->text()+"%").orderBy("name");
Wt::WSignalMapper<Wt::Dbo::dbo_traits<User>::IdType >* userLinkMap = new Wt::WSignalMapper<Wt::Dbo::dbo_traits<User>::IdType >(this);
userLinkMap->mapped().connect(this,&EditUsers::OnUserClicked);
for (UserList::const_iterator i = users.begin(); i != users.end(); ++i)
{
Wt::WText* t = new Wt::WText((*i)->name, list);
t->setStyleClass("link");
new Wt::WBreak(list);
userLinkMap->mapConnect(t->clicked(), (*i).id());
}
if (!users.size())
{
new Wt::WText(tr("no-users-found"),list);
}
} // end void EditUsers::LimitList
示例14: main
int main(int argc, char* argv[])
{
try{
InitWinSock();
SOCKET PrimaryUDP;
PrimaryUDP = mksock(SOCK_DGRAM);
sockaddr_in local;
local.sin_family=AF_INET;
local.sin_port= htons(SERVER_PORT);
local.sin_addr.s_addr = htonl(INADDR_ANY);
int nResult=bind(PrimaryUDP,(sockaddr*)&local,sizeof(sockaddr));
if(nResult==SOCKET_ERROR)
throw Exception("bind error");
sockaddr_in sender;
stMessage recvbuf;
memset(&recvbuf,0,sizeof(stMessage));
// 开始主循环.
// 主循环负责下面几件事情:
// 一:读取客户端登陆和登出消息,记录客户列表
// 二:转发客户p2p请求
for(;;)
{
int dwSender = sizeof(sender);
int ret = recvfrom(PrimaryUDP, (char *)&recvbuf, sizeof(stMessage), 0, (sockaddr *)&sender, &dwSender);
if(ret <= 0)
{
printf("recv error");
continue;
}
else
{
int messageType = recvbuf.iMessageType;
switch(messageType){
case LOGIN:
{
// 将这个用户的信息记录到用户列表中
printf("has a user login : %s\n", recvbuf.message.loginmember.userName);
stUserListNode *currentuser = new stUserListNode();
strcpy(currentuser->userName, recvbuf.message.loginmember.userName);
currentuser->ip = ntohl(sender.sin_addr.S_un.S_addr);
currentuser->port = ntohs(sender.sin_port);
ClientList.push_back(currentuser);
// 发送已经登陆的客户信息
int nodecount = (int)ClientList.size();
sendto(PrimaryUDP, (const char*)&nodecount, sizeof(int), 0, (const sockaddr*)&sender, sizeof(sender));
for(UserList::iterator UserIterator=ClientList.begin();
UserIterator!=ClientList.end();
++UserIterator)
{
sendto(PrimaryUDP, (const char*)(*UserIterator), sizeof(stUserListNode), 0, (const sockaddr*)&sender, sizeof(sender));
}
break;
}
case LOGOUT:
{
// 将此客户信息删除
printf("has a user logout : %s\n", recvbuf.message.logoutmember.userName);
UserList::iterator removeiterator = NULL;
for(UserList::iterator UserIterator=ClientList.begin();
UserIterator!=ClientList.end();
++UserIterator)
{
if( strcmp( ((*UserIterator)->userName), recvbuf.message.logoutmember.userName) == 0 )
{
removeiterator = UserIterator;
break;
}
}
if(removeiterator != NULL)
ClientList.remove(*removeiterator);
break;
}
case P2PTRANS:
{
// 某个客户希望服务端向另外一个客户发送一个打洞消息
printf("%s wants to p2p %s\n",inet_ntoa(sender.sin_addr),recvbuf.message.translatemessage.userName);
stUserListNode node = GetUser(recvbuf.message.translatemessage.userName);
sockaddr_in remote;
remote.sin_family=AF_INET;
remote.sin_port= htons(node.port);
remote.sin_addr.s_addr = htonl(node.ip);
in_addr tmp;
tmp.S_un.S_addr = htonl(node.ip);
printf("the address is %s,and port is %d\n",inet_ntoa(tmp), node.port);
stP2PMessage transMessage;
transMessage.iMessageType = P2PSOMEONEWANTTOCALLYOU;
transMessage.iStringLen = ntohl(sender.sin_addr.S_un.S_addr);
transMessage.Port = ntohs(sender.sin_port);
sendto(PrimaryUDP,(const char*)&transMessage, sizeof(transMessage), 0, (const sockaddr *)&remote, sizeof(remote));
//.........这里部分代码省略.........
示例15: runDCOP
/**
* Do the actual DCOP call
*/
int runDCOP(KStringList args, UserList users, Session session, const QString sessionName, bool readStdin, bool updateUserTime)
{
bool DCOPrefmode = false;
QCString app;
QCString objid;
QCString function;
KStringList params;
DCOPClient *client = 0L;
int retval = 0;
if(!args.isEmpty() && args[0].find("DCOPRef(") == 0)
{
int delimPos = args[0].findRev(',');
if(delimPos == -1)
{
cerr_ << "Error: '" << args[0] << "' is not a valid DCOP reference." << endl;
exit(-1);
}
app = args[0].mid(8, delimPos - 8);
delimPos++;
objid = args[0].mid(delimPos, args[0].length() - delimPos - 1);
if(args.count() > 1)
function = args[1];
if(args.count() > 2)
{
params = args;
params.remove(params.begin());
params.remove(params.begin());
}
DCOPrefmode = true;
}
else
{
if(!args.isEmpty())
app = args[0];
if(args.count() > 1)
objid = args[1];
if(args.count() > 2)
function = args[2];
if(args.count() > 3)
{
params = args;
params.remove(params.begin());
params.remove(params.begin());
params.remove(params.begin());
}
}
bool firstRun = true;
UserList::Iterator it;
QStringList sessions;
bool presetDCOPServer = false;
// char *dcopStr = 0L;
QString dcopServer;
for(it = users.begin(); it != users.end() || firstRun; ++it)
{
firstRun = false;
// cout_ << "Iterating '" << it.key() << "'" << endl;
if(session == QuerySessions)
{
QStringList sessions = dcopSessionList(it.key(), it.data());
if(sessions.isEmpty())
{
if(users.count() <= 1)
{
cout_ << "No active sessions";
if(!(*it).isEmpty())
cout_ << " for user " << *it;
cout_ << endl;
}
}
else
{
cout_ << "Active sessions ";
if(!(*it).isEmpty())
cout_ << "for user " << *it << " ";
cout_ << ":" << endl;
QStringList::Iterator sIt = sessions.begin();
for(; sIt != sessions.end(); ++sIt)
cout_ << " " << *sIt << endl;
cout_ << endl;
}
continue;
}
if(getenv("DCOPSERVER"))
{
sessions.append(getenv("DCOPSERVER"));
presetDCOPServer = true;
}
if(users.count() > 1 || (users.count() == 1 && (getenv("DCOPSERVER") == 0 /*&& getenv( "DISPLAY" ) == 0*/)))
{
//.........这里部分代码省略.........