tfel
Loading...
Searching...
No Matches
tfel::utilities::basic_fcstring< N, CharT, Traits > Struct Template Reference

This class implements a string with fixed capacity. In pratice, a simple wrapper around std::array<CharT> providing an API inspired by std::basic_string. More...

#include </home/runner/work/tfel/tfel/include/TFEL/Utilities/FCString.hxx>

Inheritance diagram for tfel::utilities::basic_fcstring< N, CharT, Traits >:

Public Member Functions

 basic_fcstring ()
 default constructor
template<typename Alloc>
 basic_fcstring (const std::basic_string< CharT, Traits, Alloc > &)
 basic_fcstring (const CharT *)
 basic_fcstring (const CharT *, const bool)
template<std::size_t N2>
 basic_fcstring (const CStringNarrowedView< N2, CharT > &)
 constructor from a restricted view of a C-string. This allows build a basic_fcstring from a static array of characters.
 basic_fcstring (basic_fcstring &&) noexcept
 move constructor
 basic_fcstring (const basic_fcstring &)
 copy constructor
basic_fcstring & operator= (basic_fcstring &&) noexcept
 move constructor
basic_fcstring & operator= (const basic_fcstring &)
 copy constructor
template<typename Alloc>
basic_fcstring & operator= (const std::basic_string< CharT, Traits, Alloc > &)
template<std::size_t N2>
basic_fcstring & operator= (const CStringNarrowedView< N2, CharT > &)
 constructor from a restricted view of a C-string. This allows build a basic_fcstring from a static array of characters.
CharT & operator[] (const std::size_t)
 access opeartor
const CharT & operator[] (const std::size_t) const
 access opeartor
CharT & at (const std::size_t)
const CharT & at (const std::size_t) const
basic_fcstring & operator= (const CharT *)
 operator std::basic_string< CharT, Traits > () const
 implicit conversion operator to std::string
bool empty () const
std::size_t size () const
auto end () -> typename std::array< CharT, N+1 >::iterator
auto end () const -> typename std::array< CharT, N+1 >::const_iterator
auto cend () const -> typename std::array< CharT, N+1 >::const_iterator
auto rbegin () -> typename std::array< CharT, N+1 >::reverse_iterator
auto rbegin () const -> typename std::array< CharT, N+1 >::const_reverse_iterator
auto crbegin () const -> typename std::array< CharT, N+1 >::const_reverse_iterator
CharT & back ()
const CharT & back () const
void pop_back ()
 remove last character of the string
bool strcmp (const CharT *) const
 comparison operator
bool strcmp (const CharT *, const typename std::array< CharT, N+1 >::size_type) const
 comparison operator
template<typename Alloc>
basic_fcstring< N, CharT, Traits > & operator= (const std::basic_string< CharT, Traits, Alloc > &rhs)
template<std::size_t N2>
basic_fcstring< N, CharT, Traits > & operator= (const CStringNarrowedView< N2, CharT > &rhs)

Static Public Member Functions

static std::size_t strnlen (const CharT *)

Detailed Description

template<std::size_t N, typename CharT, typename Traits>
struct tfel::utilities::basic_fcstring< N, CharT, Traits >

This class implements a string with fixed capacity. In pratice, a simple wrapper around std::array<CharT> providing an API inspired by std::basic_string.

Template Parameters
CharTType of character
TraitsTraits for character type, defaults to std::char_traits<CharT>.

Constructor & Destructor Documentation

◆ basic_fcstring() [1/4]

template<std::size_t N, typename CharT, typename Traits>
template<typename Alloc>
tfel::utilities::basic_fcstring< N, CharT, Traits >::basic_fcstring ( const std::basic_string< CharT, Traits, Alloc > & src)

constructor from std::string

Parameters
[in]srcsource

◆ basic_fcstring() [2/4]

template<std::size_t N, typename CharT, typename Traits>
tfel::utilities::basic_fcstring< N, CharT, Traits >::basic_fcstring ( const CharT * src)

constructor from C-string

Parameters
[in]srcsource

◆ basic_fcstring() [3/4]

template<std::size_t N, typename CharT, typename Traits>
tfel::utilities::basic_fcstring< N, CharT, Traits >::basic_fcstring ( const CharT * src,
const bool b )

constructor from C-string

Parameters
[in]srcsource
[in]brestrict the source

◆ basic_fcstring() [4/4]

template<std::size_t N, typename CharT, typename Traits>
template<std::size_t N2>
tfel::utilities::basic_fcstring< N, CharT, Traits >::basic_fcstring ( const CStringNarrowedView< N2, CharT > & src)

constructor from a restricted view of a C-string. This allows build a basic_fcstring from a static array of characters.

Parameters
[in]srcsource

Member Function Documentation

◆ at() [1/2]

template<std::size_t N, typename CharT, typename Traits>
CharT & tfel::utilities::basic_fcstring< N, CharT, Traits >::at ( const std::size_t i)
Parameters
[in]iindex
Returns
the element at the given position

◆ at() [2/2]

template<std::size_t N, typename CharT, typename Traits>
const CharT & tfel::utilities::basic_fcstring< N, CharT, Traits >::at ( const std::size_t i) const
Parameters
[in]iindex
Returns
the element at the given position

