#include "eoption.h"


ebaseoption::ebaseoption(): choice(-1) {}
ebaseoption::~ebaseoption() {}

estr ebaseoption::key()
{
  lddieif(choice==-1 || choice>keys.size(),"no choice or out of bounds: "+estr(choice));
  return(keys.at(choice));
}

estr ebaseoption::choices()
{
  if (keys.size()==0) return("{}");

  estr tmpstr="{";
  int i;
  for (i=0; i<keys.size(); ++i)
    tmpstr+=keys.at(i)+",";
  tmpstr.del(-1);
  tmpstr+="}";
  return(tmpstr);
}

int ebaseoption::operator=(const estr& val)
{
  int i;
  i=keys.find(val);
  if (i!=-1)
    choice=i;
  else
    ldie("option: "+val+" not found. Valid options are: "+choices());
  return(i);
}


