Exemplo n.º 1
0
void Step3_Convert(const TString filename)
{
    TFile* file = new TFile(filename, "READ");

    std::vector<TString> hists;
    // No bracket enclosed initializer list in root 5
    hists.push_back("NeulandDigiMon/hDepth");
    hists.push_back("NeulandDigiMon/hForemostEnergy");
    hists.push_back("NeulandDigiMon/hEtot");

    //for (const TString& hist : hists)
    for(Int_t i = 0; i < hists.size(); i++)
    {
        const TString hist = hists.at(i);
        std::cout << hist << std::endl;
        TH1D* h = (TH1D*)file->GetObjectChecked(hist, "TH1D");

        const TString outfile = (TString(filename).ReplaceAll("digi.root", TString(hist).ReplaceAll("NeulandDigiMon/", "") + ".dat"));
        ofstream outstream(outfile);

        SingleExportAscii(h, outstream);

        outstream.close();
    }
}
Exemplo n.º 2
0
    //---------------------------------------------------------------------
    DataStreamPtr FreeImageCodec::code(MemoryDataStreamPtr& input, Codec::CodecDataPtr& pData) const
    {        
		// Set error handler
		FreeImage_SetOutputMessage(FreeImageSaveErrorHandler);

		FIBITMAP* fiBitmap = encode(input, pData);

		// open memory chunk allocated by FreeImage
		FIMEMORY* mem = FreeImage_OpenMemory();
		// write data into memory
		FreeImage_SaveToMemory((FREE_IMAGE_FORMAT)mFreeImageType, fiBitmap, mem);
		// Grab data information
		BYTE* data;
		DWORD size;
		FreeImage_AcquireMemory(mem, &data, &size);
		// Copy data into our own buffer
		// Because we're asking MemoryDataStream to free this, must create in a compatible way
		BYTE* ourData = OGRE_ALLOC_T(BYTE, size, MEMCATEGORY_GENERAL);
		memcpy(ourData, data, size);
		// Wrap data in stream, tell it to free on close 
		DataStreamPtr outstream(OGRE_NEW MemoryDataStream(ourData, size, true));
		// Now free FreeImage memory buffers
		FreeImage_CloseMemory(mem);
		// Unload bitmap
		FreeImage_Unload(fiBitmap);

		return outstream;


    }
void JRoomModelClientRoomProcessor::requestRoomList()
{
    QByteArray outdata;
    QDataStream outstream(&outdata,QIODevice::WriteOnly);
    outstream<<(JID)ERP_RoomList;
    sendData(JRoomModelClientSocket::instance(),outdata);
}
/**
@brief This function demonstrates how to perform "Textless Lipsync"

Given an audio file, this method will use SAPI to guess at words
and word timings and phoneme timings in the specified audio file. 
The results are printed to std::out.

This is the best code to look at first

@param strAudioFile - [in] audio file
**/
void
run_sapi_textless_lipsync(std::wstring& strAudioFile, std::wstring outFile)
{
	// 1. [optional] declare the SAPI 5.1 estimator. 
	// NOTE: for different phoneme sets: create a new estimator
	phoneme_estimator sapi51Estimator;

	// 2. declare the sapi lipsync object and call the lipsync method to
	// start the lipsync process
	sapi_textless_lipsync lsp(&sapi51Estimator);
	if (lsp.lipsync(strAudioFile))
    {
		// 3. Run the message loop and wait till the lipsync is finished
        run_lipsync_message_loop(lsp);
		
		// 4. finalize the lipsync results for printing
		// this call will estimate phoneme timings 
		lsp.finalize_phoneme_alignment();

		// 5. print the results to the output stream
		//lsp.print_results(std::cout);
		
		// 5'. print results in a file
		std::wstring strOutFile = outFile + L".phonemes.xml";
		std::ofstream outstream(strOutFile.c_str());
		outstream << "<PhonemeTimings audiofile=\"" << wstring_2_string(strAudioFile) << "\" >" << std::endl;
		lsp.print_results(outstream);
		outstream << "</PhonemeTimings>" << std::endl;
		outstream.close();            
	}
	else
	{
		std::wcerr << lsp.getErrorString() << std::endl;
	}
}
Exemplo n.º 5
0
    //---------------------------------------------------------------------
    DataStreamPtr FreeImageCodec::code(MemoryDataStreamPtr& input, Codec::CodecDataPtr& pData) const
    {        
		FIBITMAP* fiBitmap = encode(input, pData);

		// open memory chunk allocated by FreeImage
		FIMEMORY* mem = FreeImage_OpenMemory();
		// write data into memory
		FreeImage_SaveToMemory((FREE_IMAGE_FORMAT)mFreeImageType, fiBitmap, mem);
		// Grab data information
		BYTE* data;
		DWORD size;
		FreeImage_AcquireMemory(mem, &data, &size);
		// Copy data into our own buffer
		BYTE* ourData = new BYTE[size];
		memcpy(ourData, data, size);
		// Wrap data in stream, tell it to free on close 
		DataStreamPtr outstream(new MemoryDataStream(ourData, size, true));
		// Now free FreeImage memory buffers
		FreeImage_CloseMemory(mem);
		// Unload bitmap
		FreeImage_Unload(fiBitmap);

		return outstream;


    }
