Example #1
0
void RPCServer::sendInputImages(quint64 client){
  if(global_options.diffraction_filename[0]){
    Image * a = sp_image_read(global_options.diffraction_filename,0);
    if(!a){
      qCritical("RPCServer: Could not open amplitudes file!");
      return;
    }
    QByteArray data;
    ImageStream instream(&data,QIODevice::WriteOnly);
    instream << a;
    call(client,QString("inputImageSent(QByteArray,QString)"),data,"amplitudes");
    sp_image_free(a);
  }
  if(global_options.real_image_filename[0]){
    Image * a = sp_image_read(global_options.real_image_filename,0);
    if(!a){
      qCritical("RPCServer: Could not open real image file!");
      return;
    }
    QByteArray data;
    ImageStream instream(&data,QIODevice::WriteOnly);
    instream << a;
    call(client,QString("inputImageSent(QByteArray,QString)"),data,"real_image");
    sp_image_free(a);
  }
}
Example #2
0
void ThumbnailPicker::parseGooglePage( QStringList &ImList, const QString &URL ) {
    QString tmpFile;
    QString PageHTML;

    //Read the google image page's HTML into the PageHTML QString:
    if ( KIO::NetAccess::exists(URL, KIO::NetAccess::SourceSide, this) && KIO::NetAccess::download( URL, tmpFile, this ) ) {
        QFile file( tmpFile );
        if ( file.open( QIODevice::ReadOnly ) ) {
            QTextStream instream(&file);
            PageHTML = instream.readAll();
            file.close();
            KIO::NetAccess::removeTempFile( tmpFile );
        } else {
            kDebug() << "Could not read local copy of google image page";
            KIO::NetAccess::removeTempFile( tmpFile );
            return;
        }
    } else {
        kDebug() << KIO::NetAccess::lastErrorString();
        return;
    }

    int index = PageHTML.indexOf( "src=\"http:", 0 );
    while ( index >= 0 ) {
        index += 5; //move to end of "src=\"http:" marker

        //Image URL is everything from index to next occurrence of "\""
        ImList.append( PageHTML.mid( index, PageHTML.indexOf( "\"", index ) - index ) );

        index = PageHTML.indexOf( "src=\"http:", index );
    }
}
Example #3
0
File: DOCCom.cpp Project: YPench/EN
void DOCCOM::Load_LDA_Phi_or_Theta(const char* cloadpath, vector<vector<double>*>& LDAphitheta_vv)
{
	char getlineBuf[MAX_DOC_BUFFER];
	double phi;
	ifstream in(cloadpath);
	if(in.bad())
		return;
	in.clear();
	in.seekg(0, ios::beg);
	if(in.peek() == EOF){
		in.close();
		return;
	}
	while(in.peek() != EOF){
		in.getline(getlineBuf, MAX_DOC_BUFFER,'\n');
		istringstream instream(getlineBuf);
		vector<double>* pPhi_v = new vector<double>;
		LDAphitheta_vv.push_back(pPhi_v);
		while(instream.peek() != EOF){
			instream >> phi;
			instream.getline(getlineBuf, MAX_DOC_BUFFER,' ');
			pPhi_v->push_back(phi);
		}
	}
	in.close();
}
Example #4
0
void wxSFCanvasState::Restore(wxSFShapeCanvas* canvas)
{
    wxASSERT(canvas);
    wxASSERT(canvas->GetDiagramManager());

	if( m_pDataManager )
	{
		// copy content of stored temporal data manager into the currently used one
		canvas->GetDiagramManager()->CopyItems(m_pDataManager);
		canvas->Refresh(false);
	}
	else
	{
		// create input stream from local memory buffer
		wxMemoryInputStream instream(m_dataBuffer.GetData(), m_dataBuffer.GetDataLen()-1);

		// deserialize canvas content
		if(instream.IsOk() && canvas && canvas->GetDiagramManager())
		{
			// clear all previous canvas content
			canvas->GetDiagramManager()->Clear();
			canvas->GetDiagramManager()->DeserializeFromXml(instream);
			canvas->Refresh(false);
		}
	}
}
Example #5
0
int main(int argc, char *argv[])
{
    std::string code;
    if (argc != 2)
    {
        std::cerr << "Usage: fbi <codefile>" << std::endl;
        return 1;
    }
    
    // Read code
    std::ifstream instream(argv[1]);
    if (!instream.is_open())
    {
        std::cerr << "Could not open file!" << std::endl;
        return 1;
    }

    std::string line;
    while (!instream.eof())
    {
        std::getline(instream, line);
        code.append(line);
    }

    Interpreter interpreter;
    if (!interpreter.run(code))
        return 1;
    return 0;
}
Example #6
0
MDFlib::MDFTX::MDFTX(QFile* file, long pTX, unsigned short byteOrder)
{
    myMDFFile = file;
    QByteArray byteArray;
    QDataStream instream(myMDFFile);

    QString blockType;
    unsigned short blockSize;
    QString text;

    if(byteOrder == 0)
    {
        instream.setByteOrder(QDataStream::LittleEndian);
    }
    else
    {
        instream.setByteOrder(QDataStream::BigEndian);
    }
    myMDFFile->seek(pTX);

    byteArray = myMDFFile->read(2);
    blockType.append(byteArray.data());

    myMDFFile->seek(pTX + 2);
    instream >> blockSize;

    myMDFFile->seek(pTX + 4);
    byteArray = myMDFFile->read(blockSize);
    text.append(byteArray.data());

    setBlockType(&blockType);
    setBlockSize(blockSize);
    setText(&text);
}
Example #7
0
File: DOCCom.cpp Project: YPench/EN
void DOCCOM::Load_Event_Top_Terms(const char* ladpath, vector<vector<string>*>& pmEventTopTerm_vv)
{
	char SentenceBuf[MAX_SENTENCE];

	ifstream in(ladpath);
	if(in.bad())
		return;
	in.clear();
	in.seekg(0, ios::beg);
	if(in.peek() == EOF){
		in.close();
		return;
	}
	while(in.peek() != EOF){
		in.getline(SentenceBuf, MAX_SENTENCE,'\n');
		in.getline(SentenceBuf, MAX_SENTENCE,'\n');
		istringstream instream(SentenceBuf);
		vector<string>* pTerm_v = new vector<string>;
		pmEventTopTerm_vv.push_back(pTerm_v);
		while(instream.peek() != EOF){
			instream.getline(SentenceBuf, MAX_SENTENCE,';');
			pTerm_v->push_back(SentenceBuf);
		}
		in.getline(SentenceBuf, MAX_SENTENCE,'\n');
	}
	in.close();
}
// --------------------------------------------------------------------------
void voDelimitedTextPreviewModelPrivate::loadFile()
{
  Q_ASSERT(QFile::exists(this->FileName));
  QFile infile(this->FileName);
  bool openStatus = infile.open(QIODevice::ReadOnly);
  if (!openStatus)
    {
    qWarning() << QObject::tr("File ") << this->FileName << QObject::tr(" could not be opened for reading.  Did something change between when you selected the file and now?");
    return;
    }

  // Read file
  QTextStream instream(&infile);
  QStringList sampleLinesList;
  for (int i = 0; i < this->NumberOfRowsToPreview && !instream.atEnd(); i++)
    {
    sampleLinesList << instream.readLine();
    }

  // Push lines to temp file
  QString sampleLines;
  sampleLines = sampleLinesList.join("\n");
  bool status = this->SampleCacheFile.open();
  if (!status)
    {
    qWarning() << QObject::tr("Couldn't open temporary file for preview!");
    return;
    }
  this->SampleCacheFile.write(sampleLines.toAscii());

  this->SampleCacheFile.close();
}
Example #9
0
File: DOCCom.cpp Project: YPench/EN
void DOCCOM::Load_LDA_Wordmap(const char* cloadpath, map<size_t, size_t>& LDAIndex2TermID_m)
{
	char SentenceBuf[MAX_SENTENCE];
	size_t doc_size;
	size_t TermID;
	size_t LDATermIndex;

	ifstream in(cloadpath);
	if(in.bad())
		return;
	in.clear();
	in.seekg(0, ios::beg);
	if(in.peek() == EOF){
		in.close();
		return;
	}
	in >> doc_size;
	in.getline(SentenceBuf, MAX_SENTENCE, '\n');
	for(size_t i = 0; i < doc_size; i++){
		in.getline(SentenceBuf, MAX_SENTENCE, '\n');
		istringstream instream(SentenceBuf);
		instream >> TermID;
		instream.getline(SentenceBuf, MAX_SENTENCE, ' ');
		instream >> LDATermIndex;
		LDAIndex2TermID_m.insert(make_pair(LDATermIndex, TermID));
	}
	in.close();
}
	/*****************************************************
	**
	**   AtlasImportWorker   ---   readZipFile
	**
	******************************************************/
	int readZipFile()
	{
		wxString buf;

		wxFFileInputStream instream( sharedSection->sqlfile );
		wxZipInputStream zipstream( instream );
		wxTextInputStream textstream( zipstream );
		wxZipEntry *zipentry = zipstream.GetNextEntry();

		sharedSection->totalSize = (long)zipstream.GetSize();

		if ( zipentry )
		{
			printf( "Entry: %s\n", str2char( zipentry->GetName()));
			bool b = zipstream.OpenEntry( *zipentry );
			printf( "Open flag_ %d\n", b );

			while( zipstream.GetLastError() == wxSTREAM_NO_ERROR )
			{
				sharedSection->currentLine++;
				buf = textstream.ReadLine();
				if ( checkCancelOrExit() ) break;
				addQueryPart( buf );
				if ( checkCancelOrExit() ) break;
			}
			zipstream.CloseEntry();
		}
		else
		{
			printf( "Entry NULL\n" );
		}
		if ( qb.size() > 0 ) execQueryBundle();
		return 0;
	}
