diff --git a/src/bin/common_conv.cc b/src/bin/common_conv.cc index 707a6abbf..8bead3eea 100644 --- a/src/bin/common_conv.cc +++ b/src/bin/common_conv.cc @@ -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 +to_longs(const char* arg) +{ + std::vector 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; +} diff --git a/src/bin/common_conv.hh b/src/bin/common_conv.hh index 0d6cedda7..ab867b46b 100644 --- a/src/bin/common_conv.hh +++ b/src/bin/common_conv.hh @@ -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 to_longs(const char* s); + spot::tgba_digraph_ptr read_automaton(const char* filename, spot::bdd_dict_ptr& dict);