/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * FilesTextQuery.cpp * * Created on: May 21, 2012 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include #include #include #include "TextUI/Query/TextQuery.hpp" #include "CodePatterns/Log.hpp" #include "CodePatterns/Verbose.hpp" TextDialog::FilesTextQuery::FilesTextQuery(std::string title, std::string _description) : Dialog::FilesQuery(title,_description) {} TextDialog::FilesTextQuery::~FilesTextQuery() {} bool TextDialog::FilesTextQuery::handle() { std::string tempstring; boost::filesystem::path tempfile; do{ std::cout << getDescription() << ": "; std::cin >> tempstring; if (std::cin.fail()) { std::cin.clear(); std::cin.ignore(std::numeric_limits::max(),'\n'); std::cout << "Input was not a valid string!" << std::endl; continue; } tempfile = tempstring; if (boost::filesystem::exists(tempfile)) { tmp.push_back(tempfile); } else { ELOG(1, "File " << tempstring << " cannot be found."); tempstring = std::string(); } } while(tempstring != std::string()); std::cin.ignore(std::numeric_limits::max(),'\n'); return !tmp.empty(); }