-rw-r--r-- 980 cryptattacktester-20231020/selection.cpp raw
#include "selection.h"
using namespace std;
map<string,string> selection_parse(char **x,bigint n)
{
  map<string,string> result;
  for (;n > 0;++x,--n) {
    string s(*x);
    while (s.size() > 0) {
      string snext;
      bigint comma = s.find_first_of(",");
      if (comma != string::npos) {
        snext = s.substr(comma+1);
        s = s.substr(0,comma);
      }
      bigint eq = s.find_first_of("=");
      if (eq != string::npos) {
        string left = s.substr(0,eq);
        string right = s.substr(eq+1);
        result[left] = right;
      }
      s = snext;
    }
  }
  return result;
}
bool selection_allows(const map<string,string> &S,std::string left,std::string right)
{
  if (S.count(left) == 0) return 1;
  return S.at(left) == right;
}
void selection_constrain(const std::map<std::string,std::string> &S,std::string left,bigint &leftmin,bigint &leftmax)
{
  if (S.count(left) == 0) return;
  bigint i(S.at(left));
  leftmin = i;
  leftmax = i;
}