|
MTMS main
Modern Turing Machine Simulator
|
Represents a formal string (w) consisting of a finite sequence of Symbols. More...
#include <string.hpp>
Public Member Functions | |
| auto | begin () const noexcept |
| Returns an iterator to the beginning of the symbol sequence. | |
| auto | end () const noexcept |
| Returns an iterator to the end of the symbol sequence. | |
| std::string | get_str () const noexcept(false) |
| Reconstructs a standard std::string representation from the underlying symbols. | |
| bool | is_valid_for (const Alphabet &alphabet) const noexcept |
| Validates if all symbols within this string belong to a specific formal Alphabet. | |
| std::size_t | length () const noexcept |
| Returns the total number of symbols contained in the string. | |
| auto | operator<=> (const String &other) const noexcept=default |
| Defaulted three-way comparison operator (C++20 spaceship operator). | |
| String () noexcept=default | |
| Default constructor. | |
| String (const Symbol &symbol) noexcept(false) | |
| Constructs a single-symbol string. | |
| String (std::string_view str) noexcept(false) | |
| Constructs a formal String from a raw string view. | |
| String (std::vector< Symbol > vec) noexcept(false) | |
| Constructs a String by taking ownership of an existing vector of symbols. | |
Private Attributes | |
| std::vector< Symbol > | symbols_ |
| The finite sequence of symbols forming the string. | |
Represents a formal string (w) consisting of a finite sequence of Symbols.
This class encapsulates a collection of symbols, providing validation tools against formal alphabets and standard iterator access for processing.
Definition at line 28 of file string.hpp.
|
defaultnoexcept |
Default constructor.
Initializes an empty string with no symbols.
|
inlineexplicit |
Constructs a single-symbol string.
| symbol | The initial Symbol to wrap. |
Definition at line 40 of file string.hpp.
References symbols_.
|
explicit |
Constructs a formal String from a raw string view.
Custom constructor to morph a raw character stream view into a formal sequence.
| str | The raw character sequence. |
Leverages vector internal resizing strategies via sequential emplace_back pipeline pushes.
Definition at line 20 of file string.cpp.
References symbols_.
|
inlineexplicit |
Constructs a String by taking ownership of an existing vector of symbols.
Uses pass-by-value and std::move to prevent redundant overhead dynamic allocations.
| vec | The source vector of symbols. |
Definition at line 55 of file string.hpp.
|
inlinenoexcept |
Returns an iterator to the beginning of the symbol sequence.
Definition at line 72 of file string.hpp.
References symbols_.
|
inlinenoexcept |
Returns an iterator to the end of the symbol sequence.
Definition at line 77 of file string.hpp.
References symbols_.
| std::string String::get_str | ( | ) | const |
Reconstructs a standard std::string representation from the underlying symbols.
Serializes the formal layout array back into a standard standard library string.
Optimizes performance overhead by pre-allocating heap capacity tokens via reserve().
Definition at line 34 of file string.cpp.
References symbols_.
|
noexcept |
Validates if all symbols within this string belong to a specific formal Alphabet.
Predicate logic pipeline evaluating structural correctness against an Alphabet.
Uses C++20 ranges to perform a clean and optimized all-of predicate check.
| alphabet | The formal Alphabet descriptor to validate against. |
Evaluates short-circuit logical breaks using standard library ranges algorithms.
Definition at line 52 of file string.cpp.
Referenced by TuringMachine::load_input().
|
inlinenoexcept |
Returns the total number of symbols contained in the string.
Definition at line 61 of file string.hpp.
References symbols_.
|
defaultnoexcept |
Defaulted three-way comparison operator (C++20 spaceship operator).
Instructs the compiler to automatically generate standard relational operators (<, <=, >, >=, ==, !=) based on the underlying symbols_ member.
| other | The other String instance to compare against. |
|
private |