Beispiel #1
0
KviKvsHash * KviIrcMessage::messageTagsKvsHash()
{
	KviKvsHash * hList = new KviKvsHash;
	const auto & m = this->messageTagsMap();
	for(auto it = m.begin(); it != m.end(); ++it)
		hList->set(it.key(), new KviKvsVariant(it.value()));
	return hList;
}
	bool startElement(const QString & szNamespaceUri, const QString & szLocalName, const QString & szQualifiedName, const QXmlAttributes & attrs) override
	{
		KviKvsVariant ret;
		KviKvsVariantList par;
		par.setAutoDelete(true);
		par.append(new KviKvsVariant(szQualifiedName));
		KviKvsHash * pHash = new KviKvsHash();
		par.append(new KviKvsVariant(pHash));
		par.append(new KviKvsVariant(szNamespaceUri));
		par.append(new KviKvsVariant(szLocalName));
		int c = attrs.count();
		for(int i = 0; i < c; i++)
			pHash->set(attrs.qName(i), new KviKvsVariant(attrs.value(i)));
		if(!m_pReader->callFunction(m_pReader, "onElementStart", &ret, &par))
			return kvsCodeFailure();
		return handleKvsCallReturnValue(&ret);
	}
Beispiel #3
0
static bool theme_kvs_fnc_info(KviKvsModuleFunctionCall * c)
{
	QString szTheme;

	KVSM_PARAMETERS_BEGIN(c)
	KVSM_PARAMETER("theme", KVS_PT_STRING, 0, szTheme)
	KVSM_PARAMETERS_END(c)

	KviKvsHash * pHash = new KviKvsHash();
	c->returnValue()->setHash(pHash);

	KviThemeInfo theme;
	if(!theme.load(szTheme, KviThemeInfo::Auto))
	{
		c->warning(__tr2qs_ctx("The theme package '%Q' doesn't exist", "theme"), &szTheme);
		return true;
	}

	pHash->set("name", new KviKvsVariant(theme.name()));
	pHash->set("version", new KviKvsVariant(theme.version()));
	pHash->set("author", new KviKvsVariant(theme.author()));
	pHash->set("description", new KviKvsVariant(theme.description()));
	return true;
}
Beispiel #4
0
KviKvsVariant * KviKvsVariant::unserializeHash(const QChar ** ppAux)
{
	KviKvsHash * pHash = new KviKvsHash();
	QString szKey;
	KviKvsVariant * pElement = 0;
	//skip leading '{'
	(*ppAux)++;
	int i=0;
	while(1)
	{
		//skip leading space
		while((*ppAux)->isSpace())
			(*ppAux)++;
		//waiting for starting of string
		if((*ppAux)->unicode() != '\"')
		{
			//strange characters
			delete pHash;
			return 0;
		}
		unserializeString(ppAux,szKey);
		if(szKey.isEmpty())
		{
			//Strange element name
			delete pHash;
			return 0;
		}

		//skip leading space before ':'
		while((*ppAux)->isSpace())
			(*ppAux)++;
		//waiting for name-value delimeter
		if((*ppAux)->unicode() != ':')
		{
			//strange characters
			delete pHash;
			return 0;
		}
		(*ppAux)++;

		//getting element
		pElement = unserialize(ppAux);
		if(pElement)
		{
			pHash->set(szKey,pElement);
			i++;
			while((*ppAux)->isSpace())
				(*ppAux)++;
			switch((*ppAux)->unicode())
			{
				case ',':
					//goto next
					(*ppAux)++;
				break;
				case '}':
					//EOF array
					(*ppAux)++;
					return new KviKvsVariant(pHash);
				break;
				default:
					delete pHash;
					return 0;
				break;
			}
		} else {
			//error
			delete pHash;
			return 0;
		}
	}
	return 0;
}
/*
	@doc: spellchecker.available_dictionaries
	@type:
		function
	@title:
		$spellchecker.available_dictionaries
	@short:
		Return available dictionaries.
	@syntax:
		<hash> $spellchecker.available_dictionaries
	@description:
		This function returns a hash. For every supported dictionary, key is the language code,
		value is name of provider for that language (e.g. Aspell).
*/
static void spellchecker_enumerate_dicts(const char* szLang, const char* /*szName*/,
		const char* szDesc, const char* /*szFile*/, void* pData) {
	KviKvsHash* pHash = reinterpret_cast<KviKvsHash*>(pData);
	pHash->set(szLang, new KviKvsVariant(szDesc));
}