Пример #1
0
char bibfile_parser::get_very_next_character(void)
{
  char c = char(bibfile.get());
  if (bibfile.eof()) {
    reached_end_of_file = true;
    return 0;
  }
  if (!bibfile.good()) {
    cerr << endl << "error reading input bibfile" << endl;
    exit(0);
  }
  return  c;
}
Пример #2
0
string readdata_ouput() // read data from file
{

	var_read.open("output.txt");
	var_int_loop_i = 0;
	if (var_read.eof()) {
		return 0;
	}
	while (!var_read.eof()) {
		var_read >> var_char_read;
		if (var_char_read >= 'A' && var_char_read <= 'Z') {
			var_char_read += 32;
		}
		if (var_char_read >= 'a' && var_char_read <= 'z') {
			encrypted1[var_int_loop_i] = var_char_read;
			var_int_loop_i++;
		}
	}
	encrypted1[var_int_loop_i - 1] = '\0';
	var_read.close();
	return encrypted1;
}
Пример #3
0
void getPrice(ifstream& file, int prices[], int entry) //Get the individual component prices
{
	int temp = 0;
	int count = 0;
	GotoLine(file, entry);

	while (!file.eof())
	{
		file >> temp;
		prices[count] = temp;
		count++;
	}
}
Пример #4
0
Piece::Piece(ifstream &in) : width_(0), height_(0), sin_(0), cos_(1), flip_(1) {
    string line;
    while (!in.eof()) {
        getline(in, line);
        size_t occ = line.find_last_of('#');
        if (!line.length() || string::npos==occ) break;
        width_ = max(width_, (int)occ+1);
        for (int i=0; i<(int)line.length(); i++) {
            if (line[i]=='#') coords_.push_back(Vec2i(i, height_));
        }
        height_++;
    }
}
Пример #5
0
float ComputePctScore(ifstream& input, int numScores)
{
  int total=0, possible=0;
  int score, high;
  float pct;
  while (!input.eof())
    {
      input >> score >> high;
      total += score;
      possible += high;
    }
  pct = 100.0 * total/possible;
}
Пример #6
0
int main(int argc, char **argv)
{
    setArgs(argc, argv);
    hintFile.open(fileName.c_str(), ios::in | ios::binary);

    while(!hintFile.eof())
    {
        EvictionRecord *er = new EvictionRecord();
        hintFile.read( (char *)er,sizeof(EvictionRecord));
        er->print();
    }
    hintFile.close();
}
Пример #7
0
/*POT_LJ_SPLINE ReadInput: READS AND STORES POTENTIAL PARAMETER VALUES*/
string POT_LJ_SPLINE::ReadInput(ifstream &Input) {
  string str;
  while(!Input.eof()) {
    str = Read_Next(Input);
    if(str.compare(0, 7, "epsilon", 7)==0) {Fill(epsilon, Input);} else
    if(str.compare(0, 5, "sigma"  , 5)==0) {Fill(sigma  , Input);} else
    if(str.compare(0, 3, "cutoff" , 3)==0) {Fill(cutoff , Input);} else
    if(str.compare(0, 3, "Acutoff", 3)==0) {Fill(Acutoff, Input);} else
    if(str.compare(0, 3, "rspline", 3)==0) {Fill(rspline, Input);} else
    {break;}
  }
  return(str);
}
Пример #8
0
void insertNext(PQ & pq, ifstream & fin, int limit)
{
	if (limit == 0)
		limit = numeric_limits<int>::max();
	string word;
	int ct;
	while (!fin.eof() && pq.size < limit)
	{
		pq.size++;
		fin >> word >> ct;
		pq.insert(ItemType(word, ct));
	}
}
Пример #9
0
void CDictionary::ReadTranslations(ifstream & input)
{
    string phrase, key, translation;
    while (!input.eof())
    {
        getline(input, phrase);
        translation = "oormveienrovenive";
        if (ParseTranslation(phrase, key, translation))
        {
            m_dictionary[key] = translation;
        }
    }
}
int main()
{
    #ifdef _PARSARE_
    freopen(nume ".in","r",stdin);
    cit(n);
    #endif
    
    vector<int> v;
    while(!fin.eof())
    {
        fin>>n;
        if(fin.eof())
            break;
        v.clear();
        for(int i=0;i<n;++i)
            fin>>x,v.push_back(x);
        fout<<mergesort(v).second<<'\n';
    }

    fout.close();
    return 0;
}
Пример #11
0
void ValueTable::ReturnValueTable(ifstream& f)
{
    m_str = "";
    char ch;

    while(!f.eof() && f.get(ch))
    {
        ++m_TableMap[ch];
        m_str += ch;
    }

    return;
}
Пример #12
0
ref_loc_t RefSeq::LoadNextSeq(ifstream &fin) {
    char ch[1000]; char c; string s;
    if(param.gz_ref) return 0;
    fin>>c; if(fin.eof()) return 0;
    string::iterator z=_seq.begin();
    _length=0;
    fin>>_name; fin.getline(ch, 1000);
    while(!fin.eof()) {
        fin>>c; if(fin.eof()) break;
        fin.unget(); if(c=='>') break;
        fin>>s;
        if(_length+s.size()>=param.max_dbseq_size) {
            param.max_dbseq_size+=param.append_dbseq_size;
            _seq.resize(param.max_dbseq_size);
            z=_seq.begin()+_length;
            //cout<<"_seq size: "<<param.max_dbseq_size<<endl;
        }
        copy(s.begin(), s.end(), z);
        z+=s.size(); _length+=s.size();
    }
    return _length;
}
Пример #13
0
    bool readPoints(ifstream &fin)
    {
        int state=0;
        char line[255];
        int nPointsC2;

        while (!fin.eof())
        {
            fin.getline(line,sizeof(line),'\n');
            Bottle b(line);
            Value firstItem=b.get(0);
            bool isNumber=firstItem.isInt() || firstItem.isDouble();

            if (state==0)
            {
                string tmp=firstItem.asString().c_str();
                std::transform(tmp.begin(),tmp.end(),tmp.begin(),::toupper);
                if (tmp=="OFF")
                    state++;
            }
            else if (state==1)
            {
                if (isNumber)
                {
                    nPointsC2=nPointsC=firstItem.asInt();;
                    state++;
                }
            }
            else if (state==2)
            {
                if (isNumber && (b.size()>=3))
                {
                    Vector point;
                    point.resize(3,0.0);

                    point[0]=b.get(0).asDouble();
                    point[1]=b.get(1).asDouble();
                    point[2]=b.get(2).asDouble();

                    point_cloud.push_back(point);

                    if (--nPointsC2<=0)
                        return true;
                }
            }
        }


        return false;

    }
