本文整理汇总了C++中CSmartPtr::HandleVar方法的典型用法代码示例。如果您正苦于以下问题:C++ CSmartPtr::HandleVar方法的具体用法?C++ CSmartPtr::HandleVar怎么用?C++ CSmartPtr::HandleVar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSmartPtr
的用法示例。
在下文中一共展示了CSmartPtr::HandleVar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetValue
CString CTemplate::GetValue(const CString& sArgs, bool bFromIf) {
CTemplateLoopContext* pContext = GetCurLoopContext();
CString sName = sArgs.Token(0);
CString sRest = sArgs.Token(1, true);
CString sRet;
while (sRest.Replace(" =", "=", "\"", "\"")) {}
while (sRest.Replace("= ", "=", "\"", "\"")) {}
VCString vArgs;
MCString msArgs;
//sRest.Split(" ", vArgs, false, "\"", "\"");
sRest.QuoteSplit(vArgs);
for (unsigned int a = 0; a < vArgs.size(); a++) {
const CString& sArg = vArgs[a];
msArgs[sArg.Token(0, false, "=").AsUpper()] = sArg.Token(1, true, "=");
}
/* We have no CConfig in ZNC land
* Hmm... Actually, we do have it now.
if (msArgs.find("CONFIG") != msArgs.end()) {
sRet = CConfig::GetValue(sName);
} else*/ if (msArgs.find("ROWS") != msArgs.end()) {
vector<CTemplate*>* pLoop = GetLoop(sName);
sRet = CString((pLoop) ? pLoop->size() : 0);
} else if (msArgs.find("TOP") == msArgs.end() && pContext) {
sRet = pContext->GetValue(sArgs, bFromIf);
if (!sRet.empty()) {
return sRet;
}
} else {
if (sName.Left(1) == "*") {
sName.LeftChomp(1);
MCString::iterator it = find(sName);
sName = (it != end()) ? it->second : "";
}
MCString::iterator it = find(sName);
sRet = (it != end()) ? it->second : "";
}
vector<CSmartPtr<CTemplateTagHandler> >& vspTagHandlers = GetTagHandlers();
if (!vspTagHandlers.empty()) { // @todo this should go up to the top to grab handlers
CTemplate* pTmpl = GetCurTemplate();
if (sRet.empty()) {
for (unsigned int j = 0; j < vspTagHandlers.size(); j++) {
CSmartPtr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
CString sCustomOutput;
if (!bFromIf && spTagHandler->HandleVar(*pTmpl, sArgs.Token(0), sArgs.Token(1, true), sCustomOutput)) {
sRet = sCustomOutput;
break;
} else if (bFromIf && spTagHandler->HandleIf(*pTmpl, sArgs.Token(0), sArgs.Token(1, true), sCustomOutput)) {
sRet = sCustomOutput;
break;
}
}
}
for (unsigned int j = 0; j < vspTagHandlers.size(); j++) {
CSmartPtr<CTemplateTagHandler> spTagHandler = vspTagHandlers[j];
if (spTagHandler->HandleValue(*pTmpl, sRet, msArgs)) {
break;
}
}
}
if (!bFromIf) {
if (sRet.empty()) {
sRet = ResolveLiteral(msArgs["DEFAULT"]);
}
MCString::iterator it = msArgs.find("ESC");
if (it != msArgs.end()) {
VCString vsEscs;
it->second.Split(",", vsEscs, false);
for (unsigned int a = 0; a < vsEscs.size(); a++) {
sRet.Escape(CString::ToEscape(vsEscs[a]));
}
} else {
sRet.Escape(m_spOptions->GetEscapeFrom(), m_spOptions->GetEscapeTo());
}
}
return sRet;
}