Example #1
0
void podem::read_faults()
{
    std::ifstream fault_file;

    try {
        fault_file.open(_fault_file_name);

        if(fault_file.good()) {
            std::cout << "Reading fault file: " << _fault_file_name << std::endl;

            std::string tmp;

            while (getline(fault_file, tmp))
            {
                std::string fault_site;
                int fault_value;

                my_replace(tmp, "/", " ");

                std::stringstream s(tmp);

                s >> fault_site >> fault_value;

                if(_c.does_gate_exist(fault_site))
                {
                    _faults.push_back(std::make_pair(fault_site, (fault_value::VALUE)fault_value));

                }
                else
                {
                    std::cerr << "Invalid fault site: " << fault_site << std::endl;
                }
            }

            fault_file.close();
        }
        else
        {
            std::cerr << "ERROR: Cannot open " << _fault_file_name << std::endl;
        }

    } catch(std::exception e) {
char		*eval_paren(char *str, char *ops, char *base)
{
  t_limits	limite;
  int		nb_paren;
  char		*temp;

  limite.left = max_level_paren(str, ops);
  limite.right = limite.left + 1;
  while (str[limite.right] != ops[1] && str[limite.right])
    limite.right = limite.right + 1;
  while (str_contain_operator(str, ops) == 0)
    {
      limite.left = max_level_paren(str, ops);
      limite.right = limite.left + 2;
      while (str[limite.right] != ops[1] && str[limite.right])
	limite.right = limite.right +1;
      temp = my_remove(str, limite.left, limite.right, ops);
      str = my_replace(str, my_eval_expr(my_remove(str, limite.left,
						   limite.right, ops),
					 base, ops), limite, ops);
    }
  return (str);
}