/* Lecture code 4.1
 *
 * Using the X Macro trick to automatically generate code for
 * the Color type.  This code is partly covered in Handout #08,
 * so be sure to consult it for reference.
 *
 * To compile this code, you will need the color.h file
 * (lecture code 4.2) to be in the same directory as the
 * source file.
 */

#include <iostream>
#include <string>
using namespace std;

enum Color {
	/* Color enumeration is generated by taking the
	 * first element of the DEFINE_COLOR pair and appending
	 * a comma.
	 */
	#define DEFINE_COLOR(name, opposite) name,
	#include "color.h"
	#undef DEFINE_COLOR
};

string GetColorName(Color c)
{
	switch(c)
	{
		/* Color name is generated by creating a case label
		 * based on the first element in the pair, then having
		 * the statement return the stringized form of the
		 * parameter.
		 */
		#define DEFINE_COLOR(color, opposite) case color: return #color;
		#include "color.h"
		#undef DEFINE_COLOR;
	}
}

Color GetOppositeColor(Color c)
{
	switch(c)
	{
		/* Opposite color is generated by taking the first element of the
		 * pair, creaing a case label for it, and having it return the 
		 * opposite.
		 */
		#define DEFINE_COLOR(color, opposite) case color: return opposite;
		#include "color.h"
		#undef DEFINE_COLOR
	}
}