Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
internal::basic_buffer< T > Class Template Referenceabstract

#include <core.h>

Inheritance diagram for internal::basic_buffer< T >:
basic_memory_buffer< T, SIZE, Allocator >

Public Types

typedef T value_type
 
typedef const T & const_reference
 

Public Member Functions

virtual ~basic_buffer ()
 
T * begin () FMT_NOEXCEPT
 
T * end () FMT_NOEXCEPT
 
std::size_t size () const FMT_NOEXCEPT
 
std::size_t capacity () const FMT_NOEXCEPT
 
T * data () FMT_NOEXCEPT
 
const T * data () const FMT_NOEXCEPT
 
void resize (std::size_t new_size)
 
void clear ()
 
void reserve (std::size_t new_capacity)
 
void push_back (const T &value)
 
template<typename U >
void append (const U *begin, const U *end)
 
T & operator[] (std::size_t index)
 
const T & operator[] (std::size_t index) const
 

Protected Member Functions

 basic_buffer (std::size_t sz) FMT_NOEXCEPT
 
 basic_buffer (T *p=FMT_NULL, std::size_t sz=0, std::size_t cap=0) FMT_NOEXCEPT
 
void set (T *buf_data, std::size_t buf_capacity) FMT_NOEXCEPT
 
virtual void grow (std::size_t capacity)=0
 

Private Member Functions

 basic_buffer (const basic_buffer &)=delete
 
void operator= (const basic_buffer &)=delete
 

Private Attributes

T * ptr_
 
std::size_t size_
 
std::size_t capacity_
 

Detailed Description

template<typename T>
class internal::basic_buffer< T >

A contiguous memory buffer with an optional growing ability.

Definition at line 215 of file core.h.

Member Typedef Documentation

template<typename T>
typedef const T& internal::basic_buffer< T >::const_reference

Definition at line 242 of file core.h.

template<typename T>
typedef T internal::basic_buffer< T >::value_type

Definition at line 241 of file core.h.

Constructor & Destructor Documentation

template<typename T>
internal::basic_buffer< T >::basic_buffer ( const basic_buffer< T > &  )
privatedelete
template<typename T>
internal::basic_buffer< T >::basic_buffer ( std::size_t  sz)
inlineprotected

Definition at line 226 of file core.h.

226 : size_(sz), capacity_(sz) {}
std::size_t capacity_
Definition: core.h:222
std::size_t size_
Definition: core.h:221
template<typename T>
internal::basic_buffer< T >::basic_buffer ( T *  p = FMT_NULL,
std::size_t  sz = 0,
std::size_t  cap = 0 
)
inlineprotected

Definition at line 228 of file core.h.

229  : ptr_(p), size_(sz), capacity_(cap) {}
std::size_t capacity_
Definition: core.h:222
std::size_t size_
Definition: core.h:221
p
Definition: test.py:223
template<typename T>
virtual internal::basic_buffer< T >::~basic_buffer ( )
inlinevirtual

Definition at line 244 of file core.h.

244 {}

Member Function Documentation

template<typename T >
template<typename U >
void internal::basic_buffer< T >::append ( const U *  begin,
const U *  end 
)

Appends data to the end of the buffer.

Definition at line 394 of file format.h.

