int ImageType::getPositionAfterHeader(fstream& image) { image.clear(); image.seekg(0); char line[COMMENT_LENGTH]; char c; image.getline(line, COMMENT_LENGTH); image.get(c); while (c == '#') //preskacham komentarite { image.getline(line, COMMENT_LENGTH); image.get(c); } image.unget(); int skippedNumber; image >> skippedNumber; //preskacham width image >> skippedNumber; //preskacham heigth image >> skippedNumber; //preskacham maxValue image.getline(line, COMMENT_LENGTH); return image.tellg(); }
void skip_space(fstream& fileStream) { // skip white space in the headers or pnm files char c; do { c = fileStream.get(); } while (c == '\n' || c == ' ' || c == '\t' || c == '\r'); fileStream.unget(); }
void readNextPuzzle(fstream& str, int grid[][GRIDSIZE]) { char ch; for (int i=0;i<GRIDSIZE;i++) for (int j=0;j<GRIDSIZE;j++) { str >> ch; grid[i][j]=ch-'0'; } // read to end new line or eof str >> ch; if (!str.eof()) str.unget(); }
void ImageType::skipHeaderInPBM(fstream& image) { char line[COMMENT_LENGTH]; char c; image.getline(line, COMMENT_LENGTH); image.get(c); while (c == '#') //preskacham komentarite { image.getline(line, COMMENT_LENGTH); image.get(c); } image.unget(); int skippedNumber; image >> skippedNumber; //preskacham width image >> skippedNumber; //preskacham heigth //pri pixelBitmap nqma maxValue }
void JSONDataObject:: parseFromJSONstream(fstream &stream) { char cc; if(!(stream >> cc) || cc != '{') { cout << "--Expected a curled brace to start, found --> " << cc << " <--." << endl; exit(1); } stream.unget(); stream >> cc; while(cc != '}') { JSONDataItem *dPair = new JSONDataItem; dPair -> parseJSONDataItem(stream); _listOfDataItems -> push_back(dPair); stream >> cc; } }
void JSONDataItem:: parseJSONDataItem(fstream &stream) { char cc; if(!(stream >> cc) || cc != '"') { cout << "Expected a quote.. got a " << cc << endl; exit(1); } _attribute = readQuotedString(stream); if(!(stream >> cc) || cc != ':') { cout << "--Expected a colon, found --> " << cc << " <--." << endl; exit(1); } stream >> cc; if(isdigit(cc)) { _isNumber = true; stream.unget(); stream >> _ivalue; } if( cc == '"') { _svalue = readQuotedString(stream); } hasReadAnItem = true; print(); }