MOS Source Code
Loading...
Searching...
No Matches
basic_string< Char, TAllocator > Class Template Reference

#include <string.hpp>

Public Member Functions

 basic_string (std::nullptr_t)=delete
 
 basic_string ()
 
 basic_string (const Char *buffer)
 
 basic_string (const Char *buffer, size_t size)
 
template<class StringViewLike>
 basic_string (const StringViewLike &view)
 
 basic_string (size_t size, Char c=0)
 
 basic_string (const basic_string &other)
 
 basic_string (basic_string &&other)
 
 ~basic_string ()
 
basic_stringoperator= (const Char *buffer)
 
basic_stringoperator= (const mos::basic_string_view< Char > &view)
 
basic_stringoperator= (basic_string &&other)
 
basic_stringoperator= (const basic_string &other)
 
void resize (size_t new_length)
 
basic_string operator+ (const basic_string &other) const
 
basic_string operator+ (Char c) const
 
void push_back (Char c)
 
basic_stringoperator+= (const basic_string_view< Char > &other)
 
basic_stringoperator+= (Char c)
 
const Char * data () const
 
const Char * c_str () const
 
Char & operator[] (size_t index)
 
const Char & operator[] (size_t index) const
 
size_t size () const
 
bool empty () const
 
Char * begin ()
 
const Char * begin () const
 
Char * end ()
 
const Char * end () const
 
bool operator== (const basic_string &other) const
 
bool operator== (const char *rhs) const
 
 operator basic_string_view< Char > () const
 
bool operator== (std::nullptr_t) const =delete
 

Private Member Functions

void _init (const Char *buffer, size_t size)
 
int _do_compare (const Char *other, const size_t other_size) const
 
void _convert_to_long (size_t new_length=0)
 
void _convert_to_short ()
 

Private Attributes

bool _is_long = false
 
size_t _length
 string length excluding null terminator
 
union { 
 
   struct _long_buffer
 
      Char *   _buffer 
 
      size_t   _capacity 
 buffer capacity includes null terminator More...
 
   }   _long 
 
   struct _short_buffer
 
      Char   _buffer [short_string_capacity
 
   }   _short 
 
_data 
 

Friends

basic_string operator+ (const basic_string_view< Char > &lhs, const basic_string &rhs)
 

Detailed Description

template<typename Char, typename TAllocator>
class mos::basic_string< Char, TAllocator >

Definition at line 15 of file string.hpp.

Constructor & Destructor Documentation

◆ basic_string() [1/8]

template<typename Char, typename TAllocator>
basic_string ( std::nullptr_t )
delete

◆ basic_string() [2/8]

template<typename Char, typename TAllocator>
basic_string ( )
inline

Definition at line 37 of file string.hpp.

Referenced by basic_string< char, mos::default_allocator >::operator+.

◆ basic_string() [3/8]

template<typename Char, typename TAllocator>
basic_string ( const Char * buffer)
inline

Definition at line 39 of file string.hpp.

◆ basic_string() [4/8]

template<typename Char, typename TAllocator>
basic_string ( const Char * buffer,
size_t size )
inlineexplicit

Definition at line 44 of file string.hpp.

◆ basic_string() [5/8]

template<typename Char, typename TAllocator>
template<class StringViewLike>
basic_string ( const StringViewLike & view)
inlineexplicit

Definition at line 50 of file string.hpp.

◆ basic_string() [6/8]

template<typename Char, typename TAllocator>
basic_string ( size_t size,
Char c = 0 )
inline

Definition at line 55 of file string.hpp.

◆ basic_string() [7/8]

template<typename Char, typename TAllocator>
basic_string ( const basic_string< Char, TAllocator > & other)
inline

Definition at line 60 of file string.hpp.

◆ basic_string() [8/8]

template<typename Char, typename TAllocator>
basic_string ( basic_string< Char, TAllocator > && other)
inline

Definition at line 65 of file string.hpp.

◆ ~basic_string()

Member Function Documentation

◆ operator=() [1/4]

template<typename Char, typename TAllocator>
basic_string & operator= ( const Char * buffer)
inline

Definition at line 88 of file string.hpp.

◆ operator=() [2/4]

template<typename Char, typename TAllocator>
basic_string & operator= ( const mos::basic_string_view< Char > & view)
inline

Definition at line 108 of file string.hpp.

◆ operator=() [3/4]

template<typename Char, typename TAllocator>
basic_string & operator= ( basic_string< Char, TAllocator > && other)
inline

Definition at line 128 of file string.hpp.

◆ operator=() [4/4]

template<typename Char, typename TAllocator>
basic_string & operator= ( const basic_string< Char, TAllocator > & other)
inline

