c++ version of command line input/validation handler