本文整理汇总了C++中user::Ptr::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::setTag方法的具体用法?C++ Ptr::setTag怎么用?C++ Ptr::setTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user::Ptr
的用法示例。
在下文中一共展示了Ptr::setTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onLine
//.........这里部分代码省略.........
updated(u);
}
}
}
} else if(cmd == "$MyINFO") {
string::size_type i, j;
i = 5;
j = param.find(' ', i);
if( (j == string::npos) || (j == i) )
return;
string nick = fromNmdc(param.substr(i, j-i));
i = j + 1;
User::Ptr u;
dcassert(nick.size() > 0);
{
Lock l(cs);
User::NickIter ni = users.find(nick);
if(ni == users.end()) {
u = users[nick] = ClientManager::getInstance()->getUser(nick, this);
} else {
u = ni->second;
}
}
j = param.find('$', i);
if(j == string::npos)
return;
string tmpDesc = Util::validateMessage(fromNmdc(param.substr(i, j-i)), true);
// Look for a tag...
if(tmpDesc.size() > 0 && tmpDesc[tmpDesc.size()-1] == '>') {
x = tmpDesc.rfind('<');
if(x != string::npos) {
// Hm, we have something...
u->setTag(tmpDesc.substr(x));
tmpDesc.erase(x);
} else {
u->setTag(Util::emptyString);
}
} else {
u->setTag(Util::emptyString);
}
u->setDescription(tmpDesc);
i = j + 3;
j = param.find('$', i);
if(j == string::npos)
return;
u->setConnection(fromNmdc(param.substr(i, j-i-1)));
i = j + 1;
j = param.find('$', i);
if(j == string::npos)
return;
u->setEmail(Util::validateMessage(fromNmdc(param.substr(i, j-i)), true));
i = j + 1;
j = param.find('$', i);
if(j == string::npos)
return;
u->setBytesShared(param.substr(i, j-i));
Speaker<NmdcHubListener>::fire(NmdcHubListener::MyInfo(), this, u);
} else if(cmd == "$Quit") {
if(!param.empty()) {
User::Ptr u;
{
Lock l(cs);
User::NickIter i = users.find(fromNmdc(param));
if(i == users.end()) {
示例2: handle
void AdcHub::handle(Command::INF, Command& c) throw() {
if(c.getFrom().isZero() || c.getParameters().empty())
return;
User::Ptr u = ClientManager::getInstance()->getUser(c.getFrom(), this, true);
int op = 0;
int reg = 0;
int norm = 0;
string ve;
int sl = 0;
for(StringIterC i = c.getParameters().begin(); i != c.getParameters().end(); ++i) {
if(i->length() < 2)
continue;
if(i->compare(0, 2, "NI") == 0) {
u->setNick(i->substr(2));
} else if(i->compare(0, 2, "HU") == 0) {
hub = u;
} else if(i->compare(0, 2, "DE") == 0) {
u->setDescription(i->substr(2));
} else if(i->compare(0, 2, "I4") == 0) {
u->setIp(i->substr(2));
} else if(i->compare(0, 2, "SS") == 0) {
u->setBytesShared(i->substr(2));
} else if(i->compare(0, 2, "VE") == 0) {
ve = i->substr(2);
} else if(i->compare(0, 2, "EM") == 0) {
u->setEmail(i->substr(2));
} else if(i->compare(0, 2, "OP") == 0) {
if(i->length() == 2) {
u->unsetFlag(User::OP);
} else {
u->setFlag(User::OP);
}
} else if(i->compare(0, 2, "HO") == 0) {
op = Util::toInt(i->substr(2));
} else if(i->compare(0, 2, "HR") == 0) {
reg = Util::toInt(i->substr(2));
} else if(i->compare(0, 2, "HN") == 0) {
norm = Util::toInt(i->substr(2));
} else if(i->compare(0, 2, "SL") == 0) {
sl = Util::toInt(i->substr(2));
} else if(i->compare(0, 2, "BO") == 0) {
if(i->length() == 2) {
u->unsetFlag(User::BOT);
} else {
u->setFlag(User::BOT);
}
} else if(i->compare(0, 2, "HI") == 0) {
if(i->length() == 2) {
u->unsetFlag(User::HIDDEN);
} else {
u->setFlag(User::HIDDEN);
}
} else if(i->compare(0, 2, "HU") == 0) {
if(i->length() == 2) {
u->unsetFlag(User::HUB);
} else {
u->setFlag(User::HUB);
}
}
}
if(!ve.empty()) {
if(ve.find(' ') != string::npos) {
ve.insert(ve.find(' ') + 1, "V:");
}
u->setTag("<" + ve + ",M:" + string(u->getIp().empty() ? "P" : "A") + ",H:" + Util::toString(norm) + "/" +
Util::toString(reg) + "/" + Util::toString(op) + ",S:" +
Util::toString(sl) + ">" );
}
if(u == getMe())
state = STATE_NORMAL;
fire(ClientListener::UserUpdated(), this, u);
}