Definition at line 147 of file string.hpp.

◆ resize()

template<typename Char, typename TAllocator>
void resize ( size_t new_length)
inline

Definition at line 158 of file string.hpp.

◆ operator+() [1/2]

template<typename Char, typename TAllocator>
basic_string operator+ ( const basic_string< Char, TAllocator > & other) const
inline

Definition at line 169 of file string.hpp.

◆ operator+() [2/2]

template<typename Char, typename TAllocator>
basic_string operator+ ( Char c) const
inline

Definition at line 175 of file string.hpp.

◆ push_back()

template<typename Char, typename TAllocator>
void push_back ( Char c)
inline

Definition at line 180 of file string.hpp.

◆ operator+=() [1/2]

template<typename Char, typename TAllocator>
basic_string & operator+= ( const basic_string_view< Char > & other)
inline

◆ operator+=() [2/2]

template<typename Char, typename TAllocator>
basic_string & operator+= ( Char c)
inline

Definition at line 205 of file string.hpp.

◆ data()

◆ c_str()

◆ operator[]() [1/2]

template<typename Char, typename TAllocator>
Char & operator[] ( size_t index)
inline

Definition at line 220 of file string.hpp.

◆ operator[]() [2/2]

template<typename Char, typename TAllocator>
const Char & operator[] ( size_t index) const
inline

Definition at line 225 of file string.hpp.

◆ size()

◆ empty()

template<typename Char, typename TAllocator>
bool empty ( ) const
inline

◆ begin() [1/2]

template<typename Char, typename TAllocator>
Char * begin ( )
inline

Definition at line 240 of file string.hpp.

◆ begin() [2/2]

template<typename Char, typename TAllocator>
const Char * begin ( ) const
inline

Definition at line 245 of file string.hpp.

◆ end() [1/2]

template<typename Char, typename TAllocator>
Char * end ( )
inline

Definition at line 250 of file string.hpp.

◆ end() [2/2]

template<typename Char, typename TAllocator>
const Char * end ( ) const
inline

Definition at line 255 of file string.hpp.

◆ operator==() [1/3]

template<typename Char, typename TAllocator>
bool operator== ( const basic_string< Char, TAllocator > & other) const
inline

Definition at line 260 of file string.hpp.

◆ operator==() [2/3]

template<typename Char, typename TAllocator>
bool operator== ( const char * rhs) const
inline

Definition at line 265 of file string.hpp.

◆ operator basic_string_view< Char >()

template<typename Char, typename TAllocator>
operator basic_string_view< Char > ( ) const
inline

Definition at line 270 of file string.hpp.

+ Here is the call graph for this function:

◆ operator==() [3/3]

template<typename Char, typename TAllocator>
bool operator== ( std::nullptr_t ) const
delete

◆ _init()

◆ _do_compare()

template<typename Char, typename TAllocator>
int _do_compare ( const Char * other,
const size_t other_size ) const
inlineprivate

◆ _convert_to_long()

template<typename Char, typename TAllocator>
void _convert_to_long ( size_t new_length = 0)
inlineprivate

◆ _convert_to_short()

template<typename Char, typename TAllocator>
void _convert_to_short ( )
inlineprivate

Definition at line 320 of file string.hpp.

Referenced by basic_string< char, mos::default_allocator >::resize().

Friends And Related Symbol Documentation

◆ operator+

template<typename Char, typename TAllocator>
basic_string operator+ ( const basic_string_view< Char > & lhs,
const basic_string< Char, TAllocator > & rhs )
friend

Definition at line 153 of file string.hpp.

Referenced by basic_string< char, mos::default_allocator >::operator+().

Member Data Documentation

◆ _is_long

template<typename Char, typename TAllocator>
bool _is_long = false
private

Definition at line 17 of file string.hpp.

◆ _length

template<typename Char, typename TAllocator>
size_t _length
private

string length excluding null terminator

Definition at line 18 of file string.hpp.

Referenced by operator basic_string_view< Char >().

◆ _buffer [1/2]

template<typename Char, typename TAllocator>
Char* _buffer

Definition at line 24 of file string.hpp.

◆ _capacity

template<typename Char, typename TAllocator>
size_t _capacity

buffer capacity includes null terminator

Definition at line 25 of file string.hpp.

◆ [struct]

struct { ... } ::_long_buffer _long

◆ _buffer [2/2]

template<typename Char, typename TAllocator>
Char _buffer[short_string_capacity]

Definition at line 30 of file string.hpp.

◆ [struct]

struct { ... } ::_short_buffer _short

◆ [union]

union { ... } _data

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