Free Electron
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
var_char_buf< SIZE, CharT, Traits, Alloc > Class Template Reference

This class implements the minimal string interface and is intended to be used as a base class for xstring<>, which provides the full string interface. More...

#include <var_char_buf.h>

Public Types

typedef CharT value_type
 STL container interface typedefs: More...
 
typedef value_typepointer
 
typedef const value_typeconst_pointer
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef const value_typeconst_iterator
 
typedef value_typeiterator
 
typedef std::reverse_iterator< const_iterator > const_reverse_iterator
 
typedef std::reverse_iterator< iterator > reverse_iterator
 
typedef Alloc allocator_type
 
typedef Traits traits_type
 String interface typedefs: More...
 

Public Member Functions

 var_char_buf (allocator_type const &a=allocator_type())
 
 var_char_buf (var_char_buf const &s)
 
var_char_bufoperator= (var_char_buf const &s)
 
template<class InputIter >
void insert (iterator pos, InputIter first, InputIter last)
 
iterator erase (iterator first, iterator last)
 
const allocator_type & get_allocator () const
 (Replace can be defined in terms of erase and insert, so the minimal interface can skip it.) More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void clear ()
 
size_t max_size () const
 Proper thing to do is probably to return _allocator.max_size(), but this causes problems: My default allocator returns 0xFFFFFFFF, and in fact will allocate a block of that size, but the memory returned is not actually accessible. More...
 
bool empty () const
 
size_type size () const
 
void swap (var_char_buf &s)
 
void reserve (size_type requested_chars=0)
 
size_type capacity () const
 
const CharT * c_str () const
 
const CharT * data () const
 

Static Public Attributes

static const size_type npos = (var_char_buf<SIZE,CharT,Traits,Alloc>::size_type) -1
 Definition of "npos" constant: More...
 

Protected Member Functions

void release_resources ()
 
void element_initialize (size_type n, value_type c)
 
template<class InputIter >
void range_initialize (InputIter first, InputIter last)
 

Private Attributes

CharT * _buffer
 A variable size buffer implementation: More...
 
CharT * _end
 
CharT _internal_buf [SIZE+1]
 
size_type _num_chars_allocated
 

Static Private Attributes

static allocator_type _allocator
 Definition of _allocator instance, shared between all strings of a given type: More...
 

Detailed Description

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
class var_char_buf< SIZE, CharT, Traits, Alloc >

This class implements the minimal string interface and is intended to be used as a base class for xstring<>, which provides the full string interface.

Member Typedef Documentation

◆ traits_type

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
typedef Traits var_char_buf< SIZE, CharT, Traits, Alloc >::traits_type

String interface typedefs:

◆ value_type

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
typedef CharT var_char_buf< SIZE, CharT, Traits, Alloc >::value_type

STL container interface typedefs:

Member Function Documentation

◆ get_allocator()

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
const allocator_type& var_char_buf< SIZE, CharT, Traits, Alloc >::get_allocator ( ) const
inline

(Replace can be defined in terms of erase and insert, so the minimal interface can skip it.)

References var_char_buf< SIZE, CharT, Traits, Alloc >::_allocator, and var_char_buf< SIZE, CharT, Traits, Alloc >::_buffer.

◆ max_size()

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
size_t var_char_buf< SIZE, CharT, Traits, Alloc >::max_size ( ) const
inline

Proper thing to do is probably to return _allocator.max_size(), but this causes problems: My default allocator returns 0xFFFFFFFF, and in fact will allocate a block of that size, but the memory returned is not actually accessible.

This causes problems for test code that wants to stress test the string (it breaks std::string too). Thus the following hack.

References var_char_buf< SIZE, CharT, Traits, Alloc >::_allocator, and var_char_buf< SIZE, CharT, Traits, Alloc >::_buffer.

Referenced by var_char_buf< SIZE, CharT, Traits, Alloc >::reserve().

◆ reserve()

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
void var_char_buf< SIZE, CharT, Traits, Alloc >::reserve ( size_type  requested_chars = 0)
inline

Member Data Documentation

◆ _allocator

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
var_char_buf< SIZE, CharT, Traits, Alloc >::allocator_type var_char_buf< SIZE, CharT, Traits, Alloc >::_allocator
staticprivate

◆ _buffer

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
CharT* var_char_buf< SIZE, CharT, Traits, Alloc >::_buffer
private

◆ npos

template<size_t SIZE, class CharT = char, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT>>
const var_char_buf< SIZE, CharT, Traits, Alloc >::size_type var_char_buf< SIZE, CharT, Traits, Alloc >::npos = (var_char_buf<SIZE,CharT,Traits,Alloc>::size_type) -1
static

Definition of "npos" constant:


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