Commit 727c3516 authored by Alexandre Lewkowicz's avatar Alexandre Lewkowicz

common_conv: Parse comma and space separated numbers

* src/bin/common_conv.cc, src/bin/common_conv.hh: Here.
parent 78def4f8
......@@ -80,3 +80,21 @@ read_automaton(const char* filename, spot::bdd_dict_ptr& dict)
error(2, 0, "failed to read automaton from %s", filename);
return std::move(p->aut);
}
std::vector<long>
to_longs(const char* arg)
{
std::vector<long> res;
while (*arg)
{
char* endptr;
long value = strtol(arg, &endptr, 10);
if (endptr == arg)
error(2, 0, "failed to parse '%s' as an integer.", arg);
res.push_back(value);
while (*endptr == ' ' || *endptr == ',')
++endptr;
arg = endptr;
}
return res;
}
......@@ -29,6 +29,9 @@ unsigned to_unsigned (const char *s);
float to_float(const char* s);
float to_probability(const char* s);
// Parse the comma or space seperate string of numbers.
std::vector<long> to_longs(const char* s);
spot::tgba_digraph_ptr
read_automaton(const char* filename, spot::bdd_dict_ptr& dict);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment