#include "validation.h" // Check the grammar of the input files. // You should also check properties of the input. // E.g., check that a graph is connected. int main(int argc, char** argv) { InputValidator v(argc, argv); int n = v.read_integer("n", 1, 1000); v.newline(); std::set seen; for(int i = 0; i < n; i++) { std::string type, fit; int num; type = v.read_string("type", 1, 20); v.space(); fit = v.read_string("fit", 3, 5); v.space(); num = v.read_integer("num", 1, 1000); v.newline(); for(char c : type) { v.check('a' <= c && c <= 'z', "Type may only have lower case letters."); } v.check(fit == "any" || fit == "right" || fit == "left", "Fit must be left, right or any."); std::string comb = type + fit; v.check(seen.find(comb) == seen.end(), "a given (fit, type) combination may appear at most once."); seen.insert(comb); } return 0; }