コード例 #1
0
ファイル: commandlinethread.cpp プロジェクト: ripples/paol
void CommandLineThread::writeInfoFile() {
    // Set info file path
    string infoPath = lecturePath + "/INFO";
    // Construct stream to write to info file
    QFile infoFile(QString::fromStdString(infoPath));
    infoFile.open(QIODevice::WriteOnly | QIODevice::Text);
    QTextStream infoStream(&infoFile);

    // Format course start time
    char formatDateBuffer[80];
    struct tm * localTime;
    localTime = localtime(&startTime);
    //2014,12,04,12,55,01
    strftime(formatDateBuffer,80,"%Y,%m,%d,%H,%M,%S",localTime);

    // Get host name
    char hostname[256];
    gethostname(hostname, 256);

    // Write the file
    infoStream << "[course]" << endl;
    infoStream << "id: " << course.c_str() << endl;
    infoStream << "term: " << semester.c_str() << endl;
    infoStream << endl;
    infoStream << "[pres]" << endl;
    infoStream << "start: " << formatDateBuffer << endl;
    infoStream << "duration: " << lectureDuration << endl;
    infoStream << "source: " << hostname << endl;
    infoStream << "timestamp: " << startTime << endl;
    infoStream << "whiteboardCount: " << whiteboardCount << endl;
    infoStream << "computerCount: " << vgaCount << endl;

    // Close the file
    infoFile.close();
}
コード例 #2
0
 boost::any Cache::get(IndexReaderPtr reader, EntryPtr key)
 {
     MapEntryAny innerCache;
     boost::any value;
     LuceneObjectPtr readerKey(reader->getFieldCacheKey());
     {
         SyncLock cacheLock(&readerCache);
         innerCache = readerCache.get(readerKey);
         if (!innerCache)
         {
             innerCache = MapEntryAny::newInstance();
             readerCache.put(readerKey, innerCache);
         }
         else if (innerCache.contains(key))
             value = innerCache[key];
         if (VariantUtils::isNull(value))
         {
             value = newLucene<CreationPlaceholder>();
             innerCache.put(key, value);
         }
     }
     if (VariantUtils::typeOf<CreationPlaceholderPtr>(value))
     {
         CreationPlaceholderPtr progress(VariantUtils::get<CreationPlaceholderPtr>(value));
         SyncLock valueLock(progress);
         if (VariantUtils::isNull(progress->value))
         {
             progress->value = createValue(reader, key);
             {
                 SyncLock cacheLock(&readerCache);
                 innerCache.put(key, progress->value);
             }
             
             FieldCachePtr wrapper(_wrapper);
             
             // Only check if key.custom (the parser) is non-null; else, we check twice for a single
             // call to FieldCache.getXXX
             if (!VariantUtils::isNull(key->custom) && wrapper)
             {
                 InfoStreamPtr infoStream(wrapper->getInfoStream());
                 if (infoStream)
                     printNewInsanity(infoStream, progress->value);
             }
         }
         return progress->value;
     }
     return value;
 }
コード例 #3
0
ファイル: Font.cpp プロジェクト: souxiaosou/aether3d
void ae3d::Font::LoadBMFontMetaText( const FileSystem::FileContentsData& metaData )
{
    std::stringstream metaStream( std::string( metaData.data.begin(), metaData.data.end() ) );

    std::string line;
    std::getline( metaStream, line );
    
    std::string token;
    
    // First line (info)
    std::stringstream infoStream( line );
    while (!infoStream.eof())
    {
        infoStream >> token;
        
        if (token.find( "padding" ) != std::string::npos)
        {
            const char a[ 2 ] = { token[  8 ], 0 };
            const char b[ 2 ] = { token[ 10 ], 0 };
            const char c[ 2 ] = { token[ 12 ], 0 };
            const char d[ 2 ] = { token[ 14 ], 0 };
            
            padding[ 0 ] = std::atoi( a );
            padding[ 1 ] = std::atoi( b );
            padding[ 2 ] = std::atoi( c );
            padding[ 3 ] = std::atoi( d );
        }
        else if (token.find( "spacing" ) != std::string::npos)
        {
            const char a[ 2 ] = { token[  8 ], 0 };
            const char b[ 2 ] = { token[ 10 ], 0 };
            
            spacing[ 0 ] = std::atoi( a );
            spacing[ 1 ] = std::atoi( b );
        }
    }
    
    std::getline( metaStream, line );
    
    // Second line (common)
    std::stringstream commonStream( line );

    while (!commonStream.eof())
    {
        commonStream >> token;
        
        if (token.find( "lineHeight" ) != std::string::npos)
        {
            const char a[ 3 ] = { token[ 11 ], token[ 12 ], 0 };
            
            lineHeight = std::atoi( a );
        }
        else if (token.find( "base" ) != std::string::npos)
        {
            const char a[ 3 ] = { token[ 5 ], token[ 6 ], 0 };
            
            base = std::atoi( a );
        }
    }
    
    // Third line (page)
    std::getline( metaStream, line );
    // Fourth line (chars)
    std::getline( metaStream, line );
    
    // Character tags.
    while (!metaStream.eof())
    {
        std::getline( metaStream, line );
        std::stringstream charStream( line );
        
        charStream.seekg( line.find( "id=" ) + 3 );
        int id;
        charStream >> id;

        if (id > 255)
        {
            continue;
        }

        charStream.seekg( line.find( "x=" ) + 2 );
        charStream >> chars[ id ].x;
        
        charStream.seekg( line.find( "y=" ) + 2 );
        charStream >> chars[ id ].y;
        
        charStream.seekg( line.find( "width=" ) + 6 );
        charStream >> chars[ id ].width;
        
        charStream.seekg( line.find( "height=" ) + 7 );
        charStream >> chars[ id ].height;
        
        charStream.seekg( line.find( "xoffset=" ) + 8 );
        charStream >> chars[ id ].xOffset;
        
        charStream.seekg( line.find( "yoffset=" ) + 8 );
        charStream >> chars[ id ].yOffset;
        
        charStream.seekg( line.find( "xadvance=" ) + 9 );
        charStream >> chars[ id ].xAdvance;
    }
}
コード例 #4
0
ファイル: services.cpp プロジェクト: tru7/linknx
void Services::stop()
{
    infoStream("Services") << "Stopping services" << endlog;
    timers_m.stopManager();
    knxConnection_m.stopConnection();
}