![]() |
libsemigroups
v3.0.0
C++ library for semigroups and monoids
|
Defined in word-range.hpp
.
An instance of this class is used to convert from std::string to word_type. The characters in the string are converted to integers according to their position in alphabet used to construct a ToWord instance if one is provided, or using human_readable_index otherwise.
Public Member Functions | |
ToWord () | |
Default constructor. | |
ToWord (std::string const &alphabet) | |
Construct with given alphabet. | |
ToWord (ToWord &&) | |
Default move constructor. | |
ToWord (ToWord const &) | |
Default copy constructor. | |
std::string | alphabet () const |
Return the alphabet used for conversion. | |
letter_type | call_no_checks (char input) const |
Convert a char to a letter_type. | |
word_type | call_no_checks (std::string const &input) const |
Convert a string to a word_type. | |
void | call_no_checks (word_type &output, std::string const &input) const |
Convert a string to a word_type. | |
bool | can_convert_letter (char const &c) const |
bool | empty () const noexcept |
Check if the alphabet is defined. | |
ToWord & | init () |
Initialize an existing ToWord object. | |
ToWord & | init (std::string const &alphabet) |
Initialize an existing ToWord object. | |
letter_type | operator() (char input) const |
Convert a char to a letter_type. | |
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. | |
word_type | operator() (std::string const &input) const |
Convert a string to a word_type. | |
void | operator() (word_type &output, std::string const &input) const |
Convert a string to a word_type. | |
ToWord & | operator= (ToWord &&) |
Default move assignment. | |
ToWord & | operator= (ToWord const &) |
Default copy assignment. | |
|
inline |
Constructs an empty object with no alphabet set.
|
inlineexplicit |
Construct a ToWord 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 ToWord object will use to convert from std::string to word_type. Specifically, \(a_i \mapsto i\) where \(a_i\) will correspond to a letter in a std::string, and \(i\) is a letter_type.
If this function returns the empty string, then conversion will be performed using human_readable_index.
|
inlinenodiscard |
This function converts its argument input
into a letter_type. It is converted using the alphabet used to construct the object or set via init(), or with human_readable_index if empty returns true
.
input | the character to convert. |
input
does not correspond to a letter of the alphabet, then bad things will happen.
|
inlinenodiscard |
This function converts its argument input
into 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_index if empty returns true
.
input | the string to convert. |
input
contains letters that do not correspond to letters of the alphabet, then bad things will happen.void call_no_checks | ( | word_type & | output, |
std::string const & | input ) const |
This function converts its second argument input
into a word_type 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_index 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. |
input
contains letters that do not correspond to letters of the alphabet, then bad things will happen.
|
inlinenodiscard |
Check if the current ToWord instance can convert a specified letter.
This function returns true
if c
can can be converted to a letter_type using this ToWord instance, and false
otherwise.
c | the char to check the convertibility of. |
|
inlinenodiscardnoexcept |
This function returns true
if no alphabet has been defined, and false
otherwise.
bool
.noexcept
and is guaranteed never to throw.
|
inline |
This function puts a ToWord object back into the same state as if it had been newly default constructed.
*this
.ToWord & init | ( | std::string const & | alphabet | ) |
This function puts a ToWord 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 . |
|
inlinenodiscard |
This function converts its argument input
into a letter_type. It is converted using the alphabet used to construct the object or set via init(), or with human_readable_index if empty returns true
.
input | the character to convert. |
LibsemigroupsException | if the alphabet used to define an instance of ToWord is not empty and input does not correspond to a letter of the alphabet. |
|
inlinenodiscardconstexpr |
A custom combinator for rx::ranges to convert the output of a StringRange object into word_type, that can be combined with other combinators using operator|
.
|
inlinenodiscard |
This function converts its argument input
into 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_index if empty returns true
.
input | the string to convert. |
LibsemigroupsException | if the alphabet used to define an instance of ToWord is not empty and input contains letters that do not correspond to letters of the alphabet. |
void operator() | ( | word_type & | output, |
std::string const & | input ) const |
This function converts its second argument input
into a word_type 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_index 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 ToWord is not empty and input contains letters that do not correspond to letters of the alphabet. |