本文整理汇总了C++中istream::eof方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::eof方法的具体用法?C++ istream::eof怎么用?C++ istream::eof使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类istream
的用法示例。
在下文中一共展示了istream::eof方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseProgram
void parseProgram(istream &inf, vector<Statement *> & program)
{
program.push_back(NULL);
string line;
while( ! inf.eof() )
{
getline(inf, line);
program.push_back( parseLine( line ) );
}
}
示例2: LoadInput
//加载输入流
bool LanguageParsers::LoadInput(istream& ins)
{
if(ins.fail())
{
return false;
}
this->input_symbols.clear();
char c=ins.get();
if(!ins.eof())
{
do
{
this->input_symbols.push_back(Symbols(c));
c=ins.get();
}while(!ins.eof());
}
return true;
}
示例3: skipWhiteSpace
// Consume whitespace characters from stream. Leaves the stream
// pointing at the next non-whitespace char (or possibly eof());
void skipWhiteSpace(istream &istr) {
char next;
istr >> next; // take advantage of the fact that >> uses whitespace as a field
// separator
if (!istr.eof()) {
// If eof() is set, it means we didn't find any tokens after the whitespace.
// In this case
// there's nother to put back, and doing so would unset the eof bit.
istr.putback(next);
}
}
示例4: readExpression
void readExpression(istream& is, bitset* minterms, bitset* donotcare, uint8_t* varsCount) {
char temp = '0';
long long number;
bitset* currentSet = minterms;
is >> number;
*varsCount = number;
cout << *varsCount << endl;
if (is.fail() || int(*varsCount) > int(16))
throw logic_error("Variables count could not be read or invalid");
is >> temp;
if (is.fail() || is.eof() || temp != ';')
throw logic_error("Syntax error: expected ';'");
_t_minterm maxValue = (pow(2, *varsCount) - 1);
minterms->resize(maxValue + 1);
donotcare->resize(maxValue + 1);
is >> number;
if (!is.eof()) {
while (true) {
if (is.fail())
throw logic_error("Syntax error");
if (number > maxValue)
throw out_of_range("Invalid min-term value: given value is greater than maximum");
currentSet->set(number);
temp = '0';
is >> temp;
if (is.fail() || is.eof() || (temp != ';' && temp != ','))
throw logic_error("Syntax error: expected ';'");
if (temp == ',') {
is >> number;
} else if (temp == ';') {
if (currentSet == donotcare)
break;
else {
currentSet = donotcare;
is >> number;
if (is.eof())
break;
}
} else {
throw logic_error("Unhandled weird exception");
示例5: read
void HumdrumFileBasic::read(istream& inStream) {
char* templine;
templine = new char[4096];
int linecount = 0;
while (!inStream.eof()) {
inStream.getline(templine, 4096);
#ifdef USING_URI
if ((linecount++ == 0) && (strstr(templine, "://") != NULL)) {
if (strncmp(templine, "http://", strlen("http://")) == 0) {
readFromHttpURI(templine);
delete [] templine;
return;
}
if (strncmp(templine, "humdrum://", strlen("humdrum://")) == 0) {
readFromHumdrumURI(templine);
delete [] templine;
return;
}
if (strncmp(templine, "hum://", strlen("hum://")) == 0) {
readFromHumdrumURI(templine);
delete [] templine;
return;
}
if (strncmp(templine, "h://", strlen("h://")) == 0) {
readFromHumdrumURI(templine);
delete [] templine;
return;
}
}
#endif
if (inStream.eof() && (strcmp(templine, "") == 0)) {
break;
} else {
appendLine(templine);
}
}
analyzeSpines();
analyzeDots();
delete [] templine;
}
示例6: splitString
vector<string> splitString(char* rawSplit, istream& source, char delimiter, unsigned int estimatedSplitCount)
{
vector<string> splits;
splits.reserve(estimatedSplitCount);
while (!source.eof())
{
source.getline(rawSplit, MAX_SPLIT_LENGTH, delimiter);
splits.push_back(rawSplit);
}
return splits;
}
示例7: SkipOnError
bool SkipOnError(istream& istr){
if (istr.fail()){
if (istr.eof()){
exit(EXIT_FAILURE);
}
// skip one character
char ch;
istr.clear();
istr >> ch;
return true;
} else {
return false;
示例8: createProcesses
void createProcesses(istream& ifs, vector<Process*>& processes)
{
while(!ifs.eof())
{
unsigned id;
unsigned arrivalTime;
unsigned totalCPU;
unsigned averageBurst;
ifs >> id >> arrivalTime >> totalCPU >> averageBurst;
Process* p = new Process(id, arrivalTime, totalCPU, averageBurst);
processes.push_back(p);
}
}
示例9: getLine
bool getLine( istream &fileP, vector< string > &item )
{
if (fileP.eof())
return false;
string line;
if (!getline(fileP, line))
return false;
item = splitLine(line.c_str());
return true;
}
示例10: returnCh
// DO NOT CHANGE THIS PART...
// DO NOT CHANGE THIS PART...
//
// This part will be used by TA to test your program.
//
// TA will use "make -DTA_KB_SETTING" to test your program
//
ParseChar
CmdParser::getChar(istream& istr) const
{
char ch = mygetc(istr);
if (istr.eof())
return returnCh(INPUT_END_KEY);
switch (ch) {
// Simple keys: one code for one key press
// -- The following should be platform-independent
case LINE_BEGIN_KEY: // Ctrl-a
case LINE_END_KEY: // Ctrl-e
case INPUT_END_KEY: // Ctrl-d
case TAB_KEY: // tab('\t') or Ctrl-i
case NEWLINE_KEY: // enter('\n') or ctrl-m
return returnCh(ch);
// -- The following simple/combo keys are platform-dependent
// You should test to check the returned codes of these key presses
// -- You should either modify the "enum ParseChar" definitions in
// "charDef.h", or revise the control flow of the "case ESC" below
case BACK_SPACE_KEY:
return returnCh(ch);
// Combo keys: multiple codes for one key press
// -- Usually starts with ESC key, so we check the "case ESC"
case ESC_KEY: {
char combo = mygetc(istr);
// Note: ARROW_KEY_INT == MOD_KEY_INT, so we only check MOD_KEY_INT
if (combo == char(MOD_KEY_INT)) {
char key = mygetc(istr);
if ((key >= char(MOD_KEY_BEGIN)) && (key <= char(MOD_KEY_END))) {
if (mygetc(istr) == MOD_KEY_DUMMY)
return returnCh(int(key) + MOD_KEY_FLAG);
else return returnCh(UNDEFINED_KEY);
}
else if ((key >= char(ARROW_KEY_BEGIN)) &&
(key <= char(ARROW_KEY_END)))
return returnCh(int(key) + ARROW_KEY_FLAG);
else return returnCh(UNDEFINED_KEY);
}
else { mybeep(); return getChar(istr); }
}
// For the remaining printable and undefined keys
default:
if (isprint(ch)) return returnCh(ch);
else return returnCh(UNDEFINED_KEY);
}
return returnCh(UNDEFINED_KEY);
}
示例11: readPmx
void ScorePageBase::readPmx(istream& infile, int verboseQ) {
clear();
ScoreItem* sip = NULL;
while (!infile.eof()) {
sip = readPmxScoreLine(infile, verboseQ);
if (sip != NULL) {
// setPageOwner will store the pointer for the ScoreItem
// on the given page. The page will delete it when it
// is deconstructed.
sip->setPageOwner(this);
}
}
}
示例12: fill_vector
// EOFまたは終了インジゲータが検出されるまでistからvに整数を読み取る
void fill_vector(istream& ist, vector<int>& v, char terminator){
int i = 0;
while(ist >> i) v.push_back(i);
if(ist.eof()) return; // OK: EOFが検出された
if(ist.fail()){ // できるだけ後始末をし、問題を報告する
ist.clear(); // ストリームの状態をクリアし、終了インジゲータを調査できるようにする
char c;
ist >> c; // 文字を読み取る(終了インジゲータでありますように)
if(c != terminator){ // 予想外の文字
ist.unget();
ist.clear(ios_base::failbit); // 状態をfailに設定する
}
}
示例13: readStreamAsString
string Utils::readStreamAsString(istream &inStream) {
ostringstream result;
while (true) {
char got = static_cast<char>(inStream.get());
if (!inStream.eof()) {
result << got;
} else {
break;
}
}
return result.str();
}
示例14:
obj ReplacementSelection<obj>::fill(istream& infile){
obj newelement;
int i;
int newIndex;
infile>>newelement;
for(i=0; i<size && !infile.eof(); i++){
heap[i]=newelement;
leftEnd=i;
heapify(true);
infile>>newelement;
}
return newelement;
}
示例15: createPrimary
void createPrimary(istream& read, ostream& primary){
int number,byte = 0;
map<int,int> mymap;
PrimaryIndex p;
ClientData client;
read.clear();
read.seekg(0);
primary.seekp(0);
if(read.eof())return;
read >> client;
while(!read.eof()){
if(number = client.getAccountNumber()){
mymap[number] = byte;
byte = read.tellg();
}
read >> client;
}
for(map<int,int>::iterator it = mymap.begin(); it != mymap.end(); it++){
p.AccountNumber = it->first;
p.Byte = it->second;
primary.write(reinterpret_cast<char*>(&p), sizeof(PrimaryIndex));
}
}