Exemple #1
0
	bool checkAllow(const QString &in) const
	{
		foreach(const QString &exp, config->allowExps)
		{
			if(matchExp(exp, in))
				return true;
		}

		return false;
	}
Exemple #2
0
	bool checkDeny(const QString &in) const
	{
		foreach(const QString &exp, config->denyExps)
		{
			if(matchExp(exp, in))
				return true;
		}

		return false;
	}
//-----------------------------------------------------------------------------
// Function: enumerateNames()
//-----------------------------------------------------------------------------
int CSourceContentMatcher::enumerateNames(QString const &text, MatchExecFunc func, int &startIndex,
                                        bool& exactMatch)
{
    exactMatch = false;
    int count = 0;

    // Check if the last word could be a name.
    static QRegExp lastWordExp("[a-z|A-Z|_][a-z|A-Z|0-9|_]*$");
    startIndex = lastWordExp.indexIn(text, 0);

    if (startIndex >= 0)
    {
        QString word = text.mid(startIndex, lastWordExp.matchedLength());
        QRegExp matchExp("^" + QRegExp::escape(word.toLower()) + ".*");

        foreach (QSharedPointer<ApiDefinition const> apiDef, sourceApiDefinitions_)
        {
            // Search for functions that start with the retrieved word.
            for (int i = 0; i < apiDef->getFunctionCount(); ++i)
            {
                QSharedPointer<ApiFunction const> apiFunc = apiDef->getFunction(i);

                if (tryMatchIdentifier(apiFunc->getName(), MCAPI_CONTENT_FUNC, matchExp, func, count))
                {
                    // Check if this was an exact match.
                    if (!exactMatch && apiFunc->getName() == word)
                    {
                        exactMatch = true;
                    }
                }
            }

            // Search for types that start with the retrieved word.
            foreach (QString const& dataType, apiDef->getDataTypes())
            {
                if (tryMatchIdentifier(dataType, MCAPI_CONTENT_TYPENAME, matchExp, func, count))
                {
                    // Check if this was an exact match.
                    if (!exactMatch && dataType == word)
                    {
                        exactMatch = true;
                    }
                }
            }
        }
    }