Beispiel #1
0
void IncludeStructure::recordInclude(llvm::StringRef IncludingName,
                                     llvm::StringRef IncludedName,
                                     llvm::StringRef IncludedRealName) {
  auto Child = fileIndex(IncludedName);
  if (!IncludedRealName.empty() && RealPathNames[Child].empty())
    RealPathNames[Child] = IncludedRealName;
  auto Parent = fileIndex(IncludingName);
  IncludeChildren[Parent].push_back(Child);
}
Beispiel #2
0
void ReportDialog::generateIndex()
{
    logMessage("ReportDialog::generateIndex()");

    QString fileNameTemplate = tempProblemDir() + "/report/template.html";
    QString fileNameIndex = tempProblemDir() + "/report/report.html";

    QString content;

    // load template.html
    content = readFileContent(fileNameTemplate);
    QFile::remove(fileNameTemplate);

    // save index.html
    QFile fileIndex(fileNameIndex);
    if (fileIndex.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        QTextStream stream(&fileIndex);
        stream.setCodec("UTF-8");

        stream << replaceTemplates(content);

        fileIndex.flush();
        fileIndex.close();
    }
}
void GenerateIddFactoryOutFiles::writeIddFactoryFileIndex() {
  boost::filesystem::ofstream fileIndex(m_fileIndexPath);
  for (std::map<std::string,std::pair<std::string,bool> >::const_iterator it = checksumMap.begin(),
       itEnd = checksumMap.end(); it != itEnd; ++it)
  {
    if (it->second.second) {
      fileIndex << "// " << it->first << "," << it->second.first << std::endl;
    }
  }
}
Beispiel #4
0
int main(int argc, char **argv) {

    std::string root;
    bool skipOptions = false;

    for (int i = 1; i < argc; ++i) {
        std::string arg = argv[i];
        if (!skipOptions && arg[0]=='-') {
            if (arg == "--") {
                skipOptions = true;
            } else if (arg=="-d") {
                i++;
                if (i < argc)
                  data_url = argv[i];
            }
        } else {
            if (root.empty()) {
                root = arg;
            } else {
                root = "";
                break;
            }
        }
    }

    if (root.empty()) {
        std::cerr << "Usage: " << argv[0] << " <path> -d data_url" << std::endl;
        return -1;
    }
    std::ifstream fileIndex(root + "/" + "fileIndex");
    std::string line;

    FolderInfo rootInfo;
    while (std::getline(fileIndex, line))
    {
        FolderInfo *parent = &rootInfo;

        unsigned int pos = 0;
        unsigned int next_pos;
        while ((next_pos = line.find('/', pos)) < line.size()) {
            auto &sub = parent->subfolders[line.substr(pos, next_pos - pos)];
            if (!sub) sub = std::make_shared<FolderInfo>();
            parent = sub.get();
            pos = next_pos + 1;
        }
        parent->subfolders[line.substr(pos)]; //make sure it exists;
    }
    gererateRecursisively(&rootInfo, root, "");
    return 0;
}
void GenerateIddFactoryOutFiles::loadIddFactoryFileIndex() {
  if (boost::filesystem::exists(m_fileIndexPath)) {
    boost::filesystem::ifstream fileIndex(m_fileIndexPath);
    std::string line;
    boost::regex re("// ([^,]*),(.*)");
    boost::smatch m;
    while (std::getline(fileIndex,line)) {
      if (boost::regex_match(line,m,re)) {
        std::string filename(m[1].first,m[1].second);
        std::string cs(m[2].first,m[2].second);
        checksumMap[filename] = std::pair<std::string,bool>(cs,false);
      }
    }
  }
}
Beispiel #6
0
bool EditorTab::openFile(QString filename, int highlightLine)
{
	// First, check if the file isn't already loaded
	Editor * textEdit = NULL;
	int index = fileIndex(filename);
	if (index >= 0) {
		setCurrentIndex(index);
		textEdit = (Editor *)widget(index);
	} else {		

		if (QFileInfo(filename).exists() == false) {
			ErrorMessage("Could not load file: \n\n" +  filename);
			return false;
		}
		textEdit = new Editor(this);
		textEdit->Open(filename);
		
		connect(textEdit, SIGNAL(textChanged()), this, SLOT(onEditorTextChanged()));
	
		addTab(textEdit, QFileInfo(filename).fileName());
		setCurrentIndex(count() - 1);		

		bool ok = connect(textEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
					this,SLOT(ShowEditorMenu(const QPoint )));
		textEdit->setContextMenuPolicy(Qt::CustomContextMenu);

		QApplication::restoreOverrideCursor();
	}

	if (highlightLine >= 0) {		
		textEdit->setCursorPosition(highlightLine-1, 0);
		textEdit->ensureLineVisible(highlightLine-1);		
		textEdit->markerAdd (highlightLine-1, 0);
		textEdit->setCaretLineBackgroundColor(QColor(100, 20, 20));
	}

	return true;
}
Beispiel #7
0
int main(int argc, char **argv) {

    std::string root;
    bool skipOptions = false;

    for (int i = 1; i < argc; ++i) {
        std::string arg = argv[i];
        if (!skipOptions && arg[0]=='-') {
            if (arg == "--") {
                skipOptions = true;
            } else if (arg=="-d") {
                i++;
                if (i < argc)
                    data_url = argv[i];
            } else if (arg=="-p") {
                i++;
                if (i < argc) {
                    std::string s = argv[i];
                    auto colonPos = s.find(':');
                    if (colonPos >= s.size()) {
                        std::cerr << "fail to parse project option : " << s << std::endl;
                        continue;
                    }
                    auto secondColonPos = s.find(':', colonPos+1);
                    if (secondColonPos < s.size()) {
                        project_map[s.substr(0, colonPos)] = s.substr(secondColonPos + 1);
                    }
                }
            } else if (arg=="-e") {
                i++;
                // ignore -e XXX  for compatibility with the generator project definitions
            }
        } else {
            if (root.empty()) {
                root = arg;
            } else {
                root = "";
                break;
            }
        }
    }

    if (root.empty()) {
        std::cerr << "Usage: " << argv[0] << " <path> [-d data_url] [-p project_definition]" << std::endl;
        return -1;
    }
    std::ifstream fileIndex(root + "/" + "fileIndex");
    std::string line;

    FolderInfo rootInfo;
    while (std::getline(fileIndex, line))
    {
        FolderInfo *parent = &rootInfo;

        unsigned int pos = 0;
        unsigned int next_pos;
        while ((next_pos = line.find('/', pos)) < line.size()) {
            auto &sub = parent->subfolders[line.substr(pos, next_pos - pos)];
            if (!sub) sub = std::make_shared<FolderInfo>();
            parent = sub.get();
            pos = next_pos + 1;
        }
        parent->subfolders[line.substr(pos)]; //make sure it exists;
    }
    gererateRecursisively(&rootInfo, root, "");
    return 0;
}
Beispiel #8
0
void OpCreateFontThumbnails::Do(OpDescriptor*)
{
	//First we put up a CFileDialog to allow the user to enter
	//the path to the index file
	CFileDialog dlgIndex(TRUE);

	dlgIndex.DoModal();

	PathName pthIndex=(const TCHAR*) dlgIndex.GetPathName();

	//Now we're going to open that file
	CCDiskFile fileIndex(1024, FALSE, TRUE);

	fileIndex.open(pthIndex, ios::in | ios::binary);

	//And get it ready for lexical reading...
	fileIndex.InitLexer();

	fileIndex.SetDelimiters("\r\n");		
	fileIndex.SetCommentMarker('#');
	fileIndex.SetWhitespace("\t");
	
	//This variable will point to the buffer that has been read in
	const TCHAR* TokenBuf = fileIndex.GetTokenBuf();

	//And this indicates the sort of token that has been read in
	LexTokenType tokType=TOKEN_NORMAL;

	//Now, start reading from the file until we reach the "START" token
	//or we reach the end of the file
	while (tokType != TOKEN_EOF && camStrcmp(TokenBuf, "START")!=0)
	{
		//Get a token frm the file
		fileIndex.GetToken();

		//Find out what sort of token it is
		tokType = fileIndex.GetTokenType();
	}

	//Now read until we reach the end of the file
	while (tokType!=TOKEN_EOF)
	{
		//Get a token frm the file
		fileIndex.GetToken();

		//Find out what sort of token it is
		tokType = fileIndex.GetTokenType();

		//Right, now let's find the first comma in the string
		TCHAR* pcFindPtr=camStrchr(TokenBuf, ',');

		//If we've found one
		if (pcFindPtr)
		{
			//Then move the string pointer on by two characters
			pcFindPtr=camStrninc(pcFindPtr, 2);

			//And if we didn't go past the end of the string
			if (pcFindPtr && *pcFindPtr!='\0')
			{
				//Then pcFindPtr should now be pointing to the font name

				//Then find a pointer to the next comma in the string
				TCHAR* pcSecondComma=camStrchr(pcFindPtr, ',');

				if (!pcSecondComma)
					break;

				//And copy everything from the pcFindPtr (inclusive) to that second comma
				//(exclusive) into a new string
				String_256 strFontName;

				while (pcFindPtr && pcFindPtr!=pcSecondComma && *pcFindPtr!='\0')
				{
					strFontName+=(*pcFindPtr);
					pcFindPtr=camStrinc(pcFindPtr);
				}

				//Now we want to find the ID of the font. That will occur after the
				//second comma. So set pcFindPtr so it points to two characters
				//after the second comma
				pcFindPtr=camStrninc(pcSecondComma, 2);

				//And copy everything from the pcFindPtr (inclusive) to the third comma
				//(exclusive) into a new string
				String_256 strFontID;

				while (pcFindPtr && *pcFindPtr!=',' && *pcFindPtr!='\0')
				{
					strFontID+=(*pcFindPtr);
					pcFindPtr=camStrinc(pcFindPtr);
				}

				//And translate that string into a number
				INT32 lFontID=atol(strFontID);

				//Now find the font item with that name
				SGDisplayPreviewFonts* pFontItem=FindFontFromName(strFontName);

				//And if there is a font with that name
				if (pFontItem)
				{
					//Then create three bitmap thumbnails from that font and
					//save them in the same directory as the index
					CreateThumbnailFiles(pFontItem, lFontID, pthIndex);
				}
			}
		}
	}
}