Пример #14
0
void ReadDataFile(){
	cout << "Opening data file 'data_" << FileNumber << ".txt'..." << endl;
	string file = "data_" + FileNumber + ".txt";
	DataFile.open(file.c_str());
	if (!DataFile){
		TerminateError("Unable to open data file.");
	}
	ListNode<ListNodeData> *node = NULL;
	//Find the last node to append the list, if the list is already with items. 
	TheList.Rewind();
	while (TheList.Current() != NULL){
		node = TheList.Current();
		TheList.Next();
	}
	string text, dummy;
	int number;
	//Read data file into list
	while (!DataFile.eof()){
		GetLine(DataFile, text);		//GetLine gets rid of newline character.
		if (DataFile.eof()){			//EOF was reached before a number is read!? Means file is malformed. Ignoring final node.
			cout << "Unexpected end of file for data file. Finishing read." << endl;
			break;
		}
		DataFile >> number;
		getline(DataFile, dummy);	//Use GetLine to clear the newline character.
		//The default behaviour of inserting new nodes to the list is by inserting it at the first node.
		//So we need a "workaround" to build the list as it was defined in the data file.
		cout << "Appending Node " << text << " " << number << endl;
		if (node == NULL){
			node = TheList.InsertNewNode(ListNodeData(number, text));		//This is the first node.
		}
		else{
			node = TheList.AppendNode(node, ListNodeData(number, text));	//Append additional node behind the first node
		}
		
	}
	DataFile.close();
}
Пример #15
0
void add_plus_plus(ifstream& in_stream, ofstream& out_stream)
{
    char next;
    in_stream.get(next);
    while (! in_stream.eof( ))
    {
        if (next == 'C')
            out_stream << "C++";
        else
            out_stream << next;

        in_stream.get(next);
    }
}
Пример #16
0
void moveInsideFile(ifstream &f,int moveStep)
{
    //Use this function to move inside the file
    //per line number
    int i=0;
    string line;
    f.clear();
    f.seekg(0,ios::beg);
    while(i<moveStep && f.eof()!=true)
    {
        getline(f,line);
        i++;
    }
}
Пример #17
0
void getLineCoordVt(ifstream &myFile){

    double nombrex;
    double nombrey;
    std::string myString;
    while (!myFile.eof())
    {


      getline(myFile, myString);
	  if ((myString[0] == 'v') && (myString[1] == 't') && (myString[2] == ' ')) {

        myString.erase(myString.begin(),myString.begin()+3);
		  int i = 0;
		  while (myString[i] == ' ') {
			  i++;
		  }
		  while (myString[i] != ' ') {
			  char c = myString[i];

			  tabvtx.push_back(c);
			  i++;
		  }
		  while (myString[i] == ' ') {
			  i++;
		  }
		  while (myString[i] != ' ') {
			  char c = myString[i];
			  tabvty.push_back(c);
			  i++;
		  }
		  std::string strx(tabvtx.begin(), tabvtx.end());
		  std::string stry(tabvty.begin(), tabvty.end());

          nombrex = atof(strx.c_str());
          nombrey = atof(stry.c_str());
		  tabvt.push_back(nombrex);
		  tabvt.push_back(nombrey);

          taballvt.push_back(tabvt);
		  tabvt.pop_back();
		  tabvt.pop_back();
		  tabvtx.clear();
		  tabvty.clear();

	  }
  }

  myFile.close();
}
Пример #18
0
void skipDelimiter(ifstream& ifile)
{
	while(!ifile.eof()) {
		char ch=ifile.peek();
		if(ch=='\n'){ 
			lastLineOffset = offset;
			offset=1;
			lineNum++;
			ifile.get();
		}
		else if(ch==' '||ch=='\t') { offset++; ifile.get(); }
		else break;
	}
}
Пример #19
0
 void start_thread(int num) {
   cerr << "starting worker " << num << endl;
   char buffer[mem_each*1024];
   //cerr << "stream good: " << input.good() << endl;
   input.get(buffer, mem_each*1024, EOF);
   //cerr << "Buffer: " << string(buffer) << endl;
   maps[num] = unordered_map<string, int>();
   //cerr << "Map clean: " << maps[num].empty() << endl;
   workers[num] = thread(wc, string(buffer), ref(maps[num]));
   if (input.eof()) {
     done = true;
     cerr << "End of file" << endl;
   }
 }