Example #11
0
Script::String overloadedLoad(const Script::String& filename) {
	std::string name(Pika::toStdString(filename));	// Sorry, can't pass a wchar_t filename. MSVC supports it, but it is non-standard. So we convert to a std::string to be on the safe side.
	{
		std::basic_ifstream<Script::Char> instream(name.c_str());
		if (instream.good()) return loadFile(instream, filename);
	}
	if (!pikaCmdDir.empty()) {
		std::basic_ifstream<Script::Char> instream((pikaCmdDir + name).c_str());
		if (instream.good()) return loadFile(instream, filename);
	}
	{
		for (int i = 0; i < sizeof (BUILT_IN_FILES) / sizeof (*BUILT_IN_FILES); ++i)
			if (filename == BUILT_IN_FILES[i].first) return BUILT_IN_FILES[i].second;
	}
	throw Script::Xception(Script::String("Cannot open file for reading: ") += Pika::escape(filename));
}
Example #12
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();
}
Example #13
0
TEUCHOS_UNIT_TEST(Teuchos_TwoDArrays, streamTests){
  TwoDArray<int> simpleArray = getSimpleTestTwoDArray();
  std::stringstream ss;
  ss << simpleArray;
  TwoDArray<int> readArray;
  std::istringstream instream(ss.str()); 
  instream >> readArray;
  TEST_EQUALITY(simpleArray, readArray);
}
Example #14
0
///////////////////////////////////////////////////////////////////////////////
//  Helper function reading a file into a string
///////////////////////////////////////////////////////////////////////////////
std::string read_from_file(char const* infile)
{
    std::ifstream instream(infile);
    if (!instream.is_open()) {
        std::cerr << "Couldn't open file: " << infile << std::endl;
        exit(-1);
    }
    instream.unsetf(std::ios::skipws);      // No white space skipping!
    return std::string(std::istreambuf_iterator<char>(instream.rdbuf()),
                       std::istreambuf_iterator<char>());
}
Example #15
0
/**
* @brief builds a song matching parameters file from the given info
* @param parametersFile - the name of the parameters data file
* @return a songMatchingParams object with the initialized data
*/
SongMatchingParams Parser::buildSongMatchParametrs(const std::string &parametersFile)
{
	std::ifstream instream(parametersFile.c_str()); 

	std::string currentLine;
	size_t pos;
	int tagMatchScore, lyricsMatchScore, instrumentMatchScore, bpmWeight;

	// gets the tagMatchScore
	getline(instream, currentLine);
	pos = TAG_MATCH_SCORE.size() + 2;
	tagMatchScore = stoi(currentLine.substr(pos));

	// gets the lyricsMatchScore
	getline(instream, currentLine);
	pos = LYRICS_MATCH_SCORE.size() + 2;
	lyricsMatchScore = stoi(currentLine.substr(pos));

	// gets the instrumentMatchScore
	getline(instream, currentLine);
	pos = INSTRUMENT_MATCH_SCORE.size() + 2;
	instrumentMatchScore = stoi(currentLine.substr(pos));

	// gets the bpmWeight
	getline(instream, currentLine);
	pos = BPM_WEIGHT.size() + 2;
	bpmWeight = stoi(currentLine.substr(pos));

	// gets the uniqe words vals
	double avgBpm, deviationBpm;
	std::map<std::string, std::pair<double, double>> uniqeWords;
	std::string word;
	std::pair<double, double> wordValues;
	std::pair<std::string, std::pair<double, double>> mapElement;
	while (getline(instream, currentLine))
	{
		if ((currentLine != "\n") && (currentLine != ""))
		{
			pos = currentLine.find(":");
			word = currentLine.substr(0, pos);
			currentLine = currentLine.substr(pos + 1, std::string::npos);
			pos = currentLine.find(",");
			avgBpm = stod(currentLine.substr(0, pos));
			deviationBpm = stod(currentLine.substr(pos + 1, std::string::npos));
			wordValues = std::pair<double, double>(avgBpm, deviationBpm);
			mapElement = std::pair<std::string, std::pair<double, double>>(word, wordValues);
			uniqeWords.insert(mapElement);
		}
	}

	SongMatchingParams songMatchingParams(uniqeWords, tagMatchScore, instrumentMatchScore, lyricsMatchScore,
		bpmWeight);
	return songMatchingParams;
}
Example #16
0
void CarmenLogReader::readLog(std::istream& _stream, std::vector<AbstractReading*>& _log) const{
    char buffer[MAX_LINE_SIZE];

    while(_stream){
	_stream.getline(buffer,MAX_LINE_SIZE);
	std::istringstream instream(buffer);
	AbstractReading *reading = readLine(instream);
	if (reading)
	    _log.push_back(reading);
    }
}
void ConvAutoTestCase::TestTextStream(const char *src,
                                      size_t srclength,
                                      const wxString& line1,
                                      const wxString& line2)
{
    wxMemoryInputStream instream(src, srclength);
    wxTextInputStream text(instream);

    CPPUNIT_ASSERT_EQUAL( line1, text.ReadLine() );
    CPPUNIT_ASSERT_EQUAL( line2, text.ReadLine() );
}
Example #18
0
/**
 * Initiates the InstrumentalSong with the given data.
 * @param title
 * @param tags
 * @param instruments
 * @param performedBy
 * @param bpm
 */
