Page MenuHomec4science

UIElements.cpp
No OneTemporary

File Metadata

Created
Tue, Nov 26, 05:00

UIElements.cpp

/**
* \file UIElements.cpp
*
* \date Oct 23, 2012
* \author Alexandre Tuleu
*/
#include "UIElements.h"
#include <iostream>
#include <sstream>
#include <stdexcept>
void FillHexaByteIfNeeded(const std::string & name,
bool nonInteractif,
sbcp::HexaByte & data){
std::ostringstream os;
if(!data.IsInitialized()){
if(nonInteractif){
os << name << " should be provided.";
throw std::runtime_error(os.str());
}
std::cout << "Please enter a " << name << " : " << std::flush;
std::cin >> data;
}
}
bool AskYesNoQuestion(const std::string & question){
std::string response;
while(true){
std::cout << question << " ? [yes/no]" << std::flush;
std::getline(std::cin,response);
if(response == "yes"){
return true;
}
if(response == "no"){
return false;
}
std::cout << "Please enter 'yes' or 'no'" << std::endl;
}
}

Event Timeline