◆ back() [1/2]

template<std::size_t N, typename CharT, typename Traits>
CharT & tfel::utilities::basic_fcstring< N, CharT, Traits >::back ( )
Returns
the last character of the string

◆ back() [2/2]

template<std::size_t N, typename CharT, typename Traits>
const CharT & tfel::utilities::basic_fcstring< N, CharT, Traits >::back ( ) const
Returns
the last character of the string

◆ cend()

template<std::size_t N, typename CharT, typename Traits>
auto tfel::utilities::basic_fcstring< N, CharT, Traits >::cend ( ) const->typenamestd::array< CharT, N+1 >::const_iterator
Returns
an iterator past-the end of the string

◆ crbegin()

template<std::size_t N, typename CharT, typename Traits>
auto tfel::utilities::basic_fcstring< N, CharT, Traits >::crbegin ( ) const->typenamestd::array< CharT, N+1 >::const_reverse_iterator
Returns
an reverse iterator at the end of the string

◆ empty()

template<std::size_t N, typename CharT, typename Traits>
bool tfel::utilities::basic_fcstring< N, CharT, Traits >::empty ( ) const
Returns
true if the first character is '\0'

◆ end() [1/2]

template<std::size_t N, typename CharT, typename Traits>
auto tfel::utilities::basic_fcstring< N, CharT, Traits >::end ( ) ->typenamestd::array< CharT, N+1 >::iterator
Returns
an iterator past-the end of the string

◆ end() [2/2]

template<std::size_t N, typename CharT, typename Traits>
auto tfel::utilities::basic_fcstring< N, CharT, Traits >::end ( ) const->typenamestd::array< CharT, N+1 >::const_iterator
Returns
an iterator past-the end of the string

◆ operator=() [1/3]

template<std::size_t N, typename CharT, typename Traits>
basic_fcstring< N, CharT, Traits > & tfel::utilities::basic_fcstring< N, CharT, Traits >::operator= ( const CharT * rhs)

constructor from C-string

Parameters
[in]rhssource
Returns
this object

◆ operator=() [2/3]

template<std::size_t N, typename CharT, typename Traits>
template<std::size_t N2>
basic_fcstring & tfel::utilities::basic_fcstring< N, CharT, Traits >::operator= ( const CStringNarrowedView< N2, CharT > & )

constructor from a restricted view of a C-string. This allows build a basic_fcstring from a static array of characters.

Parameters
[in]rhssource

◆ operator=() [3/3]

template<std::size_t N, typename CharT, typename Traits>
template<typename Alloc>
basic_fcstring & tfel::utilities::basic_fcstring< N, CharT, Traits >::operator= ( const std::basic_string< CharT, Traits, Alloc > & )

constructor from std::string

Parameters
[in]rhssource
Returns
this object

◆ operator[]() [1/2]

template<std::size_t N, typename CharT, typename Traits>
CharT & tfel::utilities::basic_fcstring< N, CharT, Traits >::operator[] ( const std::size_t i)

access opeartor

Parameters
[in]iindex
Returns
the element at the given position

◆ operator[]() [2/2]

template<std::size_t N, typename CharT, typename Traits>
const CharT & tfel::utilities::basic_fcstring< N, CharT, Traits >::operator[] ( const std::size_t i) const

access opeartor

Parameters
[in]iindex
Returns
the element at the given position

◆ rbegin() [1/2]

template<std::size_t N, typename CharT, typename Traits>
auto tfel::utilities::basic_fcstring< N, CharT, Traits >::rbegin ( ) ->typenamestd::array< CharT, N+1 >::reverse_iterator
Returns
an reverse iterator at the end of the string

◆ rbegin() [2/2]

template<std::size_t N, typename CharT, typename Traits>
auto tfel::utilities::basic_fcstring< N, CharT, Traits >::rbegin ( ) const->typenamestd::array< CharT, N+1 >::const_reverse_iterator
Returns
an reverse iterator at the end of the string

◆ size()

template<std::size_t N, typename CharT, typename Traits>
std::size_t tfel::utilities::basic_fcstring< N, CharT, Traits >::size ( ) const
Returns
the actual size of the string

◆ strcmp() [1/2]

template<std::size_t N, typename CharT, typename Traits>
bool tfel::utilities::basic_fcstring< N, CharT, Traits >::strcmp ( const CharT * s) const

comparison operator

Parameters
[in]sstring
Returns
true if the two string are equals

◆ strcmp() [2/2]

template<std::size_t N, typename CharT, typename Traits>
bool tfel::utilities::basic_fcstring< N, CharT, Traits >::strcmp ( const CharT * o,
const typename std::array< CharT, N+1 >::size_type n ) const

comparison operator

Parameters
[in]sstring
[in]nsize of the string
Returns
true if the two string are equals

◆ strnlen()

template<std::size_t N, typename CharT, typename Traits>
std::size_t tfel::utilities::basic_fcstring< N, CharT, Traits >::strnlen ( const CharT * s)
static
Returns
the size of an external C-string if a null character is found in the N first characters, N+1 otherwise.
Parameters
[in]sexternal C-string

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