void JRequestGameInfoSocket::rqsGameList()
{
    QByteArray outdata;
    QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<(JID)SubServer::EGP_GameList;
    sendData(outdata);
}
Exemplo n.º 7
0
bool WebGame::Utility::writeToFile(const Utility::StringGroupType& infos,
    const std::string& file_name,
    const std::string&
#ifdef WIN32

     locinfo
#endif
     ) {
#ifdef WIN32
  std::locale loc = std::locale::global(std::locale(locinfo.c_str())) ;
#endif
  std::ofstream outstream(file_name.c_str(), std::ios_base::out |
      std::ios_base::trunc) ;
  if(!outstream.is_open()) {
#ifdef WIN32
    std::locale::global(loc) ;
#endif
    return false ;
  }
  bool ok = writeToFile(infos, outstream) ;
#ifdef WIN32
  std::locale::global(loc) ;
#endif
  return ok ;
}
Exemplo n.º 8
0
//New saveUserLog, moved from DetailDialog.  
//Should create a special UserLog widget that encapsulates the "default"
//message in the widget when no log exists (much like we do with dmsBox now)
void SkyObject::saveUserLog( const QString &newLog ) {
	QFile file;
	QString logs; //existing logs
	
	//Do nothing if new log is the "default" message
	//(keep going if new log is empty; we'll want to delete its current entry)
	if ( newLog == (i18n("Record here observation logs and/or data on %1.").arg(name())) || newLog.isEmpty() )
		return;

	// header label
	QString KSLabel ="[KSLABEL:" + name() + "]";
	//However, we can't accept a star name if it has a greek letter in it:
	if ( type() == STAR ) {
		StarObject *star = (StarObject*)this;
		if ( name() == star->gname() ) 
			KSLabel = "[KSLABEL:" + star->gname( false ) + "]"; //"false": spell out greek letter
	}
	
	file.setName( locateLocal( "appdata", "userlog.dat" ) ); //determine filename in local user KDE directory tree.
	if ( file.open( IO_ReadOnly)) {
		QTextStream instream(&file);
		// read all data into memory
		logs = instream.read();
		file.close();
	}
	
	//Remove old log entry from the logs text
	if ( ! userLog.isEmpty() ) {
		int startIndex, endIndex;
		QString sub;
	
		startIndex = logs.find(KSLabel);
		sub = logs.mid (startIndex);
		endIndex = sub.find("[KSLogEnd]");
	
		logs.remove(startIndex, endIndex + 11);
	}
	
	//append the new log entry to the end of the logs text,
	//but only if the log is not empty
	if ( ! newLog.stripWhiteSpace().isEmpty() )
		logs.append( KSLabel + "\n" + newLog + "\n[KSLogEnd]\n" );
	
	//Open file for writing
	//FIXME: change error message to "cannot write to user log file"
	if ( !file.open( IO_WriteOnly ) ) {
		kdDebug() << i18n( "user log file could not be opened." ) << endl;
		return;
	}
	
	//Write new logs text
	QTextStream outstream(&file);
	outstream << logs;
	
	//Set the log text in the object itself.
	userLog = newLog;
	
	file.close();
}
void JRoomModelClientRoomProcessor::sendRoomChat(const QString& text)
{
    QByteArray outdata;
    QDataStream outstream(&outdata,QIODevice::WriteOnly);
    outstream<<(JID)ERP_RoomChat;
    outstream<<text;
    sendData(JRoomModelClientSocket::instance(),outdata);
}
void JRoomModelClientRoomProcessor::requestEnterRoom(JID roomId)
{
    QByteArray outdata;
    QDataStream outstream(&outdata,QIODevice::WriteOnly);
    outstream<<(JID)ERP_EnterRoom;
    outstream<<roomId;
    sendData(JRoomModelClientSocket::instance(),outdata);
}
void JRoomModelClientRoomProcessor::sendHello(JID userId)
{
    QByteArray outdata;
    QDataStream outstream(&outdata,QIODevice::WriteOnly);
    outstream<<(JID)ERP_Hello;
    outstream<<userId;
    sendData(JRoomModelClientSocket::instance(),outdata);
}
/*!
	\brief 发送游戏信息
	
	\a gi 表示游戏信息。
	
	\sa SubServer::SGameInfo2
*/
void JSendGsInfoSocket::sendGameInfo(const SubServer::SGameInfo2& gi)
{
	QByteArray outdata;
	QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<(JID)SubServer::ESP_GameInfo;
	outstream<<gi;
	sendData(outdata);
}
/*!
	\brief 发送服务器信息
	
	\a ss 表示服务器信息。
	
	\sa SubServer::SSubServer
*/
void JSendGsInfoSocket::sendServerInfo(const SubServer::SSubServer& ss)
{
	QByteArray outdata;
	QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<(JID)SubServer::ESP_ServerInfo;
	outstream<<ss;
	sendData(outdata);
}
void JMainServerCommandProcessor::replyCommandResult(JID type,JCode result)
{
	QByteArray outdata;
	QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<type;
	outstream<<result;
	sendData(outdata);
}
void JDownloadGameFileSocket::rqsGameFile(const QString& gamename,const JVersion& version,const QString& path)
{
	m_path=path;
	QByteArray outdata;
	QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<gamename<<version;
	sendData(outdata);
}
void JRequestGameInfoSocket::rqsServerInfo(JID serverId)
{
	QByteArray outdata;
	QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<(JID)SubServer::EGP_ServerInfo;
	outstream<<serverId;
	sendData(outdata);
}
void JRequestGameInfoSocket::sendCrypro(JID id,const QByteArray& crypro)
{
    QByteArray outdata;
	QDataStream outstream(&outdata,QIODevice::WriteOnly);
    outstream<<id;
    outstream<<crypro;
    sendData(outdata);
}
void JRequestGameInfoSocket::rqsServers(JID gameId,const JVersion& version)
{
    QByteArray outdata;
    QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<(JID)SubServer::EGP_Servers;
	outstream<<gameId;
	outstream<<version;
    sendData(outdata);
}
Exemplo n.º 19
0
    void storeRegionInfo(const QVector<ExonData>& exons)
    {
		QSharedPointer<QFile> out = Helper::openFileForWriting("regions.tsv");
        QTextStream outstream(out.data());
        outstream << "#region\tsize\tmedian_ncov\tmad_ncov\tcv_ncov\tcnvs" << endl;
        foreach(const ExonData& exon, exons)
        {
            outstream << exon.name << "\t" << (exon.end-exon.start) << "\t" << exon.median << "\t" << exon.mad  << "\t" << (exon.mad/exon.median) << "\t" << exon.cnvs << endl;
        }
    }