InstrumentalSong::InstrumentalSong(const std::string title, const std::string tags,
								   const std::string instruments, const std::string performedBy,
								   const double bpm) : Song(INSTRUMENTAL_SONG, title, tags),
								   _performedBy(performedBy), _bpm(bpm)
{
	std::istringstream instream(instruments);
	std::string instrument = "";
	while (std::getline(instream, instrument, ' '))
	{
		_instruments.insert(instrument);
	}
}
Example #19
0
string Huffman::readFile(string in)
{
	cout << "\nRead file " << in << ".txt  :" << endl;
	ifstream instream(in + ".txt");

	if (instream.is_open()) {
		while (getline(instream, words)) {
			instream >> words;
		}
	}
	return words;
}
Example #20
0
string indent(string const & str, int tabs)
{
    stringstream instream(str);
    stringstream outstream;
    string line;
    while (getline(instream, line, '\n')) {
        for (int i = 0; i != tabs; ++i)
            outstream << '\t';
        outstream << line << endl;
    }

    return outstream.str();
}
Example #21
0
bool udSettings::DeserializeFromXml(const wxString& file)
{
	if( wxFileExists(file) )
	{
		wxFileInputStream instream(file);
		return udSettings::DeserializeFromXml( instream );
	}
	else
	{
		this->CreateCategories();
		return false;
	}
}
Example #22
0
bool wxXmlSerializer::DeserializeFromXml(const wxString& file)
{
	wxFileInputStream instream(file);
	
	if(instream.IsOk())
	{
		return this->DeserializeFromXml(instream);
	}
	else
		m_sErr = wxT("Unable to initialize input stream.");
	
	return false;
}
Example #23
0
void slConfig::SetupGlobalconfig()
{
    SetRecordDefaults( true );
    const wxString global_config_path = GlobalConfigPath();

    if (  wxFileName::FileExists( global_config_path ) )
    {
        wxFileInputStream instream( global_config_path );
        if ( instream.IsOk() )
        {
            m_global_config = new wxFileConfig ( instream );
            m_global_config->SetRecordDefaults( false );
        }
    }
}
Example #24
0
/**
* @brief builds a vector of all queries
* @param queriesFile - the name of the queries file
* @return a vector of all queries
*/
std::vector<std::string> Parser::buildQueriesList(const std::string &queriesFile)
{
	std::ifstream instream(queriesFile.c_str());

	std::string query = "";
	std::vector<std::string> queriesList;

	while (instream >> query)
	{
		if (query != "\n")
		{
			queriesList.push_back(query);
		}
	}

	return queriesList;
}
Example #25
0
void sweetMeshTest(){
	std::cout << "inside SweetMeshTest()\n";
	std::ifstream instream("meshOriginal.rawhs");
	sweetMesh::hexMesh mesh;
	sweetMesh::readRAWHSfile(mesh, instream);
	instream.close();
	std::cout << "Done reading mesh\n";
	mesh.printStatistics();

	sweetMesh::visualMesh visMesh(mesh);
	visMesh.renderAllEdges = true;
	visMesh.renderAllSurfaceQuads = true;
	visMesh.refresh();
	
	cvcraw_geometry::write(cvcraw_geometry::geometry_t(visMesh), "meshOriginal.raw");
	std::cout << "Done with SweetMeshTest()\n";
}
Example #26
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	this->setWindowTitle("Авторизация");

	db = QSqlDatabase::addDatabase("QMYSQL");
	/*
	db.setHostName("127.0.0.1");
	db.setPort(3306);
	db.setDatabaseName("gkhdb");
	db.setUserName("root");
	db.setPassword("qwer");*/
	QFile file("./db.txt");
	if(!file.open(QIODevice::ReadOnly))
	{
		qDebug() << "error opening file: " << file.error();
		return;
	}
	QTextStream instream(&file);
	QString line = instream.readLine();
	db.setHostName(line);
	db.setPort(instream.readLine().toInt());
	db.setDatabaseName(instream.readLine());
	db.setUserName(instream.readLine());
	db.setPassword(instream.readLine());
	file.close();

	if (!db.open())
	{
		//Error *error = new Error();
		//error->show();
		qDebug()<<"Ошибка соединения";
	}
	QSqlQuery usertypeQuery;
	usertypeQuery.exec("SELECT * FROM usertype");
	while(usertypeQuery.next())
	{
		ui->usertype->addItem(usertypeQuery.value("typeuser").toString(),\
								usertypeQuery.value("id").toInt());
	}
}
int ReadFastaQueries(const string& filename,
                      vector< CRef<objects::CSeq_loc> >& seqs,
                      CRef<objects::CScope>& scope,
                      bool parse_deflines /* = false*/,
                      objects::CSeqIdGenerator* id_generator /* = NULL*/)
{
    seqs.clear();
    CNcbiIfstream instream(filename.c_str());
    if (!instream) {
        return -1;
    }

    CStreamLineReader line_reader(instream);
    CFastaReader::TFlags flags =  CFastaReader::fAssumeProt |
        CFastaReader::fForceType;
    
    if (!parse_deflines) {
        flags |= CFastaReader::fNoParseID;
    }

    CFastaReader fasta_reader(line_reader, flags);

    if (id_generator) {
        fasta_reader.SetIDGenerator(*id_generator);
    }

    scope->AddDefaults();
    while (!line_reader.AtEOF()) {

        CRef<CSeq_entry> entry = fasta_reader.ReadOneSeq();

        if (entry == 0) {
            return -1;
        }
        scope->AddTopLevelSeqEntry(*entry);
        CTypeConstIterator<CBioseq> itr(ConstBegin(*entry));
        CRef<CSeq_loc> seqloc(new CSeq_loc());
        seqloc->SetWhole().Assign(*itr->GetId().front());
        seqs.push_back(seqloc);
    }

    return 0;
}
int ReadMsa(const string& filename, CRef<CSeq_align>& align,
            CRef<CScope> scope, bool parse_deflines /* = false*/,
            objects::CSeqIdGenerator* id_generator /* = NULL*/)
{
    if (scope.Empty()) {
        return -1;
    }

    CNcbiIfstream instream(filename.c_str());
    if (!instream) {
        return -1;
    }
    CStreamLineReader line_reader(instream);

    CFastaReader::TFlags flags =  CFastaReader::fAssumeProt |
        CFastaReader::fForceType | CFastaReader::fValidate;
    
    if (!parse_deflines) {
        flags |= CFastaReader::fNoParseID;
    }

    CFastaReader fasta_reader(line_reader, flags);

    if (id_generator) {
        fasta_reader.SetIDGenerator(*id_generator);
    }

    CRef<CSeq_entry> entry = fasta_reader.ReadAlignedSet(-1);
    if (entry.Empty()) {
        return -1;
    }
    scope->AddTopLevelSeqEntry(*entry);

    // notify of a problem if the whole file was not read
    if (!line_reader.AtEOF()) {
        return -1;
    }

    align = entry->GetAnnot().front()->GetData().GetAlign().front();

    return 0;
}
Example #29
0
File: Act.cpp Project: YPench/EN
void CAct::Load_Action_Documents(const char* cPath, list<ACE_Action*>& Actions_l)
{
	char SentenceBuf[MAX_SENTENCE];

	ifstream in(cPath);
	if(in.bad())
		return;
	in.clear();
	in.seekg(0, ios::beg);
	if(in.peek() == EOF){
		in.close();
		return;
	}
	while(in.peek() != EOF){
		size_t entitycnt;
		ACE_Action* plocAction = new ACE_Action;
		in.getline(SentenceBuf, MAX_SENTENCE, '\n');
		istringstream instream(SentenceBuf);
		instream.getline(SentenceBuf, MAX_SENTENCE, '\t');
		plocAction->DOCID = SentenceBuf;
		instream >> plocAction->CASID;
		instream.getline(SentenceBuf, MAX_SENTENCE, '\t');
		instream >> plocAction->SENID;
		instream.getline(SentenceBuf, MAX_SENTENCE, '\t');
		instream.getline(SentenceBuf, MAX_SENTENCE, '\t');
		plocAction->TYPE = SentenceBuf;
		instream >> plocAction->value;

		in.getline(SentenceBuf, MAX_SENTENCE, '\n');
		plocAction->charseq = SentenceBuf;
		in >> entitycnt;
		in.getline(SentenceBuf, MAX_SENTENCE, '\n');
		list<string>& loc_l = plocAction->entity_mention_l;
		for(size_t i = 0; i < entitycnt; i++){
			in.getline(SentenceBuf, MAX_SENTENCE, '\n');
			loc_l.push_back(SentenceBuf);
		}
		Actions_l.push_back(plocAction);
	}

	in.close();
}
  bool Producer::CheckResponse(BrokerChannel* channel,
                               const string& topic_name,
                               const int32_t partition_id)
  {
    NetworkBufferedReader instream(channel, recv_buf_, recv_buf_size_);
    try {
      int32_t unused_length;
      instream.ReadInt32(&unused_length);
      int16_t unused_version_id;
      instream.ReadInt16(&unused_version_id);
      int32_t unused_correlation_id;
      instream.ReadInt32(&unused_correlation_id);
      int32_t topic_count;
      instream.ReadInt32(&topic_count);
      for (int i = 0; i < topic_count; ++i) {
        string recv_topic_name;
        instream.ReadShortString(recv_topic_name);
        int32_t partition_count;
        instream.ReadInt32(&partition_count);
        for (int j = 0; j < partition_count; ++j) {
          int32_t recv_partition_id;
          instream.ReadInt32(&recv_partition_id);
          int16_t error_code;
          instream.ReadInt16(&error_code);
          int64_t offset;
          instream.ReadInt64(&offset);
          if (!topic_name.compare(recv_topic_name) &&
              recv_partition_id == partition_id &&
              error_code == NoError) {
            return true;
          }

        }
      }
    }
    catch (std::exception ex) {
      std::cerr << "Exception in reading Producer response from Server."
                << std::endl;
      return false;
    }
    return false;
  }