Пример #20
0
void readDict() {
    ifstream f("dictionary");
    string g;
    for(;!f.eof();) {
        getline(f,g);
        string pre;
        for(int i=0; i<=55 && i<g.size(); ++i) {
            pre+=g[i];
            dictp[i+1].insert(pre);
            dictp[i+1].insert("");
        }
        dict.insert(g);
    }
}
Пример #21
0
void convertToFail(ifstream &in_stream) {
    string oneline;
    string outputline;
    getline(in_stream, oneline);
    outputline = ":-" + oneline.substr(0, stringSearch(oneline) + 1) + "_).";
    writeToFile(outputline, 1);
    while(!in_stream.eof()) {
        getline(in_stream, oneline);
        if(oneline.size() < 4)
            return;
        outputline = ":-" + oneline.substr(0, stringSearch(oneline) + 1) + "_).";
        writeToFile(outputline, 0);
    }
}
bool DataSourceProducerRGBDDataset::parseFrameLine(ifstream& file ,double& timeStamp,string& path)
{
	if(file.eof())return false;
	string line;
	getline(file,line);
	path=_sourcefilename;
    stringstream ss(line);
    ss>>timeStamp;
    string temp_path;
    ss>>temp_path;
    path+=temp_path;
    return true;

}
Пример #23
0
/*
 * Function to count the number of vertices in GML file.
 * Scans the file for "node" entries and updates the counter.
 * Returns the number of vertices.
 */