Exemplo n.º 20
0
    void storeSampleCorrel(const QVector<SampleData>& data)
    {
		QSharedPointer<QFile> out = Helper::openFileForWriting("samples_correl_all.tsv");
        QTextStream outstream(out.data());
        outstream << "#sample\tdoc_mean\tref_correl\tqc" << endl;
        foreach(const SampleData& sample, data)
        {
            outstream << sample.name << "\t" << sample.doc_mean << "\t" << sample.ref_correl << "\t" << sample.qc << endl;
        }
    }
/*!
	\brief 发送关联信息
	
	\a serverId 表示服务器ID,\a gameId 表示游戏ID,\a gameVersion 表示游戏版本。
	
	关联信息表示服务器\a serverId 为\a gameId 的\a gameVersion 版本的游戏提供服务。
*/
void JSendGsInfoSocket::sendRelation(JID serverId,
								 JID gameId,
								 const JVersion& gameVersion)
{
	QByteArray outdata;
	QDataStream outstream(&outdata,QIODevice::WriteOnly);
	outstream<<(JID)SubServer::ESP_Relation;
	outstream<<serverId<<gameId<<gameVersion;
	sendData(outdata);
}
Exemplo n.º 22
0
/// \brief Writes the network to file.
/// \param filename A string
/// If filename is nonempty, output is written to the file named filename.
/// If filename is empty, output is written to stdout.
/// The processes are not written to file, only the filenames of the original processes.
void network::save(const std::string& filename) const
{
  std::ofstream outstream(filename.c_str(), std::ofstream::out);
  if (!outstream)
  {
    throw mcrl2::runtime_error("cannot open output file: " + filename);
  }
  write(outstream);
  outstream.close();
}
Exemplo n.º 23
0
    void storeSampleInfo(const QVector<SampleData>& data)
    {
		QSharedPointer<QFile> out = Helper::openFileForWriting("samples.tsv");
        QTextStream outstream(out.data());
        outstream << "#sample\tdoc_mean\tref_correl\tcnvs\tcnvs_merged" << endl;
        foreach(const SampleData& sample, data)
        {
            if (sample.qc!="") continue;
            outstream << sample.name << "\t" << sample.doc_mean << "\t" << sample.ref_correl << "\t" << sample.cnvs << "\t" << sample.cnvs_merged << endl;
        }
    }
