/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * BooleanTextQuery.cpp * * Created on: Oct 25, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Helpers/MemDebug.hpp" #include #include "TextUI/Query/TextQuery.hpp" #include "Helpers/Log.hpp" #include "Helpers/Verbose.hpp" TextDialog::BooleanTextQuery::BooleanTextQuery(string title, std::string _description) : Dialog::BooleanQuery(title,_description) {} TextDialog::BooleanTextQuery::~BooleanTextQuery() {} bool TextDialog::BooleanTextQuery::handle() { bool badInput = false; char input = ' '; do{ badInput = false; Log() << Verbose(0) << getTitle(); cin >> input; if ((input == 'y' ) || (input == 'Y')) { tmp = true; } else if ((input == 'n' ) || (input == 'N')) { tmp = false; } else { badInput=true; cin.clear(); cin.ignore(std::numeric_limits::max(),'\n'); Log() << Verbose(0) << "Input was not of [yYnN]!" << endl; } } while(badInput); // clear the input buffer of anything still in the line cin.ignore(std::numeric_limits::max(),'\n'); return true; }