本文整理汇总了C++中std::ifstream::ignore方法的典型用法代码示例。如果您正苦于以下问题:C++ ifstream::ignore方法的具体用法?C++ ifstream::ignore怎么用?C++ ifstream::ignore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ifstream
的用法示例。
在下文中一共展示了ifstream::ignore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
HillPromReaction::HillPromReaction( std::ifstream& file ) {
for (int i = 0 ; i < NUM_LINE ; i++) {
switch (i) {
case I_PROMOTER_LINE:
file.ignore(256,':');
file >> _i_promoter;
break;
case I_PROMOTED_LINE:
file.ignore(256,':');
file >> _i_promoted;
break;
case KINETIC_LINE:
file.ignore(256,':');
file >> _kinetic;
break;
case K_LINE:
file.ignore(256,':');
file >> _K;
break;
case COOPERATIVITY_LINE:
file.ignore(256,':');
file >> _cooperativity;
break;
default:
break;
}
}
}
示例2: Reservasjon
/******************************************************************************
name: Reservasjon()
description: Constructor for Reservasjon; creates a reservation from
information read from file.
Parameters sent from Rom is a reference tothe file reading object,
date (arrival date), and the room number
parameters: std::ifstream &infile, int dato, int roomNr
******************************************************************************/
Reservasjon::Reservasjon(std::ifstream &inFile, int dato, int roomNr) : Num_element(dato)
{
occupant = new std::string[MAX_PAA_ROM]; // Create a string array
bills = new List(FIFO); // Create a FIFO list
roomID = roomNr; // Assign roomNr to roomID
arrival = dato; // Assign dato to arrival
inFile >> departure >> numberOfDays >> inUse; // Read data from file
costPrDay = new float[numberOfDays]; // Create a float array
inFile.ignore(); // Ignore and discard character
// Loop through number of days and read from file:
for (int i = 0; i < numberOfDays; i++)
{
inFile >> costPrDay[i]; inFile.ignore();
}
inFile >> extraBed >> bedInUse >> numberOfOccupants; // Read data from file
inFile.ignore(); // Ignore and discard character
// Loop through number of occupants:
for (int i = 1; i <= numberOfOccupants; i++)
{
getline(inFile, occupant[i]);
}
inFile >> numberOfBills; // Read number of bills from file
inFile.ignore(); // Ignore and discard character
// Loop through number of bills:
for (int i = 1; i <= numberOfBills; i++)
{
Regning* reg = new Regning(inFile); // Create a new regning object
bills->add(reg); // Add new bill
}
}
示例3: make_tuple
std::tuple<unsigned int, unsigned int, int> parse_ppm_header(std::ifstream &fs)
{
// Check the PPM magic number is valid
std::array<char, 2> magic_number{ { 0 } };
fs >> magic_number[0] >> magic_number[1];
ARM_COMPUTE_ERROR_ON_MSG(magic_number[0] != 'P' || magic_number[1] != '6', "Invalid file type");
ARM_COMPUTE_UNUSED(magic_number);
discard_comments_and_spaces(fs);
unsigned int width = 0;
fs >> width;
discard_comments_and_spaces(fs);
unsigned int height = 0;
fs >> height;
discard_comments_and_spaces(fs);
int max_val = 0;
fs >> max_val;
discard_comments(fs);
ARM_COMPUTE_ERROR_ON_MSG(isspace(fs.peek()) == 0, "Invalid PPM header");
fs.ignore(1);
return std::make_tuple(width, height, max_val);
}
示例4: LoadPpm
TypedImage LoadPpm(std::ifstream& bFile)
{
// Parse header
std::string ppm_type = "";
int num_colors = 0;
int w = 0;
int h = 0;
bFile >> ppm_type;
PpmConsumeWhitespaceAndComments(bFile);
bFile >> w;
PpmConsumeWhitespaceAndComments(bFile);
bFile >> h;
PpmConsumeWhitespaceAndComments(bFile);
bFile >> num_colors;
bFile.ignore(1,'\n');
if(!bFile.fail() && w > 0 && h > 0) {
TypedImage img(w, h, PpmFormat(ppm_type, num_colors) );
// Read in data
for(size_t r=0; r<img.h; ++r) {
bFile.read( (char*)img.ptr + r*img.pitch, img.pitch );
}
if(!bFile.fail()) {
return img;
}
}
throw std::runtime_error("Unable to load PPM file.");
}
示例5: PpmConsumeWhitespaceAndComments
void PpmConsumeWhitespaceAndComments(std::ifstream& bFile)
{
// TODO: Make a little more general / more efficient
while( bFile.peek() == ' ' ) bFile.get();
while( bFile.peek() == '\n' ) bFile.get();
while( bFile.peek() == '#' ) bFile.ignore(4096, '\n');
}
示例6:
void ResourceManager::getI2NBlock(std::ifstream &file,
Resource::Mapping &mapping,
bool files,
const std::string &dir,
const std::string &ext)
{
uint id;
const int bufferSize = 80;
char buffer[bufferSize];
while (!file.eof() && file.peek() != '#')
{
file >> id;
if (!(file.peek() == '.'))
return;
file.ignore(2, ' ');
file.getline(buffer, bufferSize);
fixLineEnd(buffer);
if (files)
{
std::string path = dir + '/' + std::string(buffer) + ext;
Normalize(path);
mapping[id] = path;
}
else
{
mapping[id] = std::string(buffer);
}
}
}
示例7: readLabels
void readLabels(std::ifstream &file, char delim, const std::string &poslabel, const std::string &neglabel, std::deque<unsigned> &pos, std::deque<unsigned> &neg, bool posvall){
string chunk;
unsigned idx=1;
while(file.good()){
// read first column
chunk.clear();
getline(file,chunk,delim);
if(chunk.empty())
break;
if(chunk.compare(poslabel)==0)
pos.push_back(idx);
else if(posvall)
neg.push_back(idx);
else if(chunk.compare(neglabel)==0)
neg.push_back(idx);
// else
// exit_with_err(std::string("Encountered unknown label: ")+chunk+" ... missing -posvall flag?");
// when encountering an unkown label, ignore it and parse rest of the data
// ignore rest
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
++idx;
}
}
示例8:
inline static void seek_to_line(std::ifstream& file, unsigned line)
{
file.seekg(std::ios::beg);
for (int i = 0; i < line - 1; ++i)
{
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
}
示例9: read_vertices
void mesh::read_vertices(std::ifstream &vfile)
{
for (int i = 0 ; i < nv; ++i)
{
vfile >> v[i].no;
vfile.ignore(100, ':');
vfile >> v[i].r.x >> v[i].r.y >> v[i].marker;
}
}
示例10: loadDataStructures
void AnimatedObjModel::loadDataStructures(std::ifstream& _dataStream, const DataCounts& counts)
{
std::vector<glm::vec3> tVertices;
std::vector<glm::vec2> tTexCoords;
std::vector<glm::vec3> tNormals;
std::vector<FaceType> tFaces;
char tInput1;
int tVertexIndex = 0;
int tTexcoordIndex = 0;
int tNormalIndex = 0;
int tFaceIndex = 0;
int tBoneIndex = 0;
mModel.resize(counts.faces * 3);
//Initialize the four data structures.
tVertices.resize(counts.positions);
tTexCoords.resize(counts.texCoords);
tNormals.resize(counts.normals);
tFaces.resize(counts.faces);
bones.resize(counts.bones);
while(_dataStream)
{
_dataStream.get(tInput1);
if (tInput1 == '#')
{
#undef max
_dataStream.ignore(std::numeric_limits<int>::max(), '\n');
continue;
}
if(tInput1 == 'v')
{
_dataStream.get(tInput1);
//Read in the vertices.
if(tInput1 == ' ')
{
_dataStream >> tVertices[tVertexIndex].x;
_dataStream >> tVertices[tVertexIndex].y;
_dataStream >> tVertices[tVertexIndex].z;
tVertexIndex++;
}
//Read in the texture uv coordinates.
if(tInput1 == 't')
{
_dataStream >> tTexCoords[tTexcoordIndex].x;
_dataStream >> tTexCoords[tTexcoordIndex].y;
tTexcoordIndex++;
}
示例11: runtime_error
template <class T> void GetNextToken(std::ifstream& Config, T& Data)
{
if (!Config)
throw std::runtime_error("Config stream is not open !");
std::string buffer;
while (Config.peek() == '#')
Config.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::getline(Config, buffer, ' ');
std::cout << "[DEBUG] : " << buffer << std::endl;
Data = ToType<T>(buffer);
}
示例12: read_sides
void mesh::read_sides(std::ifstream &sfile)
{
for (int i = 0 ; i < ns ; ++i)
{
int idx1, idx2;
sfile >> s[i].no;
sfile.ignore(100, ':');
sfile >> idx1 >> idx2;
s[i].v1 = idx1 == -1 ? NULL : &v[idx1]; s[i].v2 = idx2 == -1 ? NULL : &v[idx2];
sfile >> idx1 >> idx2;
s[i].e1 = idx1 == -1 ? NULL : &e[idx1]; s[i].e2 = idx2 == -1 ? NULL : &e[idx2];
sfile >> s[i].marker;
}
}
示例13: read
void sbfMaterialProperties::read(std::ifstream &in)
{
std::getline(in, name_);
size_t numTables;
in >> numTables;
in.ignore(10, '\n');
for(size_t ct = 0; ct < numTables; ct++) {
std::string name;
std::getline(in, name);
auto table = new sbfPropertyTable(name);
table->read(in);
tables_[name] = table;
}
}
示例14: read_elems
void mesh::read_elems(std::ifstream &efile)
{
for (int i = 0 ; i < ne ; ++i)
{
int idx1, idx2, idx3;
efile >> e[i].no;
efile.ignore(100, ':');
efile >> idx1 >> idx2 >> idx3;
e[i].v1 = idx1 == -1 ? NULL : &v[idx1]; e[i].v2 = idx2 == -1 ? NULL : &v[idx2]; e[i].v3 = idx3 == -1 ? NULL : &v[idx3];
efile >> idx1 >> idx2 >> idx3;
e[i].e1 = idx1 == -1 ? NULL : &e[idx1]; e[i].e2 = idx2 == -1 ? NULL : &e[idx2]; e[i].e3 = idx3 == -1 ? NULL : &e[idx3];
efile >> idx1 >> idx2 >> idx3;
e[i].s1 = idx1 == -1 ? NULL : &s[idx1]; e[i].s2 = idx2 == -1 ? NULL : &s[idx2]; e[i].s3 = idx3 == -1 ? NULL : &s[idx3];
efile >> e[i].r.x >> e[i].r.y >> e[i].marker;
}
}
示例15: pnm_read
void pnm_read(std::ifstream &file, char *buf)
{
char doc[PNM_BUFFER_SIZE];
char c;
file >> c;
while (c == '#') {
file.getline(doc, PNM_BUFFER_SIZE);
file >> c;
}
file.putback(c);
file.width(PNM_BUFFER_SIZE);
file >> buf;
file.ignore();
}