12#ifndef MCRL2_UTILITIES_NUMBER_POSTFIX_GENERATOR_H
13#define MCRL2_UTILITIES_NUMBER_POSTFIX_GENERATOR_H
30 mutable std::map<std::string, std::size_t>
m_index;
46 std::string::size_type i =
id.find_last_not_of(
"0123456789");
47 std::size_t new_index = 0;
49 if (i == std::string::npos ||
id.size() == i + 1)
55 name =
id.substr(0, i + 1);
56 std::string num =
id.substr(i + 1);
57 new_index = atoi(num.c_str());
60 m_index[name] = (std::max)(old_index, new_index);
67 template <
typename Iter>
70 for (Iter i = first; i != last; ++i)
81 template <
typename Iter>
93 if (std::isdigit(
hint[
hint.size() - 1]))
95 std::string::size_type i =
hint.find_last_not_of(
"0123456789");
115 return (*
this)(
m_hint,
true);
119 const std::string&
hint()
const
Identifier generator that generates names consisting of a prefix followed by a number....
number_postfix_generator(std::string hint="FRESH_VAR")
Constructor.
std::string operator()(std::string hint, bool add_to_context=true) const
Generates a fresh identifier that doesn't appear in the context.
void add_identifiers(Iter first, Iter last)
Adds the strings in the range [first, last) to the context.
number_postfix_generator(Iter first, Iter last, std::string hint="FRESH_VAR")
Constructor.
void clear()
Clear the context of the generator.
std::string m_hint
The default hint.
std::map< std::string, std::size_t > m_index
A map that maintains the highest index for each prefix.
void add_identifier(const std::string &id)
Adds the strings in the range [first, last) to the context.
const std::string & hint() const
Returns the default hint.
std::string & hint()
Returns the default hint.
std::string operator()() const
Generates a fresh identifier that doesn't appear in the context.
void number2string(std::size_t number, std::string &buffer, std::size_t start_position)
Convert a number to a string in the buffer starting at position start_position.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
String manipulation functions.