394  {
395  std::size_t new_size = size_ + internal::to_unsigned(end - begin);
396  reserve(new_size);
397  std::uninitialized_copy(begin, end,
399  size_ = new_size;
400 }
T * begin() FMT_NOEXCEPT
Definition: core.h:246
std::size_t capacity_
Definition: core.h:222
std::size_t size_
Definition: core.h:221
void reserve(std::size_t new_capacity)
Definition: core.h:273
T * make_checked(T *p, std::size_t)
Definition: format.h:389
FMT_CONSTEXPR std::make_unsigned< Int >::type to_unsigned(Int value)
Definition: core.h:208
T * end() FMT_NOEXCEPT
Definition: core.h:247
template<typename T>
T* internal::basic_buffer< T >::begin ( )
inline

Definition at line 246 of file core.h.

246 { return ptr_; }
template<typename T>
std::size_t internal::basic_buffer< T >::capacity ( ) const
inline

Returns the capacity of this buffer.

Definition at line 253 of file core.h.

253 { return capacity_; }
std::size_t capacity_
Definition: core.h:222
template<typename T>
void internal::basic_buffer< T >::clear ( void  )
inline

Clears this buffer.

Definition at line 270 of file core.h.

270 { size_ = 0; }
std::size_t size_
Definition: core.h:221
template<typename T>
T* internal::basic_buffer< T >::data ( )
inline

Returns a pointer to the buffer data.

Definition at line 256 of file core.h.

256 { return ptr_; }
template<typename T>
const T* internal::basic_buffer< T >::data ( ) const
inline

Returns a pointer to the buffer data.

Definition at line 259 of file core.h.

259 { return ptr_; }
template<typename T>
T* internal::basic_buffer< T >::end ( void  )
inline

Definition at line 247 of file core.h.

247 { return ptr_ + size_; }
std::size_t size_
Definition: core.h:221
template<typename T>
virtual void internal::basic_buffer< T >::grow ( std::size_t  capacity)
protectedpure virtual

Increases the buffer capacity to hold at least capacity elements.

Implemented in basic_memory_buffer< T, SIZE, Allocator >, basic_memory_buffer< Char >, and internal::container_buffer< Container >.

template<typename T>
void internal::basic_buffer< T >::operator= ( const basic_buffer< T > &  )
privatedelete
template<typename T>
T& internal::basic_buffer< T >::operator[] ( std::size_t  index)
inline

Definition at line 287 of file core.h.

template<typename T>
const T& internal::basic_buffer< T >::operator[] ( std::size_t  index) const
inline

Definition at line 288 of file core.h.

template<typename T>
void internal::basic_buffer< T >::push_back ( const T &  value)
inline

Definition at line 278 of file core.h.

278  {
279  reserve(size_ + 1);
280  ptr_[size_++] = value;
281  }
std::size_t size_
Definition: core.h:221
void reserve(std::size_t new_capacity)
Definition: core.h:273
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
template<typename T>
void internal::basic_buffer< T >::reserve ( std::size_t  new_capacity)
inline

Reserves space to store at least capacity elements.

Definition at line 273 of file core.h.

273  {
274  if (new_capacity > capacity_)
275  grow(new_capacity);
276  }
std::size_t capacity_
Definition: core.h:222
virtual void grow(std::size_t capacity)=0
template<typename T>
void internal::basic_buffer< T >::resize ( std::size_t  new_size)
inline

Resizes the buffer. If T is a POD type new elements may not be initialized.

Definition at line 264 of file core.h.

264  {
265  reserve(new_size);
266  size_ = new_size;
267  }
std::size_t size_
Definition: core.h:221
void reserve(std::size_t new_capacity)
Definition: core.h:273
template<typename T>
void internal::basic_buffer< T >::set ( T *  buf_data,
std::size_t  buf_capacity 
)
inlineprotected

Sets the buffer data and capacity.

Definition at line 232 of file core.h.

232  {
233  ptr_ = buf_data;
234  capacity_ = buf_capacity;
235  }
std::size_t capacity_
Definition: core.h:222
template<typename T>
std::size_t internal::basic_buffer< T >::size ( void  ) const
inline

Returns the size of this buffer.

Definition at line 250 of file core.h.

250 { return size_; }
std::size_t size_
Definition: core.h:221

Member Data Documentation

template<typename T>
std::size_t internal::basic_buffer< T >::capacity_
private

Definition at line 222 of file core.h.

template<typename T>
T* internal::basic_buffer< T >::ptr_
private

Definition at line 220 of file core.h.

template<typename T>
std::size_t internal::basic_buffer< T >::size_
private

Definition at line 221 of file core.h.


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