Esempio n. 1
0
void getAllIncludes(QString path, QFileInfoList h_files, QFileInfoList cpp_files, QStringList& includes)
{
	for(QFileInfoList::iterator it = h_files.begin(); it != h_files.end(); it++)
	{		
		QFile file(it->absoluteFilePath());
		
		if(file.open(QFile::ReadOnly))
		{
			QTextStream textStream(&file);
			
			while(!textStream.atEnd())
			{
				QString line = textStream.readLine();
				
				if( line.indexOf("#include ") != -1 && line.indexOf("Q") != -1 )
				{
					addToStringList(includes, line);
				}
			}
			
			file.close();
		}
	}

	for(QFileInfoList::iterator it = cpp_files.begin(); it != cpp_files.end(); it++)
	{
		QFile file(it->absoluteFilePath());
		if(file.open(QFile::ReadOnly))
		{
			QTextStream textStream(&file);
			
			while(!textStream.atEnd())
			{
				QString line = textStream.readLine();

				if( line.indexOf("//") == -1 && 
					line.indexOf("#include ") != -1 && 
					line.indexOf("Q") != -1
				   )
				{
					addToStringList(includes, line);
				}
			}
			
			file.close();
		}
	}
}
Esempio n. 2
0
void createModuleVector(QList<QStringList>& moduleVector, bool shortModules)
{
	// Modulefiles will be in modules subdir. This should be configurable in future
	// now we expect, that the modules-folder is right next to the application it self
	QDir moduleBasePath(QCoreApplication::applicationDirPath().append("/modules/"));

	// Check if moduleBasePath exists and is directory
	if( moduleBasePath.exists() )
	{
		// Get all files in directory, exclude SymLinks and special-files
		moduleBasePath.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
		
		QStringList filterList;
		// only use short modulename lists
		if( shortModules )
		{
			filterList << "*_short";
		}
		// use the full modulename lists
		else
		{
			filterList << "*_long";
		}
		// set the name filter
		moduleBasePath.setNameFilters(filterList);
		
		// get the filelist
		QFileInfoList fileList = moduleBasePath.entryInfoList();

		for (int i = 0; i < fileList.count(); ++i)
		{
			QFile file(fileList.at(i).filePath());
			
			// get module name from filename
			QString moduleName = fileList.at(i).baseName().split('_')[0];
			
			if(file.open(QFile::ReadOnly))
			{
				QTextStream textStream(&file);
				QStringList includes;
				
				// the module name is always the first entry in the list
				includes.push_back(moduleName);

				while(!file.atEnd())
				{
					addToStringList(includes, textStream.readLine());
				}
			
				moduleVector.push_back( includes );
				file.close();
			}
		}
	}
}
Esempio n. 3
0
void getModules(QStringList& includes, QStringList& modules, bool useShortModules)
{
	QList<QStringList> moduleVector;
	createModuleVector( moduleVector, useShortModules );
	
	for(QStringList::iterator it = includes.begin(); it != includes.end(); it++)
	{
		QString qtInclude;

		size_t pos1 = (*it).indexOf('\"');
		if( pos1 != -1 )
		{
			size_t last = (*it).lastIndexOf('\"');
			qtInclude = (*it).mid( pos1 + 1, last - pos1 - 1 );
		}

		size_t pos2 = (*it).indexOf('<');
		if( pos2 != -1 )
		{
			size_t last = (*it).lastIndexOf('>');
			qtInclude = (*it).mid( pos2 + 1, last - pos2 - 1 );
		}

		for( QList< QStringList >::iterator itMod = moduleVector.begin(); itMod != moduleVector.end(); itMod++ )
		{
			for( QStringList::iterator stringIt = (*itMod).begin(); stringIt != (*itMod).end(); stringIt++ )
			{
				//comparisons++;
				if( qtInclude.indexOf( *stringIt ) != -1 )
				{
					addToStringList(modules, QString("+").append(*(itMod->begin())) );
				}
			}
		}
	}
}
Esempio n. 4
0
StringList* search(Pattern* p, String* s) {
    int i, j;
    String* buffer;
    BufferRange range;
    unsigned char buffering = 0,
                  detecting = 0;
    StringList* list = newStringList();

    unsigned char buffering_after = 0,
                  detecting_after = 0;

    for (i = 0; i < s->length; i++) {
        // This condition fully use lazy execution
        if (buffering || detecting > 0 || (s->str[i] == p->start[0])) {

            // Trying to start buffering
            if (!buffering) {

                if (p->start[detecting] == L'\0') {

                    // Starting buffer
                    range.start = i - detecting;

                    detecting = 0;
                    buffering = 1;


                } else if (p->start[detecting] != s->str[i]) {
                    detecting = 0;
                } else {
                    detecting++;
                }
            } else {
                // Trying to stop buffering
                if(detecting > 0 || s->str[i] == p->end[0]) {

                    if (p->end[detecting] == L'\0') {
                        detecting = 0;
                        buffering = 0;

                        // Saving the buffer in a list
                        range.end = i;

                        buffer = newStringFromInt(range.end - range.start);
                        for (j = 0; j < buffer->length; j++) {
                            buffer->str[j] = s->str[j+range.start];
                        }

                        addToStringList(list, buffer);

                        // Starting buffering "after"
                        buffering_after = 1;

                    } else if (s->str[i] != p->end[detecting]) {
                        detecting = 0;
                    } else {
                        detecting++;
                    }

                }
            }
        } else {
            detecting = 0;
        }

        // Getting the prototype of the function
        if(buffering_after) {
            // If it's a new line, detection comes to 0
            if(s->str[i] == L'\n') {
                detecting_after = 0;

            } else if (detecting_after > 4 && s->str[i] == L')') {

                buffering_after = 0;
                list->last->after = newStringFromInt(detecting_after+1);
                int itmp = i - detecting_after;
                for (j=0; j <= detecting_after; j++) {

                    list->last->after->str[j] = s->str[itmp+j];
                }

                list->last->hasAfter = 1;
                detecting_after = 0;

            } else if(s->str[i] == L';') {
                buffering_after = 0;
                detecting_after = 0;
            } else if(detecting_after > 0) {
                detecting_after++;
            } else if(s->str[i] != L' ') {
                detecting_after++;
            }
        }
    }

    return list;
}