コード例 #1
0
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();
}
コード例 #2
0
ファイル: ImageIOpfm.cpp プロジェクト: TPeterW/flying-pancake
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();
}
コード例 #3
0
ファイル: Sudoku.cpp プロジェクト: jamescoll/cpp_portfolio
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();
}
コード例 #4
0
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
}
コード例 #5
0
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;
    }
  
}
コード例 #6
0
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();

}