Defined in word-range.hpp.
An instance of this class is used to convert from word_type to std::string. The letters in the word are converted to characters according to their position in alphabet used to construct a ToString instance if one is provided, or using human_readable_letter otherwise.
Public Member Functions | |
| ToString () | |
| Default constructor. | |
| ToString (std::string const &alphabet) | |
| Construct with given alphabet. | |
| ToString (ToString &&) | |
| Default move constructor. | |
| ToString (ToString const &) | |
| Default copy constructor. | |
| std::string | alphabet () const |
| Return the alphabet used for conversion. | |
| void | call_no_checks (std::string &output, word_type const &input) const |
| Convert a word_type to a std::string. | |
| std::string | call_no_checks (word_type const &input) const |
| Convert a word_type to a std::string. | |
| bool | can_convert_letter (letter_type const &l) const |
| bool | empty () const noexcept |
| Check if the alphabet is defined. | |
| ToString & | init () noexcept |
| Initialize an existing ToString object. | |
| ToString & | init (std::string const &alphabet) |
| Initialize an existing Tostring object. | |
| template<typename InputRange, typename = std::enable_if_t<rx::is_input_or_sink_v<InputRange>>> | |
| constexpr auto | operator() (InputRange &&input) const |
| Call operator for combining with other range objects. | |
| template<typename Int> | |
| std::string | operator() (std::initializer_list< Int > input) const |
| Convert a std::initializer_list to a std::string. | |
| void | operator() (std::string &output, word_type const &input) const |
| Convert a word_type to a std::string. | |
| std::string | operator() (word_type const &input) const |
| Convert a word_type to a std::string. | |
| ToString & | operator= (ToString &&) |
| Default move assignment. | |
| ToString & | operator= (ToString const &) |
| Default copy assignment. | |
|
inline |
Constructs an empty object with no alphabet set.
| ToString | ( | ToString const & | ) |
Default copy constructor.
| ToString | ( | ToString && | ) |
Default move constructor.
|
inlineexplicit |
Construct a ToString object with the given alphabet.
| alphabet | the alphabet. |
| LibsemigroupsException | if there are repeated letters in alphabet. |
|
nodiscard |
This function returns a std::string corresponding to the ordered-set alphabet \(\{a_0, a_1, \dots a_{n-1}\}\) that the initialised ToString object will use to convert from a word_type to a std::string. Specifically, \(i\mapsto a_i\) where \(i\) will correspond to a letter in a word_type, and \(a_i\) is a char.
If this function returns the empty string, then conversion will be performed using human_readable_index.
| void call_no_checks | ( | std::string & | output, |
| word_type const & | input ) const |
This function converts its second argument input into a std::string and stores the result in the first argument output. The characters of input are converted using the alphabet used to construct the object or set via init(), or with human_readable_letter if empty returns true.
The contents of the first argument output, if any, is removed.
| output | std::string to hold the result. |
| input | the word_type to convert. |
input contains letters that do not correspond to letters of the alphabet, then bad things will happen.
|
inlinenodiscard |
This function converts its argument input into a std::string. The characters of input are converted using the alphabet used to construct the object or set via init(), or with human_readable_letter if empty returns true.
| input | the word_type to convert. |
input contains letters that do not correspond to letters of the alphabet, then bad things will happen.
|
inlinenodiscard |
Check if the current ToString instance can convert a specified letter.
This function returns true if l can can be converted to a char using this ToString instance, and false otherwise.
| l | the letter to check the convertibility of. |
|
inlinenodiscardnoexcept |
This function return true if no alphabet has been defined, and false otherwise.
bool.
|
inlinenoexcept |
This function puts a ToString object back into the same state as if it had been newly default constructed.
*this.| ToString & init | ( | std::string const & | alphabet | ) |
This function puts a ToString object back into the same state as if it had been newly constructed from alphabet.
| alphabet | the alphabet. |
*this.| LibsemigroupsException | if there are repeated letters in alphabet. |
|
inlinenodiscardconstexpr |
A custom combinator for rx::ranges to convert the output of a WordRange object into std::string, that can be combined with other combinators using operator|.
|
inlinenodiscard |
This function converts its argument input into a std::string, by first converting it to a word_type. The characters of input are converted using the alphabet used to construct the object or set via init(), or with human_readable_letter if empty returns true.
| input | the initializer list to convert. |
| LibsemigroupsException | if the alphabet used to define an instance of ToString is not empty and input contains letters that do not correspond to letters of the alphabet. |
| void operator() | ( | std::string & | output, |
| word_type const & | input ) const |
This function converts its second argument input into a std::string and stores the result in the first argument output. The characters of input are converted using the alphabet used to construct the object or set via init(), or with human_readable_letter if empty returns true.
The contents of the first argument output, if any, is removed.
| output | word to hold the result. |
| input | the string to convert. |
| LibsemigroupsException | if the alphabet used to define an instance of ToString is not empty and input contains letters that do not correspond to letters of the alphabet. |
|
inlinenodiscard |
This function converts its argument input into a std::string. The characters of input are converted using the alphabet used to construct the object or set via init(), or with human_readable_letter if empty returns true.
| input | the string to convert. |
| LibsemigroupsException | if the alphabet used to define an instance of ToString is not empty and input contains letters that do not correspond to letters of the alphabet. |