Exemplo n.º 24
0
QString dataController::addSection(QString sectionInfo) {
    QFile file("../ServerSide/Data/Sections.txt");
    if(!file.open(QIODevice::Append))
    {
        qDebug() << "error opening the Section data" << endl;
    }

    QTextStream outstream(&file);
    outstream<<sectionInfo;

    file.close();
    return("yay");
}
Exemplo n.º 25
0
/* pipe an address through a command to translate it */
extern dest *
translate(dest *dp)
{
	process *pp;
	String *line;
	dest *rv;
	char *cp;
	int n;

	pp = proc_start(s_to_c(dp->repl1), (stream *)0, outstream(), outstream(), 1, 0);
	if (pp == 0) {
		dp->status = d_resource;
		return 0;
	}
	line = s_new();
	for(;;) {
		cp = Brdline(pp->std[1]->fp, '\n');
		if(cp == 0)
			break;
		if(strncmp(cp, "_nosummary_", 11) == 0){
			nosummary = 1;
			continue;
		}
		n = Blinelen(pp->std[1]->fp);
		cp[n-1] = ' ';
		s_nappend(line, cp, n);
	}
	rv = s_to_dest(s_restart(line), dp);
	s_restart(line);
	while(s_read_line(pp->std[2]->fp, line))
		;
	if ((dp->pstat = proc_wait(pp)) != 0) {
		dp->repl2 = line;
		rv = 0;
	} else
		s_free(line);
	proc_free(pp);
	return rv;
}
Exemplo n.º 26
0
bool wxXmlSerializer::SerializeToXml(const wxString& file, bool withroot)
{
	wxFileOutputStream outstream(file);

	if(outstream.IsOk())
	{
		return this->SerializeToXml(outstream, withroot);
	}
	else
		m_sErr = wxT("Unable to initialize output file stream.");

	return false;
}
Exemplo n.º 27
0
void HistoryDialog::on_savePushButton_clicked()
{
    QString filename = QFileDialog::getSaveFileName(this, "Save macro",
                                                    workspace_->directory(),
                                                    "Text files (*.txt)");
    if (filename.isEmpty()) return;
    QFile outfile(filename);
    outfile.open(QFile::WriteOnly);
    QTextStream outstream(&outfile);
    for (int i = 0; i < ui->actionsListWidget->count(); ++i)
        outstream << ui->actionsListWidget->item(i)->text() << "\n";
    outfile.close();
}
Exemplo n.º 28
0
QString dataController::addChapter(QString chapterInfo) {
    QFile file("../ServerSide/Data/Chapters.txt");
    if(!file.open(QIODevice::Append))
    {
        qDebug() << "error opening the Chapter data" << endl;
    }

    QTextStream outstream(&file);
    outstream<<chapterInfo;

    file.close();
    return("yay");
}
Exemplo n.º 29
0
void FBX::Node::Dump(
    std::shared_ptr<Assimp::IOStream> outfile,
    bool binary, int indent
) {
    if (binary) {
        Assimp::StreamWriterLE outstream(outfile);
        DumpBinary(outstream);
    } else {
        std::ostringstream ss;
        DumpAscii(ss, indent);
        std::string s = ss.str();
        outfile->Write(s.c_str(), s.size(), 1);
    }
}
/**
@brief This function demonstrates how to perform "Text Based Lipsync"

Given an audio file and a text file, this method will generate word timings and
phoneme timings of the text file to the audio file using sapi_lipsync and
helpers.

This is the best code to look at first.

The results are printed to std::out
@param strAudioFile - [in] audio file
@param strTextFile - [in] text file
**/
void
run_sapi_textbased_lipsync(std::wstring& strAudioFile, TCHAR *strTextFile, std::wstring outFile)
{
	// 1. [optional] declare the SAPI 5.1 estimator. 
	// NOTE: for different phoneme sets, create a new estimator
	phoneme_estimator sapi51Estimator;

	// 2. Load the text file into memory
	WCHAR * pwszCoMem = 0;
	ULONG cch = 0;
    HRESULT hr = GetTextFile(strTextFile, &pwszCoMem, &cch);
	if (hr == S_OK)
    {
		std::wstring strText(pwszCoMem, cch);

		// 3. declare the sapi lipsync object and call the lipsync method 
		// to start the lipsync process
        sapi_textbased_lipsync lsp(&sapi51Estimator);
		if (lsp.lipsync(strAudioFile, strText))
		{

			// 4. Run the message loop and wait till the lipsync is 
			// finished
			run_lipsync_message_loop(lsp);
              
			// 5. finalize the lipsync results for printing
			// this call will estimate phoneme timings 
			lsp.finalize_phoneme_alignment();
			
			// 6. print the results to the output stream
			//lsp.print_results(std::cout);
			
			// 6'. print results in a file
			std::wstring strOutFile = outFile + L".phonemes.xml";
			std::ofstream outstream(strOutFile.c_str());
			outstream << "<PhonemeTimings audiofile=\"" << wstring_2_string(strAudioFile) << "\" >" << std::endl;
			lsp.print_results(outstream);
			outstream << "</PhonemeTimings>" << std::endl;
			outstream.close();             
		}
		else
		{
			std::wcerr << lsp.getErrorString() << std::endl;			
		}
	}
	else
	{
		std::wcerr << L"Can't open text transcript file" << std::endl;
	}
}