本文整理汇总了C++中KviKvsVariant类的典型用法代码示例。如果您正苦于以下问题:C++ KviKvsVariant类的具体用法?C++ KviKvsVariant怎么用?C++ KviKvsVariant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KviKvsVariant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluateReadOnly
bool KviKvsTreeNodeMultipleParameterIdentifier::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
{
KviKvsVariant * v = c->parameterList()->at(m_iStart);
if(!v)
{
pBuffer->setNothing();
return true;
}
QString sz;
v->asString(sz);
if(m_iEnd >= m_iStart)
{
// only up to m_iEnd
int idx = m_iStart;
for(v = c->parameterList()->next(); v && (idx < m_iEnd); v = c->parameterList()->next())
{
sz += QChar(' ');
v->appendAsString(sz);
idx++;
}
} else {
// all up to the end of the list
for(v = c->parameterList()->next(); v; v = c->parameterList()->next())
{
sz += QChar(' ');
v->appendAsString(sz);
}
}
pBuffer->setString(sz);
return true;
}
示例2: execute
bool KviKvsTreeNodeSpecialCommandWhile::execute(KviKvsRunTimeContext * c)
{
for(;;)
{
KviKvsVariant v;
if(!m_pExpression->evaluateReadOnly(c, &v))
return false;
if(!v.asBoolean())
break;
if(m_pInstruction)
{
if(!m_pInstruction->execute(c))
{
if(c->error())
return false;
if(c->breakPending())
{
c->handleBreak();
return true;
}
if(c->continuePending())
{
c->handleContinue();
continue;
}
return false;
}
}
}
return true;
}
示例3: urllist_module_event_onUrl
bool urllist_module_event_onUrl(KviKvsModuleEventCall * c)
{
KviKvsVariant * vUrl = c->firstParam();
QString szUrl;
if(vUrl)vUrl->asString(szUrl);
if (check_url(c->window(),szUrl) == 0)
{
KviUrl *tmp = new KviUrl;
QString tmpTimestamp;
QDate d = QDate::currentDate();
QString date;
date.sprintf("%d-%d%d-%d%d",d.year(),d.month() / 10,d.month() % 10,d.day() / 10,d.day() % 10);
tmpTimestamp = "["+date+"]"+" [";
tmpTimestamp += QTime::currentTime().toString()+"]";
tmp->url = szUrl;
tmp->window = c->window()->plainTextCaption();
tmp->count = 1;
tmp->timestamp = tmpTimestamp;
g_pList->append(tmp);
for (UrlDlgList *tmpitem=g_pUrlDlgList->first();tmpitem;tmpitem=g_pUrlDlgList->next()) {
if (tmpitem->dlg) {
QString tmpCount;
tmpCount.setNum(tmp->count);
tmpitem->dlg->addUrl(QString(tmp->url), QString(tmp->window), tmpCount, QString(tmp->timestamp));
tmpitem->dlg->windowListItem()->highlight(false);
}
}
}
return true;
}
示例4: run
int KviKvsScript::run(KviWindow * pWnd, KviKvsVariantList * pParams, QString & szRetVal, int iRunFlags, KviKvsExtendedRunTimeData * pExtData)
{
KviKvsVariant retVal;
int iRet = run(pWnd, pParams, &retVal, iRunFlags, pExtData);
retVal.asString(szRetVal);
return iRet;
}
示例5: KviKvsHashElement
KviKvsRWEvaluationResult * KviKvsTreeNodeHashElement::evaluateReadWriteInObjectScope(KviKvsObject *o,KviKvsRunTimeContext * c)
{
KviKvsVariant key;
if(!m_pKey->evaluateReadOnly(c,&key))return 0;
QString szKey;
key.asString(szKey);
if(szKey.isEmpty())
{
c->warning(this,__tr2qs_ctx("Hash key evaluated to empty string: fix the script","kvs"));
}
KviKvsRWEvaluationResult * result;
if(o)result = m_pSource->evaluateReadWriteInObjectScope(o,c);
else result = m_pSource->evaluateReadWrite(c);
if(!result)return 0;
if(!result->result()->isHash())
{
// convert to hash in some way
//#warning "Supply a *real* conversion from other types to array ?"
if(!result->result()->isNothing())
{
QString szType;
result->result()->getTypeName(szType);
c->warning(this,__tr2qs_ctx("The argument of the {} subscript didn't evaluate to a hash: automatic conversion from %Q supplied","kvs"),&szType);
}
result->result()->setHash(new KviKvsHash());
}
return new KviKvsHashElement(result,result->result()->hash()->get(szKey),result->result()->hash(),szKey);
}
示例6: execute
bool KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::execute(KviKvsRunTimeContext * c,KviKvsVariant * pRealParameter, bool * bPassThrough)
{
if(!(*bPassThrough))
{
KviKvsVariant v;
if(!m_pParameter->evaluateReadOnly(c,&v))return false;
QString reg;
v.asString(reg);
// QRegExp rx(reg,false,false);
QRegExp rx(reg,Qt::CaseInsensitive,QRegExp::RegExp);
QString val;
pRealParameter->asString(val);
if(!rx.exactMatch(val))return true; // no match
}
*bPassThrough = true;
if(m_pInstruction)
{
if(!m_pInstruction->execute(c))return false; // might be a break too
}
if(m_bHasTerminatingBreak)
{
c->setBreakPending();
return false;
}
return true;
}
示例7: next
bool KviKvsVariantList::nextAsString(QString & szBuffer)
{
KviKvsVariant * v = next();
if(!v)
return false;
v->asString(szBuffer);
return true;
}
示例8: evaluateAsString
int KviKvsScript::evaluateAsString(const QString & szCode, KviWindow * pWindow, KviKvsVariantList * pParams, QString & szRetVal)
{
// static helper
KviKvsVariant ret;
KviKvsScript s("kvirc::corecall(evaluate)", szCode, Parameter);
int iRet = s.run(pWindow, pParams, &ret, PreserveParams);
ret.asString(szRetVal);
return iRet;
}
示例9: KVI_OPTION_STRING
void KviWindow::getDefaultLogFileName(QString & szBuffer, QDate date, bool bGzip, unsigned int uDatetimeFormat)
{
QString szLog;
// dynamic log path
QString szDynamicPath = KVI_OPTION_STRING(KviOption_stringLogsDynamicPath).trimmed();
if(!szDynamicPath.isEmpty())
{
KviQString::escapeKvs(&szDynamicPath, KviQString::PermitVariables | KviQString::PermitFunctions);
KviKvsVariant vRet;
if(KviKvsScript::evaluate(szDynamicPath, this, nullptr, &vRet))
vRet.asString(szDynamicPath);
}
g_pApp->getLocalKvircDirectory(szLog, KviApplication::Log, szDynamicPath);
KviQString::ensureLastCharIs(szLog, KVI_PATH_SEPARATOR_CHAR);
//ensure the directory exists
KviFileUtils::makeDir(szLog);
QString szDate;
switch(uDatetimeFormat)
{
case 1:
szDate = date.toString(Qt::ISODate);
break;
case 2:
szDate = date.toString(Qt::SystemLocaleShortDate);
break;
case 0:
default:
szDate = date.toString("yyyy.MM.dd");
break;
}
szDate.replace('_', '-'); // this would confuse the log viewer
KviFileUtils::cleanFileName(szDate);
QString szBase;
getBaseLogFileName(szBase);
KviFileUtils::encodeFileName(szBase);
szBase = szBase.toLower();
szBase.replace("%%2e", "%2e");
QString szTmp;
if(bGzip)
szTmp = "%1_%2_%3.log.gz";
else
szTmp = "%1_%2_%3.log";
szLog.append(QString(szTmp).arg(typeString(), szBase, szDate));
szBuffer = szLog;
}
示例10: theme_kvs_cmd_pack
static bool theme_kvs_cmd_pack(KviKvsModuleCommandCall * c)
{
QString szPath, szName, szVersion, szDescription, szAuthor, szImage;
KviKvsArrayCast aCast;
KVSM_PARAMETERS_BEGIN(c)
KVSM_PARAMETER("package_path", KVS_PT_NONEMPTYSTRING, 0, szPath)
KVSM_PARAMETER("package_name", KVS_PT_NONEMPTYSTRING, 0, szName)
KVSM_PARAMETER("package_version", KVS_PT_NONEMPTYSTRING, 0, szVersion)
KVSM_PARAMETER("package_description", KVS_PT_STRING, 0, szDescription)
KVSM_PARAMETER("package_author", KVS_PT_NONEMPTYSTRING, 0, szAuthor)
KVSM_PARAMETER("package_image", KVS_PT_STRING, 0, szImage)
KVSM_PARAMETER("theme", KVS_PT_ARRAYCAST, 0, aCast)
KVSM_PARAMETERS_END(c)
KviKvsArray * pArray = aCast.array();
if((!pArray) || (pArray->size() < 1))
{
c->error(__tr2qs_ctx("No themes specified", "theme"));
return false;
}
kvs_uint_t s = pArray->size();
QStringList lThemeList;
for(kvs_uint_t i = 0; i < s; i++)
{
KviKvsVariant * v = pArray->at(i);
if(!v)
continue; // ?
QString szVal;
v->asString(szVal);
if(szVal.isEmpty())
continue;
lThemeList.append(szVal);
}
KviPointerList<KviThemeInfo> lThemeInfoList;
lThemeInfoList.setAutoDelete(true);
Q_FOREACH(QString szTheme, lThemeList)
{
KviThemeInfo * pInfo = new KviThemeInfo();
if(!pInfo->load(szTheme, KviThemeInfo::External))
{
QString szErr = pInfo->lastError();
c->error(__tr2qs_ctx("Failed to load theme from directory %Q: %Q", "theme"), &szTheme, &szErr);
delete pInfo;
return false;
}
lThemeInfoList.append(pInfo);
}
示例11: execute
bool KviKvsTreeNodeSpecialCommandDefpopup::execute(KviKvsRunTimeContext * c)
{
KviKvsVariant v;
if(!m_pPopupName->evaluateReadOnly(c,&v))return false;
QString szName;
v.asString(szName);
KviKvsSwitchList swl;
if(m_pSwitches)
{
if(!(m_pSwitches->evaluate(c,&swl)))return false;
}
KviKvsPopupMenu * pPopup = KviKvsPopupManager::instance()->lookup(szName);
bool bWasAlreadyThere;
if(!pPopup)
{
if(m_pMainPopup->isEmpty())return true; // we wanted to remove it anyway: exit silently
// we want to create it
pPopup = new KviKvsPopupMenu(szName);
KviKvsPopupManager::instance()->add(szName,pPopup);
bWasAlreadyThere = false;
} else {
bWasAlreadyThere = true;
if(pPopup->isHardLocked())
{
c->error(__tr2qs_ctx("The popup '%s' is actually locked: 'self-modifications' are not allowed","kvs"),&szName);
return false;
}
if(m_pMainPopup->isEmpty())
{
// we want to remove it
KviKvsPopupManager::instance()->remove(szName);
return true;
}
// we want to (re)create it
if(!swl.find('m',"--merge"))pPopup->doClear();
}
if(!m_pMainPopup->fill(c,pPopup))
{
if(!bWasAlreadyThere)KviKvsPopupManager::instance()->remove(szName);
return false;
}
KviKvsPopupManager::instance()->emitRefresh(szName);
return true;
}
示例12: QString
void KviKvsVariantList::allAsString(QString & szBuffer)
{
szBuffer = QString();
bool bFirst = true;
for(KviKvsVariant * v = first(); v; v = next())
{
if(bFirst)
bFirst = false;
else
szBuffer.append(' ');
v->appendAsString(szBuffer);
}
}
示例13: QString
bool KviKvsTreeNodeCompositeData::evaluateReadOnly(KviKvsRunTimeContext * c, KviKvsVariant * pBuffer)
{
QString * pS = new QString();
pBuffer->setString(pS);
KviKvsVariant res;
// we need to use an iterator to accommodate recursion
KviPointerListIterator<KviKvsTreeNodeData> it(*m_pSubData);
while(KviKvsTreeNodeData * d = it.current())
{
if(!d->evaluateReadOnly(c, &res))
return false;
res.appendAsString(*pS);
++it;
}
return true;
}
示例14: m_allocProc
KviKvsObject * KviKvsObjectClass::allocateInstance(KviKvsObject * pParent,const QString &szName,KviKvsRunTimeContext * pContext,KviKvsVariantList * pParams)
{
if(!m_allocProc)
return 0;
KviKvsObject * pObject = m_allocProc(this,pParent,szName);
if(!pObject)
return 0;
if(!pObject->init(pContext,pParams))
{
// internal init failure : abort
pObject->dieNow();
return 0;
}
// copy params
KviKvsVariantList copy;
copy.setAutoDelete(false);
KviKvsVariant * v = pParams->first();
while(v)
{
copy.append(v);
v = pParams->next();
}
KviKvsVariant ret;
if(!pObject->callFunction(pObject,"constructor",QString(),pContext,&ret,©))
{
// ops...constructor failed (script error!)
pObject->dieNow();
return 0;
}
if(!ret.isEmpty())
pContext->warning(__tr2qs_ctx("It's not allowed to return values in the constructor","kvs"));
return pObject;
}
示例15: evaluateReadOnlyInObjectScope
bool KviKvsTreeNodeHashElement::evaluateReadOnlyInObjectScope(KviKvsObject *o,KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
{
KviKvsVariant key;
if(!m_pKey->evaluateReadOnly(c,&key))return false;
QString szKey;
key.asString(szKey);
if(szKey.isEmpty())
{
c->warning(this,__tr2qs_ctx("Hash key evaluated to empty string: fix the script","kvs"));
pBuffer->setNothing();
return true;
}
KviKvsVariant val;
if(o)
{
if(!m_pSource->evaluateReadOnlyInObjectScope(o,c,&val))return false;
} else {
if(!m_pSource->evaluateReadOnly(c,&val))return false;
}
if(!val.isHash())
{
if(!val.isNothing())
{
QString szType;
val.getTypeName(szType);
c->warning(this,__tr2qs_ctx("The argument of the {} subscript didn't evaluate to a hash: automatic conversion from type '%Q' supplied","kvs"),&szType);
}
pBuffer->setNothing();
return true;
}
KviKvsVariant * v = val.hash()->find(szKey);
if(!v)
{
pBuffer->setNothing();
return true;
}
pBuffer->copyFrom(v);
return true;
}