int count_vertices(ifstream &fin) {
	string line;
	int result = 0;
	while (!fin.eof())
	{
		getline(fin, line);
		if (string::npos != line.find("node"))
			result++;
		if (string::npos != line.find("edge"))
			break;
	}
	reset_pointer(fin);
	return result;
}
Пример #24
0
/*POT_SW3 ReadInput: READS AND STORES POTENTIAL PARAMETER VALUES*/
string POT_SW3::ReadInput(ifstream &Input) {
  int n_e=0, n_l=0;
  string str;
  while(!Input.eof()) {
    str = Read_Next(Input);
    if(str.compare(0, 7, "epsilon", 7)==0) {Fill(epsilon[n_e], Input);n_e++;} else
    if(str.compare(0, 5, "sigma"  , 5)==0) {Fill(sigma  , Input);} else
    if(str.compare(0, 1, "a"      , 1)==0) {Fill(a      , Input);} else
    if(str.compare(0, 5, "gamma"  , 5)==0) {Fill(gamma  , Input);} else
    if(str.compare(0, 6, "lambda" , 6)==0) {Fill(lambda[n_l], Input);n_l++;} else
    {break;}
  }
  return(str);
}
Пример #25
0
uint Train(ifstream& cpg_file, shared_ptr< HMM<double> > hmm_sptr)
{
    cerr << "Start training" << endl;
    string observed;

    string line;
    while (!cpg_file.eof())
    {
        cpg_file >> line;
        observed += line;
    }

    return Process_Observed(observed, hmm_sptr, train);
}
Пример #26
0
int HMeTiS2Bin::computeNumPins(ifstream &in_stream) {
  int loc = in_stream.tellg();
  int numPins = 0;
  int numHedgesRead = 0;

  while (!in_stream.eof() && numHedgesRead < numHedges) {
    getLine(in_stream);
    numHedgesRead += countPinsInLine(buffer.data(), numPins);
  }

  in_stream.seekg(loc, ios::beg);

  return numPins;
}
Пример #27
0
int main(){
    fin.open("tree.txt");
    fout.open("treeC.txt");
    
    while(1){
        fin >> node;
        if(fin.eof()) break;
        fin >> node;
        fout << node <<endl;
    }
    fin.close();
    fout.close();
    return 0;
}
Пример #28
0
 int lineCount (ifstream& in)
 {
 string line_in;
 in.clear();
 in.seekg(0);
 
 int count = 0;
 while (!in.eof())
 {
     getline(in, line_in);
     count++;
 }
 return count;
 }
Пример #29
0
void readData(ifstream& attributeFile, LabelProps& slippCount)
{
    int numberOfReads;
    float winner, second, numOfRepeats;
    string temp, nextLine;
    Marker marker;
    while (!attributeFile.eof())
    {            
        attributeFile >> marker.chrom;
        attributeFile >> marker.start;        
        attributeFile >> marker.end;
        attributeFile >> temp;
        attributeFile >> temp;
        attributeFile >> numberOfReads;
        attributeFile >> temp;
        attributeFile >> winner;
        attributeFile >> second;
        if (numberOfReads >= 10)
        {
            for (unsigned i = 0; i < numberOfReads; ++i)
            {
                attributeFile >> numOfRepeats;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                attributeFile >> temp;
                if (numOfRepeats == winner || numOfRepeats == second)
                    slippCount.p1 += 0.95;
                else 
                {
                    float diff1 = fabs(numOfRepeats - winner), diff2 = fabs(numOfRepeats - second);
                    if (std::min(diff1,diff2)>=0.9)
                        slippCount.p2 += 0.95;
                    else
                        slippCount.p3 += 0.95;
                }
            }
        }
        else
        {
            for (unsigned i = 0; i <= numberOfReads; ++i)
                getline (attributeFile,nextLine);
        }
    } 
Пример #30
0
//Account Functions --------------------------------------------------------------------------------------------------------
int read_accts(BankAccount account[], int max_accounts){
    //start counter
    int count = 0;
    //temporary variables
    string fname, lname, type;
    int SSN;
    double acctbalance;
    //count how moany entries are in the file.
    while(!File.eof() && count < max_accounts){
        File >> fname >> lname >> SSN >> type >> acctbalance;

        count++;
    }
    //loop back to top of file.
    File.clear();
    File.seekg(0, ios::beg);
    //counter for our current account
    int i = 0;
    //create pointer for changing the values at the direct address in memory
    BankAccount * b;
    //loop trhough file and save and set values
    while(!File.eof() && i < count){
        //set our current account into our pointer variable
        b = &account[i];
        //define our file format
        File >> fname >> lname >> SSN >> type >> acctbalance;
        //set all of our values
        b->setFirstName(fname);
        b->setLastName(lname);
        b->setSSN(SSN);
        b->setAccountNumber(i);
        b->setAccountType(type);
        b->setAccountBalance(acctbalance);
        i++;
    }
    return count;
}