コード例 #1
0
void TemplightGraphVizWriter::openPrintedTreeNode(const EntryTraversalTask& aNode) {
  const PrintableTemplightEntryBegin& BegEntry = aNode.start;
  const PrintableTemplightEntryEnd&   EndEntry = aNode.finish;
  
  std::string EscapedName = escapeXml(BegEntry.Name);
  OutputOS 
    << llvm::format("n%d [label = ", aNode.nd_id)
    << llvm::format(
        "\"%s\\n"
        "%s\\n"
        "At %s Line %d Column %d\\n",
      InstantiationKindStrings[BegEntry.InstantiationKind], EscapedName.c_str(),
      BegEntry.FileName.c_str(), BegEntry.Line, BegEntry.Column);
  if( !BegEntry.TempOri_FileName.empty() ) {
    OutputOS << llvm::format(
      "From %s Line %d Column %d\\n",
      BegEntry.TempOri_FileName.c_str(), BegEntry.TempOri_Line, BegEntry.TempOri_Column);
  }
  OutputOS 
    << llvm::format(
        "Time: %.9f seconds Memory: %d bytes\" ];\n",
      EndEntry.TimeStamp - BegEntry.TimeStamp,
      EndEntry.MemoryUsage - BegEntry.MemoryUsage);
  
  if ( aNode.parent_id == RecordedDFSEntryTree::invalid_id )
    return;
  
  OutputOS << llvm::format(
    "n%d -> n%d;\n",
    aNode.parent_id, aNode.nd_id);
}
コード例 #2
0
void TemplightGraphMLWriter::openPrintedTreeNode(const EntryTraversalTask& aNode) {
  const PrintableTemplightEntryBegin& BegEntry = aNode.start;
  const PrintableTemplightEntryEnd&   EndEntry = aNode.finish;
  
  OutputOS << llvm::format("<node id=\"n%d\">\n", aNode.nd_id);
  
  std::string EscapedName = escapeXml(BegEntry.Name);
  OutputOS << llvm::format(
    "  <data key=\"d0\">%s</data>\n"
    "  <data key=\"d1\">\"%s\"</data>\n"
    "  <data key=\"d2\">\"%s|%d|%d\"</data>\n",
    InstantiationKindStrings[BegEntry.InstantiationKind], EscapedName.c_str(),
    BegEntry.FileName.c_str(), BegEntry.Line, BegEntry.Column);
  OutputOS << llvm::format(
    "  <data key=\"d3\">%.9f</data>\n"
    "  <data key=\"d4\">%d</data>\n", 
    EndEntry.TimeStamp - BegEntry.TimeStamp,
    EndEntry.MemoryUsage - BegEntry.MemoryUsage);
  if( !BegEntry.TempOri_FileName.empty() ) {
    OutputOS << llvm::format(
      "  <data key=\"d2\">\"%s|%d|%d\"</data>\n",
      BegEntry.TempOri_FileName.c_str(), BegEntry.TempOri_Line, BegEntry.TempOri_Column);
  }
  
  OutputOS << "</node>\n";
  if ( aNode.parent_id == RecordedDFSEntryTree::invalid_id )
    return;
  
  OutputOS << llvm::format(
    "<edge id=\"e%d\" source=\"n%d\" target=\"n%d\"/>\n",
    last_edge_id++, aNode.parent_id, aNode.nd_id);
}
コード例 #3
0
void TemplightXmlWriter::printEntry(const PrintableTemplightEntryBegin& aEntry) {
  std::string EscapedName = escapeXml(aEntry.Name);
  OutputOS << llvm::format(
    "<TemplateBegin>\n"
    "    <Kind>%s</Kind>\n"
    "    <Context context = \"%s\"/>\n"
    "    <Location>%s|%d|%d</Location>\n",
    InstantiationKindStrings[aEntry.InstantiationKind], EscapedName.c_str(),
    aEntry.FileName.c_str(), aEntry.Line, aEntry.Column);
  OutputOS << llvm::format(
    "    <TimeStamp time = \"%.9f\"/>\n"
    "    <MemoryUsage bytes = \"%d\"/>\n",
    aEntry.TimeStamp, aEntry.MemoryUsage);
  if( !aEntry.TempOri_FileName.empty() ) {
    OutputOS << llvm::format(
      "    <TemplateOrigin>%s|%d|%d</TemplateOrigin>\n",
      aEntry.TempOri_FileName.c_str(), aEntry.TempOri_Line, aEntry.TempOri_Column);
  }
  OutputOS << "</TemplateBegin>\n";
}
コード例 #4
0
void TemplightNestedXMLWriter::openPrintedTreeNode(const EntryTraversalTask& aNode) {
  const PrintableTemplightEntryBegin& BegEntry = aNode.start;
  const PrintableTemplightEntryEnd&   EndEntry = aNode.finish;
  std::string EscapedName = escapeXml(BegEntry.Name);
  
  OutputOS << llvm::format(
    "<Entry Kind=\"%s\" Name=\"%s\" ",
    InstantiationKindStrings[BegEntry.InstantiationKind], EscapedName.c_str());
  OutputOS << llvm::format(
    "Location=\"%s|%d|%d\" ", 
    BegEntry.FileName.c_str(), BegEntry.Line, BegEntry.Column);
  if( !BegEntry.TempOri_FileName.empty() ) {
    OutputOS << llvm::format(
      "TemplateOrigin=\"%s|%d|%d\" ",
      BegEntry.TempOri_FileName.c_str(), BegEntry.TempOri_Line, BegEntry.TempOri_Column);
  }
  OutputOS << llvm::format(
    "Time=\"%.9f\" Memory=\"%d\">\n", 
    EndEntry.TimeStamp - BegEntry.TimeStamp,
    EndEntry.MemoryUsage - BegEntry.MemoryUsage);
  
  // Print only first part (heading).
}
コード例 #5
0
ファイル: iau2kml.cpp プロジェクト: MChemodanov/marble
int main(int argc, char *argv[])
{
    QString  sourcefilename;
    QString  targetfilename;

    QCoreApplication  app( argc, argv );

    for ( int i = 1; i < argc; ++i ) {
        if ( strcmp( argv[ i ], "-o" ) != 0 )
            continue;

        targetfilename = QString(argv[i+1]);
        sourcefilename = QString(argv[i+2]);

        qDebug() << "Source: " << sourcefilename;
        qDebug() << "Target: " << targetfilename;

        QFile  sourcefile( sourcefilename );
        sourcefile.open( QIODevice::ReadOnly );

        // Read the data serialized from the file.
        QTextStream  sourcestream( &sourcefile );
        sourcestream.setCodec("UTF-8");

        QFile  targetfile( targetfilename );
        targetfile.open( QIODevice::ReadWrite );

        QTextStream  targetstream( &targetfile );
        targetstream.setCodec("UTF-8");

        // gzFile gzDoc = gzopen( targetfilename.toLatin1(), "w");
        // QTextStream targetstream( new QString() );

        targetstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
                     << "<kml xmlns=\"http://earth.google.com/kml/2.1\"> \n"
                     << "<Document> \n";

        targetstream << "    <Schema name=\"MarblePlacemark\" parent=\"Placemark\"> \n";
        targetstream << "       <SimpleField name=\"pop\" type=\"int\"></SimpleField> \n";
        targetstream << "       <SimpleField name=\"role\" type=\"string\"></SimpleField> \n";
        targetstream << "    </Schema> \n";

        targetstream << "\n";

        QString  rawline;
        QString  nameString;
        QString  latString;
        QString  lonString;
        QString  popString;
        QString  roleString;
        QString  description;
        float    lat;
        float    lon;
        int          population;
        QStringList  splitline;

        while ( !sourcestream.atEnd() ) {

            rawline = sourcestream.readLine();
//            if ( !rawline.startsWith("\"E\"|\"m\"|\"" ) ) {
            if ( !rawline.startsWith("\"V\"|\"V\"|\"" ) ) {
                continue;
            }
            rawline = rawline.replace( "\"|", "|" );
            rawline = rawline.replace( "|\"", "|" );
            if ( rawline.startsWith('\"') && rawline.endsWith('\"') ) {
                rawline = rawline.left( rawline.length() - 1 );
                rawline = rawline.right( rawline.length() - 2 );
            }

            splitline = rawline.split('|');

            nameString  = splitline[2];
            latString   = splitline[3];
            lonString   = splitline[4];
            popString   = splitline[10];
            roleString  = splitline[18];
            description = splitline[19];

            // if ( roleString == "SF" ) continue;

            QString marbleRoleString = 'o';

            if ( roleString == "AA" || roleString == "SF" ) marbleRoleString = "c";
            if (    roleString == "ME" || roleString == "OC" 
                 || roleString == "LC" || roleString == "SI" ) marbleRoleString = "a";
            if ( roleString == "MO" ) marbleRoleString = "m";
            if ( roleString == "VA" ) marbleRoleString = "v";

            population = (int) ( 1000.0 * popString.toFloat() );

            lon = lonString.toFloat();

            if ( lon > 180.0 ) lon = lon - 360.0;

            if ( rawline.startsWith("\"M\"|\"M\"|\"" ) || rawline.startsWith("\"V\"|\"V\"|\"" ) ) {
                lon = -lon;
            }

            lat = latString.toFloat();

            description = description.remove('"');

            targetstream << "    <MarblePlacemark> \n";
            targetstream << "        <name>" << escapeXml( nameString ) << "</name> \n";
            targetstream << "        <role>" << escapeXml( marbleRoleString ) << "</role> \n";
            targetstream << "        <pop>"
                         << escapeXml( QString::number( population ) ) << "</pop> \n";
            targetstream << "        <description>" << escapeXml( description ) << "</description> \n";
            targetstream << "        <Point>\n"
                         << "            <coordinates>"
                         << escapeXml( QString::number( lon ) )
                         << ","
                         << escapeXml( QString::number( lat ) )
                         << "</coordinates> \n"
                         << "        </Point> \n";
            targetstream << "    </MarblePlacemark> \n";
        }

        targetstream << "</Document> \n"
                     << "</kml> \n";
        qDebug("...");

        sourcefile.close();
        targetfile.close();

        qDebug("Finished!");
        return 0;
    }

    qDebug(" iau2kml -o targetfile sourcefile");
    app.exit();
}
コード例 #6
0
ファイル: asc2kml.cpp プロジェクト: PayalPradhan/marble
int main(int argc, char *argv[])
{
    QCoreApplication  app( argc, argv );

    for ( int i = 1; i < argc; ++i ) {
        if ( strcmp( argv[ i ], "-o" ) != 0 )
            continue;

        const QString targetfilename   = QString( argv[i+1] );
        const QString sourcefilename   = QString( argv[i+2] );
        const QString supportfilename  = QString( argv[i+3] );
        const QString timezonefilename = QString( argv[i+4] );

        qDebug() << "Source: " << sourcefilename;
        qDebug() << "Support: " << supportfilename;
        qDebug() << "Target: " << targetfilename;
        qDebug() << "Timezone: " << timezonefilename;

        QFile  sourcefile( sourcefilename );
        sourcefile.open( QIODevice::ReadOnly );

        // Read the data serialized from the file.
        QTextStream  sourcestream( &sourcefile );
        sourcestream.setCodec("UTF-8");

        QFile  targetfile( targetfilename );
        targetfile.open( QIODevice::WriteOnly );

        QTextStream  targetstream( &targetfile );
        targetstream.setCodec("UTF-8");

        QFile  supportfile( supportfilename );
        supportfile.open( QIODevice::ReadOnly );

        QTextStream  supportstream( &supportfile );
        supportstream.setCodec("UTF-8");

        QFile  timezonefile( timezonefilename );
        timezonefile.open( QIODevice::ReadOnly );

        QTextStream  timezonestream( &timezonefile );
        timezonestream.setCodec("UTF-8");

        // gzFile gzDoc = gzopen( targetfilename.toLatin1(), "w");
        // QTextStream targetstream( new QString() );

        targetstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"
                     << "<kml xmlns=\"http://earth.google.com/kml/2.1\"> \n"
                     << "<Document> \n";
        QString  state;
        QString  gmt;
        QString	 dst;

        while ( !sourcestream.atEnd() ) {

            const QString rawline = sourcestream.readLine();
            const QStringList splitline = rawline.split('\t');

            const QString name       = splitline[1];
            const QString latstring  = splitline[4];
            const QString lngstring  = splitline[5];
            const QString role       = splitline[7];
            const QString country    = splitline[8];
            const QString statecode  = splitline[10];
            const QString popstring  = splitline[14];
            const QString elestring  = splitline[16];
            const QString timezone   = splitline[17];
	
            supportstream.seek(0);
            while ( !supportstream.atEnd() ) {
                const QString supportrawline = supportstream.readLine();
                const QStringList supportsplitline = supportrawline.split('\t');
                if(supportsplitline[0] == (country + '.' +statecode))
                {
                    state = supportsplitline[1];
                    break;
                }
            }   

            timezonestream.seek(0);
            timezonestream.readLine();
            while ( !timezonestream.atEnd() ) {
                    const QString timezonerawline = timezonestream.readLine();
                    const QStringList timezonesplitline = timezonerawline.split('\t');

                    if( timezonesplitline[0] == timezone )
                    {
                        gmt = timezonesplitline[1];
                        dst = timezonesplitline[2];
                        break;
                    }
            }

            const int gmtoffset = ( int ) ( gmt.toFloat() * 100 );
            const int dstoffset = ( int ) ( dst.toFloat() * 100 ) - gmtoffset;
	
            if(role != "PPLX")
            {          
	            targetstream << "    <Placemark> \n";
         	    targetstream << "        <name>" << escapeXml( name ) << "</name> \n";
                targetstream << "        <state>" << escapeXml( state ) << "</state> \n";
      	        targetstream << "        <CountryNameCode>" << escapeXml( country.toUpper() ) << "</CountryNameCode>\n";
        	    targetstream << "        <role>" << escapeXml( role ) << "</role> \n";
        	    targetstream << "        <pop>"
                             << escapeXml( popstring ) << "</pop> \n";
           	    targetstream << "        <Point>\n"
                        	 << "            <coordinates>"
                      		 << escapeXml( lngstring )
                        	 << ","
                        	 << escapeXml( latstring )
				<< ","
                             << escapeXml( elestring )
	                         << "</coordinates> \n"
	                         << "        </Point> \n";
		        targetstream << "        <ExtendedData>\n"
                                 << "            <Data name=\"gmt\">\n"
                                 << "                <value>" << escapeXml( QString::number( gmtoffset ) ) << "</value>\n"
                                 << "            </Data>\n";
                    if( dstoffset )
                    {
                        targetstream << "            <Data name=\"dst\">\n"
                                 << "                <value>" << escapeXml( QString::number( dstoffset) ) << "</value>\n"
                                 << "            </Data>\n";
                    }
                    targetstream << "        </ExtendedData>\n";  
	            targetstream << "    </Placemark> \n";
            }
        }

        targetstream << "</Document> \n"
                     << "</kml> \n";
        qDebug("Putting");

        // gzputs( gzDoc, targetstream.readAll().toUtf8() );
        // gzclose( gzDoc );

        sourcefile.close();
        targetfile.close();
        supportfile.close();
        timezonefile.close();
        qDebug("Finished!");
        return 0;
    }

    qDebug(" asc2kml -o targetfile sourcefile supporfile timezonefile");
    app.exit();
}