当前位置: 首页>>代码示例>>C++>>正文


C++ KviKvsVariant::hash方法代码示例

本文整理汇总了C++中KviKvsVariant::hash方法的典型用法代码示例。如果您正苦于以下问题:C++ KviKvsVariant::hash方法的具体用法?C++ KviKvsVariant::hash怎么用?C++ KviKvsVariant::hash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KviKvsVariant的用法示例。


在下文中一共展示了KviKvsVariant::hash方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:namikaze90,项目名称:KVIrc-old,代码行数:45,代码来源:KviKvsTreeNodeHashElement.cpp

示例2: execute

bool KviKvsTreeNodeSpecialCommandForeach::execute(KviKvsRunTimeContext * c)
{
    KviKvsVariantList l;
    l.setAutoDelete(true);
    if(!m_pIterationData->evaluate(c,&l))
        return false;

    KviKvsSwitchList swl;
    if(m_pSwitches)
    {
        if(!(m_pSwitches->evaluate(c,&swl)))
            return false;
    }

    bool bIncludeEmptyScalars = swl.find('a',"all") != 0;

    for(KviKvsVariant * pArg = l.first(); pArg; pArg = l.next())
    {
        switch(pArg->type())
        {
        case KviKvsVariantData::Array:
        {
            unsigned int uCnt = pArg->array()->size();
            unsigned int idx = 0;
            while(idx < uCnt)
            {
                // we evaluate this each time (as it may actually be killed at each iteration)
                // FIXME: maybe some kind of reference counting or a observer pattern might be a bit more efficient here
                //        (but might be far less efficient everywhere else...)
                KviKvsRWEvaluationResult * v = m_pIterationVariable->evaluateReadWrite(c);
                if(!v)
                    return false;
                KviKvsVariant * pOne = pArg->array()->at(idx);
                if(pOne)
                {
                    if(bIncludeEmptyScalars || (!pOne->isEmpty()))
                    {
                        v->result()->copyFrom(*pOne);
                    } else {
                        delete v; // we're done with it for this iteration
                        idx++;
                        continue;
                    }
                } else {
                    if(bIncludeEmptyScalars)
                    {
                        v->result()->setNothing();
                    } else {
                        delete v; // we're done with it for this iteration
                        idx++;
                        continue;
                    }

                }
                delete v; // we're done with it for this iteration

                if(!m_pLoop->execute(c))
                {
                    if(c->error())
                        return false;

                    // break allowed!
                    if(c->breakPending())
                    {
                        c->handleBreak();
                        return true;
                    }

                    if(c->continuePending())
                    {
                        c->handleContinue();
                        idx++;
                        continue;
                    }

                    return false; // propagate the false return value
                }

                idx++;
            }
        }
        break;
        case KviKvsVariantData::Hash:
        {
            KviKvsHashIterator it(*(pArg->hash()->dict()));
            while(KviKvsVariant * pOne = it.current())
            {
                // we evaluate this each time (as it may actually be killed at each iteration)
                // FIXME: maybe some kind of reference counting or a observer pattern might be a bit more efficient here
                //        (but might be far less efficient everywhere else...)
                KviKvsRWEvaluationResult * v = m_pIterationVariable->evaluateReadWrite(c);
                if(!v)
                    return false;

                if(bIncludeEmptyScalars || (!pOne->isEmpty()))
                {
                    v->result()->copyFrom(*pOne);
                } else {
                    delete v; // we're done with it for this iteration
                    ++it;
//.........这里部分代码省略.........
开发者ID:kartagis,项目名称:KVIrc,代码行数:101,代码来源:KviKvsTreeNodeSpecialCommandForeach.cpp

示例3: if


//.........这里部分代码省略.........
	gbox = addGroupBox(0,1,0,1,Qt::Horizontal,__tr2qs_ctx("Language","options"));
	grid = new QGridLayout;
	gbox->setLayout(grid);

	grid->addWidget(addLabel(gbox,__tr2qs_ctx("Force language:","options")),0,0);

	m_pForcedLocaleCombo = new QComboBox(gbox);

	grid->addWidget(m_pForcedLocaleCombo,0,1);

	grid->addWidget(addLabel(gbox,__tr2qs_ctx("<b>Note:</b> You must restart KVIrc to apply any language changes","options")),1,0,1,2);

	m_pForcedLocaleCombo->addItem(__tr2qs_ctx("Automatic detection","options"));
	m_pForcedLocaleCombo->addItem(__tr2qs_ctx("en","options"));

	QString szLangFile;
	g_pApp->getLocalKvircDirectory(szLangFile,KviApplication::None,KVI_FORCE_LOCALE_FILE_NAME);

	bool bIsDefaultLocale = !KviFileUtils::fileExists(szLangFile);
	//We Have setted locale, but not restarted kvirc
	if(!g_szPrevSettedLocale.isEmpty())
		m_szLanguage = g_szPrevSettedLocale;
	else
		m_szLanguage = KviLocale::instance()->localeName();

	QString szLocaleDir;
	g_pApp->getGlobalKvircDirectory(szLocaleDir,KviApplication::Locale);

	QStringList list=QDir(szLocaleDir).entryList(QStringList("kvirc_*.mo"),QDir::Files);

	i = 0;
	int iMatch = 0;

	for(QStringList::Iterator it = list.begin(); it != list.end(); ++it)
	{
		QString szTmp=*it;
		szTmp.replace("kvirc_","");
		szTmp.replace(".mo","");
        m_pForcedLocaleCombo->insertItem(m_pForcedLocaleCombo->count(),szTmp);
		if(KviQString::equalCI(szTmp,m_szLanguage))
			iMatch = i + 2;
		i++;
	}
	if(bIsDefaultLocale)
		m_pForcedLocaleCombo->setCurrentIndex(0);
	else if(KviQString::equalCI(m_szLanguage,"en"))
		m_pForcedLocaleCombo->setCurrentIndex(1);
	else
		m_pForcedLocaleCombo->setCurrentIndex(iMatch);

#ifdef COMPILE_ENCHANT_SUPPORT
	{
		gbox = addGroupBox(0,2,0,2,Qt::Horizontal,__tr2qs_ctx("Spell Checker Dictionaries","options"));

		KviKvsVariant availableDictionaries;
		KviKvsScript::evaluate("$spellchecker.availableDictionaries", NULL, NULL, &availableDictionaries);
		const KviPointerHashTable<QString, KviKvsVariant>* hashTable = availableDictionaries.hash()->dict();
		KviPointerHashTableIterator<QString, KviKvsVariant> iter(*hashTable);
		QMap<QString, QString> dictMap;
		for (bool b = iter.moveFirst(); b; b = iter.moveNext()) {
			QString szDescription;
			iter.current()->asString(szDescription);
			dictMap[iter.currentKey()] = szDescription;
		}

		m_pSpellCheckerDictionaries = new QTableWidget(gbox);
		m_pSpellCheckerDictionaries->setRowCount(dictMap.size());
		m_pSpellCheckerDictionaries->setColumnCount(2);
		QStringList header;
		header << __tr2qs_ctx("Language code", "options");
		header << __tr2qs_ctx("Provided by", "options");
		m_pSpellCheckerDictionaries->setHorizontalHeaderLabels(header);
#if (QT_VERSION >= 0x050000)
		m_pSpellCheckerDictionaries->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
		m_pSpellCheckerDictionaries->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
		m_pSpellCheckerDictionaries->setSelectionBehavior(QAbstractItemView::SelectRows);
		m_pSpellCheckerDictionaries->setSelectionMode(QAbstractItemView::SingleSelection);
		m_pSpellCheckerDictionaries->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

		int row = 0;
		for (QMap<QString, QString>::iterator it = dictMap.begin(); it != dictMap.end(); ++it, ++row) {
			QTableWidgetItem* itemLang = new QTableWidgetItem(it.key());
			itemLang->setCheckState(KVI_OPTION_STRINGLIST(KviOption_stringlistSpellCheckerDictionaries).contains(it.key()) ? Qt::Checked : Qt::Unchecked);
			itemLang->setFlags(itemLang->flags() & ~Qt::ItemIsEditable);
			m_pSpellCheckerDictionaries->setItem(row,0,itemLang);

			QTableWidgetItem* itemDesc = new QTableWidgetItem(it.value());
			itemDesc->setFlags(itemDesc->flags() & ~Qt::ItemIsEditable);
			m_pSpellCheckerDictionaries->setItem(row,1,itemDesc);
		}

		m_pSpellCheckerDictionaries->resizeColumnsToContents();
		m_pSpellCheckerDictionaries->resizeRowsToContents();
	}
#else
	addRowSpacer(0,2,0,2);
#endif
}
开发者ID:kartagis,项目名称:KVIrc,代码行数:101,代码来源:OptionsWidget_textEncoding.cpp

示例4: process


//.........这里部分代码省略.........
							v->appendAsString(tmp);
							v = pVariantList->next();
						}
						*((QByteArray *)(pFmtArray->pContainer)) = tmp.toUtf8();
						bDoReturn = true;
					}
					*((QByteArray *)(pFmtArray->pContainer)) = tmp.toUtf8();
					if(((QByteArray *)(pFmtArray->pContainer))->isEmpty())
					{
						QString szError = QString(__tr2qs_ctx("Invalid data type for parameter \"%1\": found empty string while a non empty one was expected", "kvs")).arg(pFmtArray->szName);
						pContext->error(szError);
						return false;
					}
					if(bDoReturn)
						return true;
				}
				break;
				case KVS_PT_INT:
					if(!v->asInteger(*((kvs_int_t *)(pFmtArray->pContainer))))
					{
						if(!handleParameterTypeError(pContext, pFmtArray, v, "integer"))
							return false;
					}
					break;
				case KVS_PT_UINT:
				{
					kvs_int_t iTmp;
					if(!v->asInteger(iTmp))
					{
						if(!handleParameterTypeError(pContext, pFmtArray, v, "unsigned integer"))
							return false;
					}
					if(iTmp < 0)
					{
						QString szError = QString(__tr2qs_ctx("Invalid data type for parameter \"%1\": found signed integer \"%2\" where type 'unsigned integer' was expected", "kvs")).arg(pFmtArray->szName).arg(iTmp);
						pContext->error(szError);
						return false;
					}
					*((kvs_uint_t *)(pFmtArray->pContainer)) = (kvs_uint_t)iTmp;
				}
				break;
				case KVS_PT_DOUBLE:
					if(!v->asReal(*((kvs_real_t *)(pFmtArray->pContainer))))
					{
						if(!handleParameterTypeError(pContext, pFmtArray, v, "real"))
							return false;
					}
					break;
				case KVS_PT_HASH:
					if(!v->isHash())
					{
						if(!handleParameterTypeError(pContext, pFmtArray, v, "hash"))
							return false;
					}
					else
					{
						*((KviKvsHash **)(pFmtArray->pContainer)) = v->hash();
					}
					break;
				case KVS_PT_ARRAYCAST:
					v->castToArray((KviKvsArrayCast *)(pFmtArray->pContainer));
					break;
				case KVS_PT_ARRAY:
					if(!v->isArray())
					{
						if(!handleParameterTypeError(pContext, pFmtArray, v, "array"))
							return false;
					}
					else
					{
						*((KviKvsArray **)(pFmtArray->pContainer)) = v->array();
					}
					break;
				case KVS_PT_BOOL:
					// this never fails: anything is converted to a boolean
					*((bool *)(pFmtArray->pContainer)) = v->asBoolean();
					break;
				case KVS_PT_VARIANT:
					*((KviKvsVariant **)(pFmtArray->pContainer)) = v;
					break;
				case KVS_PT_HOBJECT:
					if(!v->asHObject(*((kvs_hobject_t *)(pFmtArray->pContainer))))
					{
						if(!handleParameterTypeError(pContext, pFmtArray, v, "hobject"))
							return false;
					}
					break;
				case KVS_PT_IGNORE:
					// ignore
					break;
				default:
					qDebug("Internal error in KviKvsParameterProcessor::processAsParameters(): unknown parameter type %d", pFmtArray->uType);
					return false;
					break;
			}
			pFmtArray++;
			v = pVariantList->next();
		}
		return true;
	}
开发者ID:AndrioCelos,项目名称:KVIrc,代码行数:101,代码来源:KviKvsParameterProcessor.cpp


注:本文中的KviKvsVariant::hash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。