mCRL2
Loading...
Searching...
No Matches
mcrl2::utilities::number_postfix_generator Class Reference

Identifier generator that generates names consisting of a prefix followed by a number. For each prefix an index is maintained, that is incremented after each call to operator()(prefix). More...

#include <number_postfix_generator.h>

Public Member Functions

 number_postfix_generator (std::string hint="FRESH_VAR")
 Constructor.
 
void add_identifier (const std::string &id)
 Adds the strings in the range [first, last) to the context.
 
template<typename Iter >
void add_identifiers (Iter first, Iter last)
 Adds the strings in the range [first, last) to the context.
 
template<typename Iter >
 number_postfix_generator (Iter first, Iter last, 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.
 
std::string operator() () const
 Generates a fresh identifier that doesn't appear in the context.
 
const std::string & hint () const
 Returns the default hint.
 
std::string & hint ()
 Returns the default hint.
 
void clear ()
 Clear the context of the generator.
 

Protected Attributes

std::map< std::string, std::size_t > m_index
 A map that maintains the highest index for each prefix.
 
std::string m_hint
 The default hint.
 

Detailed Description

Identifier generator that generates names consisting of a prefix followed by a number. For each prefix an index is maintained, that is incremented after each call to operator()(prefix).

Definition at line 26 of file number_postfix_generator.h.

Constructor & Destructor Documentation

◆ number_postfix_generator() [1/2]

mcrl2::utilities::number_postfix_generator::number_postfix_generator ( std::string  hint = "FRESH_VAR")
inline

Constructor.

Definition at line 38 of file number_postfix_generator.h.

◆ number_postfix_generator() [2/2]

template<typename Iter >
mcrl2::utilities::number_postfix_generator::number_postfix_generator ( Iter  first,
Iter  last,
std::string  hint = "FRESH_VAR" 
)
inline

Constructor.

Parameters
first
last
hintString hint to use as prefix for generated strings. [first, last) is a sequence of strings that is used as context.

Definition at line 82 of file number_postfix_generator.h.

Member Function Documentation

◆ add_identifier()

void mcrl2::utilities::number_postfix_generator::add_identifier ( const std::string &  id)
inline

Adds the strings in the range [first, last) to the context.

Parameters
idA string

Definition at line 44 of file number_postfix_generator.h.

◆ add_identifiers()

template<typename Iter >
void mcrl2::utilities::number_postfix_generator::add_identifiers ( Iter  first,
Iter  last 
)
inline

Adds the strings in the range [first, last) to the context.

Parameters
first
last[first, last) is a sequence of strings that is used as context.

Definition at line 68 of file number_postfix_generator.h.

◆ clear()

void mcrl2::utilities::number_postfix_generator::clear ( )
inline

Clear the context of the generator.

Definition at line 131 of file number_postfix_generator.h.

◆ hint() [1/2]

std::string & mcrl2::utilities::number_postfix_generator::hint ( )
inline

Returns the default hint.

Definition at line 125 of file number_postfix_generator.h.

◆ hint() [2/2]

const std::string & mcrl2::utilities::number_postfix_generator::hint ( ) const
inline

Returns the default hint.

Definition at line 119 of file number_postfix_generator.h.

◆ operator()() [1/2]

std::string mcrl2::utilities::number_postfix_generator::operator() ( ) const
inline

Generates a fresh identifier that doesn't appear in the context.

Returns
A fresh identifier.

Definition at line 113 of file number_postfix_generator.h.

◆ operator()() [2/2]

std::string mcrl2::utilities::number_postfix_generator::operator() ( std::string  hint,
bool  add_to_context = true 
) const
inline

Generates a fresh identifier that doesn't appear in the context.

Returns
A fresh identifier.

Definition at line 90 of file number_postfix_generator.h.

Member Data Documentation

◆ m_hint

std::string mcrl2::utilities::number_postfix_generator::m_hint
protected

The default hint.

Definition at line 33 of file number_postfix_generator.h.

◆ m_index

std::map<std::string, std::size_t> mcrl2::utilities::number_postfix_generator::m_index
mutableprotected

A map that maintains the highest index for each prefix.

Definition at line 30 of file number_postfix_generator.h.


The documentation for this class was generated from the following file: