Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    r0286bc r5079a0  
    1515#include <Descriptors/MoleculeIdDescriptor.hpp>
    1616#include "CommandLineUI/CommandLineDialog.hpp"
    17 
    18 #include "Actions/Values.hpp"
    1917
    2018#include "element.hpp"
     
    118116
    119117bool CommandLineDialog::BooleanCommandLineQuery::handle() {
    120   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    121     tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
    122     return true;
    123   } else
    124     return false;
     118  bool badInput = false;
     119  char input = ' ';
     120  do{
     121    badInput = false;
     122    Log() << Verbose(0) << getTitle();
     123    cin >> input;
     124    if ((input == 'y' ) || (input == 'Y')) {
     125      tmp = true;
     126    } else if ((input == 'n' ) || (input == 'N')) {
     127      tmp = false;
     128    } else {
     129      badInput=true;
     130      cin.clear();
     131      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     132      Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
     133    }
     134  } while(badInput);
     135  // clear the input buffer of anything still in the line
     136  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     137  return true;
    125138}
    126139
     
    179192  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    180193    IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
    181     cout << "IdxOfMol " << IdxOfMol << endl;
    182     if (IdxOfMol >= 0)
    183       tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
    184     else
    185       tmp = NULL;
     194    tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
    186195    return true;
    187196  } else
     
    197206
    198207bool CommandLineDialog::VectorCommandLineQuery::handle() {
    199   VectorValue temp;
    200   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    201     temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
    202     tmp->at(0) = temp.x;
    203     tmp->at(1) = temp.y;
    204     tmp->at(2) = temp.z;
     208  vector<double> temp;
     209  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     210    temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
     211    assert((temp.size() == 3) && "Vector from command line does not have three components.");
     212    for (int i=0;i<NDIM;i++)
     213      tmp->at(i) = temp[i];
    205214    return true;
    206215  } else
     
    217226
    218227bool CommandLineDialog::BoxCommandLineQuery::handle() {
    219   BoxValue temp;
    220   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    221     temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
    222     tmp[0] = temp.xx;
    223     tmp[1] = temp.xy;
    224     tmp[2] = temp.xz;
    225     tmp[3] = temp.yy;
    226     tmp[4] = temp.yz;
    227     tmp[5] = temp.zz;
     228  vector<double> temp;
     229  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     230    temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
     231    assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components.");
     232    for (int i=0;i<6;i++)
     233      tmp[i] = temp[i];
    228234    return true;
    229235  } else
Note: See TracChangeset for help on using the changeset viewer.