Exemple #1
0
double 
Oldunits::Content::convert (const symbol from, const symbol to, 
                            double value) const
{ 
  if (from == to)
    return value;

  const Oldunits::Convert& conv = get_convertion (from, to);

  if (!conv.valid (value))
    throw std::string ("invalid value");

  return conv (value);
}
Exemple #2
0
bool 
Oldunits::Content::can_convert (const symbol from, const symbol to) const
{ 
  if (from == to)
    return true;

  try 
    {
      get_convertion (from, to);
    }
  catch (...)
    {
      return false;
    }
  return true;
}
Exemple #3
0
bool 
Oldunits::Content::can_convert (const symbol from, const symbol to, 
                                const double value) const
{ 
  if (from == to)
    return true;

  try 
    {
      const Oldunits::Convert& conv = get_convertion (from, to);
      if (!conv.valid (value))
	return false;
    }
  catch (...)
    {
      return false;
    }
  return true;
}
/*
**Treat arg
*/
t_list		*treat_arg(t_list *list, char *str)
{
  t_format	*format;
  t_list	*elt;

  format = malloc_format();
  format->attribut = get_attribut(str);
  format->field_width = get_field_width(str);
  format->precision = get_precision(str);
  format->len_modif = get_len_modif(str);
  format->convertion = str[0];
  format->disp_func = get_convertion(str);
  if (format->len_modif & mod_ll_v && 
      (pf_char_is_in_base(format->convertion, "diouxXb") != -1))
    format->size_on_stack = sizeof(long long);
  else
    format->size_on_stack = sizeof(int);
  elt = pf_xmalloc(sizeof(*elt));
  elt->data = format;
  return (pf_insert_queue(list, elt));
}