本文整理汇总了C++中ifstream::ignore方法的典型用法代码示例。如果您正苦于以下问题:C++ ifstream::ignore方法的具体用法?C++ ifstream::ignore怎么用?C++ ifstream::ignore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ifstream
的用法示例。
在下文中一共展示了ifstream::ignore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCustom
void RoomCost::setCustom(ifstream& file)
{
int periodBegin; // Period start
int periodEnd; // Period end
int count; // Count of entries under start - end (count)
float cost; // Cost for one entry
string roomType; // Type of room
string costType; // Cost
CostInterval* interval;
file >> periodBegin;
file >> periodEnd;
file >> count;
file.ignore();
for (int i = 0; i < count; i++) // Go over all entries
{
getline(file, roomType, ' ');
getline(file, costType, ' ');
file >> cost;
file.ignore();
// Thanks Ubama for not adding switch for string
if (costType == "uke") // If is week cost
interval = new WeekCost(periodBegin, periodEnd, cost);
else if (costType == "helg") // if weekend cost
interval = new WeekendCost(periodBegin, periodEnd, cost);
else // or everything else
interval = new CostInterval(periodBegin, periodEnd, cost);
customCosts[getType(roomType)]->add((Element*)interval);
}
}
示例2: readGrammar
static void readGrammar(ifstream& infile, map<string, Definition>& grammar)
{
// Keep parsing until EOF is reached.
while(infile.good())
{
// Ignore all chars until '{' is reached.
infile.ignore(numeric_limits<streamsize>::max(), '{');
// Ignore all chars until '\n' is reached.
infile.ignore(numeric_limits<streamsize>::max(), '<');
if(infile.good())
{
// Beginning of a definition; parse into program.
Definition myDefinition = Definition(infile);
// Fill map.
string myNonTerminal = myDefinition.getNonterminal();
pair<string, Definition> myPair(myNonTerminal, myDefinition);
grammar.insert(myPair);
}
}
infile.close();
}
示例3: ReadOneTrainingSample
void ReadOneTrainingSample(ifstream& is,FDImage& image)
{
int i,j;
char buf[256];
FDImage timage;
ASSERT(sx<=256 && sy<=256);
is>>image.label; is.ignore(256,'\n');
ASSERT( (image.label == 0) || (image.label == 1) );
is>>timage.height>>timage.width; is.ignore(256,'\n');
ASSERT(timage.height==sx);
ASSERT(timage.width==sy);
timage.SetSize(CSize(timage.height,timage.width));
for(i=0;i<timage.height;i++)
{
is.read(buf,timage.width);
for(j=0;j<timage.width;j++)
{
timage.data[i][j] = REAL(int(unsigned char(buf[j-1])));
ASSERT(timage.data[i][j]>=0 && timage.data[i][j] <= 255);
}
}
is.ignore(256,'\n');
timage.Resize(image,40.0/24.0);
timage.Clear();
}
示例4: input
// handles all file inputs
void Room::input(ifstream& in1) {
in1.getline(name,50);
in1.ignore(1);
in1.getline(description,300);
in1 >> exit[0] >> exit[1] >> exit[2] >> exit[3];
in1.ignore(1);
}
示例5: ReadOneTrainingSample
void ReadOneTrainingSample(ifstream& is,IntImage& image)
{
int i,j;
char buf[256];
ASSERT(sx<=256 && sy<=256);
is>>image.label; is.ignore(256,'\n');
ASSERT( (image.label == 0) || (image.label == 1) );
is>>image.height>>image.width; is.ignore(256,'\n');
ASSERT(image.height==sx);
ASSERT(image.width==sy);
image.SetSize(CSize(image.height+1,image.width+1));
for(i=0;i<image.height;i++) image.data[i][0] = 0;
for(i=0;i<image.width;i++) image.data[0][i] = 0;
for(i=1;i<image.height;i++)
{
is.read(buf,image.width-1);
for(j=1;j<image.width;j++)
{
image.data[i][j] = REAL(int(unsigned char(buf[j-1])));
ASSERT(image.data[i][j]>=0 && image.data[i][j] <= 255);
}
}
is.ignore(256,'\n');
}
示例6: readmessages
// Reads messages file and pushes email messages to the stack
void readmessages(StackType& email, ifstream& in)
{
Message message; // Redo the constructor
while (!(in.eof())) {
char Body[1000];
char FROM[6], sender[50];
char DATE[6], date[15];
char SUBJECT[9], subject[60]; // Body, sender,date, and subject initialized as character arrays
in >> FROM;
in.ignore(1);
in.getline(sender,50);
in >> DATE >> date;
in >> SUBJECT;
in.ignore(1);
in.getline(subject,60);
in.ignore(100,'\n'); // reads the data from messagesfile.txt
in.get(Body,1000,'#');
message.setSender(sender);
message.setDate(date);
message.setSubject(subject);
message.setBody(Body); // Sets the information into a message object
email.Push(message); // Pushes the message object onto the emails stack
in.ignore(100,'\n');
}
}
示例7: LoadTriggersLegacy
void cTriggerList::LoadTriggersLegacy(ifstream& ifs)
{
int temp;
int numTriggersToLoad = 0;
char buffer[1000];
Free();
if (ifs.peek() == '\n') ifs.ignore(1, '\n');
ifs >> numTriggersToLoad;
if (numTriggersToLoad > 10) // Myr: For some reason I can't determine my save game is suddenly
numTriggersToLoad = 10; // generating a value of 16842851 here. Sanity check.
for (int i = 0; i<numTriggersToLoad; i++)
{
cTrigger* current = new cTrigger();
// load the type
if (ifs.peek() == '\n') ifs.ignore(1, '\n');
ifs >> temp;
current->m_Type = temp;
// load additional data
if (ifs.peek() == '\n') ifs.ignore(1, '\n');
if (current->m_Type == TRIGGER_SKILL || current->m_Type == TRIGGER_STAT)
{
// skill/stat id
ifs >> temp;
current->m_Values[0] = temp;
// what value it must reach
ifs >> temp;
current->m_Values[1] = temp;
}
else if (current->m_Type == TRIGGER_STATUS)
示例8: ReadFromFile
void AdaBoostClassifier::ReadFromFile(ifstream& f)
{
Clear();
f>>m_iCount; ASSERT(m_iCount>0);
f.ignore(256,'\n');
m_WeakClassifiers = new WeakClassifier[m_iCount]; ASSERT(m_WeakClassifiers!=NULL);
m_rAlphas = new REAL[m_iCount]; ASSERT(m_rAlphas!=NULL);
f>>m_rThreshold; f.ignore(256,'\n');
for(int i=0;i<m_iCount;i++) f>>m_rAlphas[i]; f.ignore(256,'\n');
for(int i=0;i<m_iCount;i++) m_WeakClassifiers[i].ReadFromFile(f); f.ignore(256,'\n');
}
示例9: ReadAndPrintFiles
void ReadAndPrintFiles(ifstream& dataFileIn1, ifstream& dataFileIn2, hashT<elemType>& hashtable)
{
char num[4];
cout << "The hash table is shown as follow (size " << HTSize << "):" << endl;
cout << " indexStatusList HashTable(0 means empty spot)" << endl;
dataFileIn1 >> num;
while (!dataFileIn1.eof())
{
dataFileIn1.ignore(100, '\n');
hashtable.insert(hashFunction(num), atoi(num));
dataFileIn1 >> num;
}
hashtable.print();
char num1[4];
int hashIndex;
bool found;
int pCount;
linkedQueueType<int> probeSequence;
cout << endl << "Search for values in the hash table using values in lab8srch.dat:";
cout << endl << " Value" << " " << "Found?" << " " << "# of probes" << " " << "The probe sequence" << endl;
dataFileIn2 >> num1;
while (!dataFileIn2.eof())
{
hashIndex = hashFunction(num1);
dataFileIn2.ignore(100, '\n');
hashtable.search(hashIndex, atoi(num1), found, pCount, probeSequence);
cout << setw(5) << num1;
switch(found)
{
case 1: cout << setw(8) << "Yes";
break;
case 0: cout << setw(8) << "No";
break;
}
cout << setw(11) << pCount << " ";
while (!probeSequence.isEmptyQueue())
{
cout << probeSequence.front() << " ";
probeSequence.deleteQueue();
}
cout << endl;
dataFileIn2 >> num1;
}
}
示例10: averageGrade
double averageGrade(double sum, char gender, ifstream& file) {
// Instantiate helper variables
double avg, count = 0;
char testGender;
// While the file is available for reading, take in the
// gender from each line to 'testGender'. If testGender
// matches the gender we care about, increment the counter.
// Finally, ignore the rest of the line.
while (file >> testGender) {
if (testGender == gender) {
count++;
}
file.ignore(50, '\n');
}
// Reset the readable file back to its initial state so we
// can read it again later
file.clear();
file.seekg(0, ios::beg);
// Compute and return the average
avg = sum / count;
return avg;
}
示例11: read_his_vcc
void read_his_vcc(ifstream &in_vcc, vector <int> & i_will){ // Reading history.vcc
int nv; in_vcc >> nv;
in_vcc.ignore();
char c_T[3];
long long int ts_vcc;
double time_vcc;
in_vcc >> c_T >> ts_vcc >> time_vcc;
if(strcmp("T:", c_T) !=0){
cout << c_T << endl;
error(1, "(read vcc) the format is incorrect"); // check
}
if(ts_vcc != timestep || time_vcc != realtime) error(1, "(read vcc) the reading block might inconsistent. timestep:", 2, ts_vcc, timestep);
vltcp.clear();
for(int a=0; a<nv; a ++){
int type_in, vltcp_in, ix, iy, iz;
in_vcc >> type_in >> vltcp_in >> ix >> iy >> iz;
states[vltcp_in]= type_in;
vltcp.push_back(vltcp_in);
iv[0]= ix;
iv[1]= iy;
iv[2]= iz;
i_will.push_back(vltcp_in);
}
if(in_vcc.eof()) error(1, "(read_vcc) unexpected eof");
}
示例12: readFile
void readFile(ifstream &inf, Station stations[], int numStations, int numCars,
Car cars[])
{
int i, j;
char line[256];
inf.ignore(1000, '\n');
for(i = 0; i < numStations; i++)
{
inf.getline(line, 256);
strtok(line, ",");
stations[i].adjCount = atoi(strtok(NULL, ","));
for(j = 0; j < stations[i].adjCount; j++)
{
stations[i].adjacent[j] = atoi(strtok(NULL, ","));
stations[i].distances[j] = atoi(strtok(NULL, ","));
} // for j
} // for each station
for(i = 0; i < numCars; i++)
{
inf.getline(line, 256);
strtok(line, ",");
cars[i].source = atoi(strtok(NULL, ","));
cars[i].destination = atoi(strtok(NULL, ","));
} // for each car
} // readFile()
示例13: loadArrays
void loadArrays(ifstream &fileData, string wine[], double qsales[][4], int &row)
{
for (row = 0; row < SIZE; row++)
{
getline(fileData, wine[row]);
if (fileData.eof())
{
break;
}
for (int col = 0; col < 4; col++)
{
fileData >> qsales[row][col];
}
fileData.ignore(80, '\n');
}
}
示例14: data
Transacao::Transacao(ifstream & in){ // le uma transacao na forma de idcliente ; data ; lista produtos
string data_aux;
string lista_prod_aux;
vector<string> produtos_aux;
string prod_individual;
//idcliente
in >> idCliente; in.ignore(); // ignora o ;
cout << idCliente << endl;
//data
getline(in, data_aux, ';');
//cout << 77 << endl;
data_aux.erase(data_aux.begin()); data_aux.erase(data_aux.end() - 1); //apaga 1 e último espaço
//cout << 33 << endl;
Data data(data_aux);
//lista de produtos
getline(in, lista_prod_aux);
istringstream instr(lista_prod_aux);
while (getline(instr, prod_individual, ','))
{
prod_individual.erase(0, prod_individual.find_first_not_of(' ')); //remove espacos iniciais
produtos_aux.push_back(prod_individual);
}
produtos = produtos_aux;
}
示例15: carregaParamPULSE
//PULSE (<amplitude 1> <amplitude 2> <atraso> <tempo de subida> <tempo de descida> <tempo ligada> <período> <número de ciclos>)
void Tensao::carregaParamPULSE(ifstream &arq)
{
int i = 0;
while(arq.good() && arq.peek() != '\n')
{
//ignora os parenteses
if (arq.peek() == ' ' || arq.peek() == '(' || arq.peek() == ')')
{
arq.ignore();
continue;
}
switch(i)
{
case 0:
arq >> m_amplitude;
break;
case 1:
arq >> m_amplitude2;
break;
case 2:
arq >> m_atraso;
break;
case 3:
arq >> m_t_subida;
break;
case 4:
arq >> m_t_descida;
break;
case 5:
arq >> m_t_ligada;
break;
case 6:
arq >> m_periodo;
break;
case 7:
arq >> m_ciclos;
break;
default:
arq >> m_ignora;
break;
}
i++;
}
if(i!=8)
{
cout<< m_nome <<" PULSE: Numero de parametros errado" << i << "/8"<<endl;
arq.close();
m_erro = true;
}
cout<<m_nome<<" PULSE:"<<m_nome_a<<" "<<m_nome_b
<<" "<<m_amplitude
<<" "<<m_amplitude2
<<" "<<m_atraso
<<" "<<m_t_subida
<<" "<<m_t_descida
<<" "<<m_t_ligada
<<" "<<m_periodo
<<" "<<m_ciclos<<endl;
}