Terminal++ 3.1.0.4
A C++ library for interacting with ANSI terminal windows
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
terminalpp::string Class Reference

A class that represents strings of elements. More...

#include <string.hpp>

Public Types

using value_type = element
 Container Typedefs.
 
using reference = value_type &
 
using const_reference = value_type const &
 
using pointer = element *
 
using const_pointer = element const *
 
using iterator = elements_storage::iterator
 
using const_iterator = elements_storage::const_iterator
 
using reverse_iterator = elements_storage::reverse_iterator
 
using const_reverse_iterator = elements_storage::const_reverse_iterator
 
using difference_type = std::ptrdiff_t
 
using size_type = std::size_t
 

Public Member Functions

 string ()=default
 Constructor.
 
template<std::forward_iterator ForwardIterator>
 string (ForwardIterator &&begin, ForwardIterator &&end)
 Range Constructor.
 
 string (std::initializer_list< element > const &ilist)
 Initializer List Constructor.
 
 string (char const *text)
 Constructor.
 
 string (char const *text, size_type len)
 Constructor.
 
 string (std::string const &text)
 Constructor.
 
 string (std::string const &text, terminalpp::attribute const &attr)
 Constructor.
 
 string (size_type size, terminalpp::element const &elem)
 Construct a string of a number of identical elements.
 
size_type size () const
 Returns the number of elements in the string.
 
iterator begin ()
 Returns an iterator to the beginning of the string.
 
const_iterator begin () const
 Returns an iterator to the beginning of the string.
 
reverse_iterator rbegin ()
 Returns a reverse iterator to the reverse beginning of the string.
 
const_reverse_iterator rbegin () const
 Returns a reverse iterator to the reverse beginning of the string.
 
iterator end ()
 Returns an iterator to the end of the string.
 
const_iterator end () const
 Returns an iterator to the end of the string.
 
reverse_iterator rend ()
 Returns a reverse iterator to the reverse end of the string.
 
const_reverse_iterator rend () const
 Returns a reverse iterator to the reverse end of the string.
 
const_iterator cbegin ()
 Returns an iterator to the beginning of the string.
 
const_iterator cend ()
 Returns an iterator to the end of the string.
 
void swap (string &other) noexcept
 Swaps the contents of this and another string.
 
size_type max_size () const
 Returns the maximum size of the string allowed.
 
bool empty () const
 Returns whether the string is empty or not.
 
reference operator[] (size_type index)
 Array access operator.
 
const_reference operator[] (size_type index) const
 Array access operator.
 
stringoperator+= (element const &elem)
 Append operator.
 
stringoperator+= (string const &rhs)
 Append operator.
 
void insert (iterator pos, element const &elem)
 Inserts an element at the iterator position.
 
template<class InputIterator >
void insert (iterator pos, InputIterator range_begin, InputIterator range_end)
 Inserts a range of elements at the iterator position.
 
void erase ()
 Erase.
 
void erase (iterator range_begin)
 Erase.
 
void erase (iterator range_begin, iterator range_end)
 Erase.
 

Friends

string operator+ (string lhs, element const &rhs)
 Append operator.
 
string operator+ (string lhs, string const &rhs)
 Append operator.
 
auto operator<=> (string const &lhs, string const &rhs) noexcept=default
 Relational operators for strings.
 
TERMINALPP_EXPORT friend bool operator== (string const &lhs, string const &rhs)
 Equality operator.
 
std::size_t hash_value (string const &str) noexcept
 Hash function.
 

Detailed Description

A class that represents strings of elements.

Note: models an STL container.

Constructor & Destructor Documentation

◆ string() [1/5]

terminalpp::string::string ( char const text)

Constructor.

Parameters
textthe text to build this string around. Results in a string with the passed text, with all attributes their default values.

◆ string() [2/5]

terminalpp::string::string ( char const text,
size_type  len 
)

Constructor.

Parameters
textthe text to build this string around.
lenthe length of text. Results in a string of length len with the passed text, with all attributes their default values.

◆ string() [3/5]

terminalpp::string::string ( std::string const text)

Constructor.

Parameters
textthe text to build this string around Results in a string with the passed text, with all attributes their default values.

◆ string() [4/5]

terminalpp::string::string ( std::string const text,
terminalpp::attribute const attr 
)

Constructor.

Parameters
textthe text to build this string around.
attrthe attribute to apply to each new element of the string.

◆ string() [5/5]

terminalpp::string::string ( size_type  size,
terminalpp::element const elem 
)

Construct a string of a number of identical elements.

Parameters
sizethe size of the string to construct.
elema prototype element to fill the string with

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