common_conv: Parse comma and space separated numbers
* src/bin/common_conv.cc, src/bin/common_conv.hh: Here.
This commit is contained in:
parent
78def4f8ca
commit
727c351657
2 changed files with 21 additions and 0 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue