Exemplo n.º 1
0
int BingoApp::loadSymbols()
{
	cerr << symbols.size() << " symbols before\n";
	if ( symbolsFilename.length() > 0 )
	{
		QFile symbolsFile(symbolsFilename);
		if ( ! symbolsFile.open(QIODevice::Text | QIODevice::ReadOnly) )
			{ cerr << "bingo: could not open " << symbolsFilename << endl; return 21; }

		symbols.reserve(symbolCount);
		for ( QTextStream symbolsStream(&symbolsFile); ! symbolsStream.atEnd() && symbols.size() <= symbolCount; )
			symbols.push_back( symbolsStream.readLine() );

		if ( symbols.size() == symbolCount ) return 0;
		cerr << "bingo: file must have 75 symbols: " << symbolsFilename << endl;
		return 23;
	}
	else
	{
		symbols.reserve(symbolCount);
		for ( int i = 1; i <= symbolCount; ++i )
			symbols.push_back(QString::number(i));

		cerr << symbols.size() << " numbers generated\n";
	}
	return 0;
}
Exemplo n.º 2
0
std::vector<std::string> 
readSymbols(std::string symbolFileName)
{
	std::string line;
	std::vector<std::string> symbols; 
	std::ifstream symbolsFile(symbolFileName);
	//std::cerr << "---->BEGIN CONFIG" << std::endl;
	if (symbolsFile.is_open()) {
		while(symbolsFile.good()) {
			std::getline(symbolsFile, line);
			//std::cerr << "LINE: " << line << std::endl;
			symbols.push_back(line);	
		}
	}
	//std::cerr << "---->END CONFIG" << std::endl;
	return symbols;

}