Exemplo n.º 1
0
/*
 * Sets the characters used to represent alive and dead cells.
 *
 * INTPUT: &cnfg Config file to store characters
 */
void reader::set_chars(config &cnfg)
{
	// Check for the Chars keyword
	int indx1 = data.find("Chars");
	if (indx1 == string::npos) return;

	// Locate the alive/dead characters
	int indx2 = data.find(";", indx1+1);
	
	// Parse the ASCII values
	string str(data.substr(indx1+6, indx2-indx1));
	str.replace(str.find(";"), 1, " ");
	str.replace(str.find(","), 1, " ");
	istringstream stream(str);
	int one, two;
	stream >> one >> two;	

	// Save to config
	cnfg.set_chars((char)one, (char)two);
}