本文整理汇总了C++中ModeHandler::GetTranslateType方法的典型用法代码示例。如果您正苦于以下问题:C++ ModeHandler::GetTranslateType方法的具体用法?C++ ModeHandler::GetTranslateType怎么用?C++ ModeHandler::GetTranslateType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModeHandler
的用法示例。
在下文中一共展示了ModeHandler::GetTranslateType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
//.........这里部分代码省略.........
bool adding = true;
char output_pm = '\0'; // current output state, '+' or '-'
unsigned int param_at = 2;
for (std::string::const_iterator letter = mode_sequence.begin(); letter != mode_sequence.end(); letter++)
{
unsigned char modechar = *letter;
if (modechar == '+' || modechar == '-')
{
adding = (modechar == '+');
continue;
}
ModeHandler *mh = this->FindMode(modechar, type);
if (!mh)
{
/* No mode handler? Unknown mode character then. */
user->WriteServ("%d %s %c :is unknown mode char to me", type == MODETYPE_CHANNEL ? 472 : 501, user->nick.c_str(), modechar);
continue;
}
std::string parameter;
int pcnt = mh->GetNumParams(adding);
if (pcnt && param_at == parameters.size())
{
/* No parameter, continue to the next mode */
mh->OnParameterMissing(user, targetuser, targetchannel);
continue;
}
else if (pcnt)
{
parameter = parameters[param_at++];
/* Make sure the user isn't trying to slip in an invalid parameter */
if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
continue;
if ((flags & MODE_MERGE) && targetchannel && targetchannel->IsModeSet(mh) && !mh->IsListMode())
{
std::string ours = targetchannel->GetModeParameter(mh);
if (!mh->ResolveModeConflict(parameter, ours, targetchannel))
/* we won the mode merge, don't apply this mode */
continue;
}
}
ModeAction ma = TryMode(user, targetuser, targetchannel, adding, modechar, parameter, SkipAccessChecks);
if (ma != MODEACTION_ALLOW)
continue;
char needed_pm = adding ? '+' : '-';
if (needed_pm != output_pm)
{
output_pm = needed_pm;
output_mode.append(1, output_pm);
}
output_mode.append(1, modechar);
if (pcnt)
{
output_parameters << " " << parameter;
LastParseParams.push_back(parameter);
LastParseTranslate.push_back(mh->GetTranslateType());
}
if ( (output_mode.length() + output_parameters.str().length() > 450)
|| (output_mode.length() > 100)
|| (LastParseParams.size() > ServerInstance->Config->Limits.MaxModes))
{
/* mode sequence is getting too long */
break;
}
}
LastParseParams[0] = output_mode;
if (!output_mode.empty())
{
LastParse = targetchannel ? targetchannel->name : targetuser->nick;
LastParse.append(" ");
LastParse.append(output_mode);
LastParse.append(output_parameters.str());
if (!(flags & MODE_LOCALONLY))
ServerInstance->PI->SendMode(user, targetuser, targetchannel, LastParseParams, LastParseTranslate);
if (targetchannel)
targetchannel->WriteChannel(user, "MODE " + LastParse);
else
targetuser->WriteFrom(user, "MODE " + LastParse);
FOREACH_MOD(OnMode, (user, targetuser, targetchannel, LastParseParams, LastParseTranslate));
}
else if (targetchannel && parameters.size() == 2)
{
/* Special case for displaying the list for listmodes,
* e.g. MODE #chan b, or MODE #chan +b without a parameter
*/
this->DisplayListModes(user, targetchannel, mode_sequence);
}
}