CACAO
Data Structures | Public Member Functions | Private Member Functions | Private Attributes
Buffer< Allocator > Class Template Reference

Data Structures

struct  Encode
 

Public Member Functions

 Buffer (size_t initial_size=64)
 
 ~Buffer ()
 
Bufferwrite (char)
 
Bufferwrite (Utf8String)
 
Bufferwrite (JavaString)
 
Bufferwrite (const char *)
 
Bufferwrite (const char *, size_t)
 
Bufferwrite (const uint16_t *, size_t)
 
Bufferwrite_slash_to_dot (const char *)
 write to buffer, replacing '/' by '.' More...
 
Bufferwrite_slash_to_dot (Utf8String)
 
Bufferwrite_dot_to_slash (Utf8String)
 write to buffer, replacing '.' by '/' More...
 
template<typename A >
Bufferwrite (Buffer< A > &src)
 copy contents of buffer (calls c_str() on src) More...
 
Bufferwrite_ptr (void *)
 write address of pointer as hex to buffer More...
 
Bufferwrite_dec (s4)
 write number to buffer as decimal More...
 
Bufferwrite_dec (s8)
 
Bufferwrite_dec (float)
 
Bufferwrite_dec (double)
 
Bufferwrite_hex (s4)
 write number to buffer as hexadecimal More...
 
Bufferwrite_hex (s8)
 
Bufferwrite_hex (float)
 
Bufferwrite_hex (double)
 
Bufferwritef (const char *fmt,...)
 
Bufferwritevf (const char *fmt, va_list ap)
 
Bufferzero_terminate ()
 ensure string in buffer is zero terminated More...
 
const char * c_str ()
 get contents of buffer as zero-terminated c-style-string This strings lifetime is tied to it's buffer. More...
 
const char * c_str_copy ()
 get copy contents of buffer as zero-terminated c-style-string You must free the returned string yourself ( use a copy of the buffer's allocator via get_allocator()) More...
 
Utf8String utf8_str ()
 get utf-8 string contents of buffer as utf8-string More...
 
uint8_t * data ()
 get raw contents of buffer (not necessarily zero terminated). More...
 
const uint8_t * data () const
 
size_t size ()
 get size of buffer contents More...
 
void reset ()
 Reset buffer position to start of buffer. More...
 
void skip (size_t num_bytes)
 advance buffer position by n bytes O(1) More...
 
void rewind (size_t bytes_to_drop)
 remove data from the back of this buffer. More...
 
void ensure_capacity (size_t sz)
 ensure buffer contains space for at least sz bytes More...
 

Private Member Functions

 Buffer (const Buffer &)
 non-copyable More...
 
Bufferoperator= (const Buffer &)
 non-assignable More...
 

Private Attributes

uint8_t * _start
 
uint8_t * _end
 
uint8_t * _pos
 
Allocator _alloc
 

Detailed Description

template<typename Allocator = MemoryAllocator<uint8_t>>
class Buffer< Allocator >

Definition at line 54 of file buffer.hpp.

Constructor & Destructor Documentation

template<typename Allocator >
Buffer< Allocator >::Buffer ( size_t  initial_size = 64)

Definition at line 185 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator >::~Buffer ( )

Definition at line 193 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
Buffer< Allocator >::Buffer ( const Buffer< Allocator > &  )
private

non-copyable

Member Function Documentation

template<typename Allocator >
const char * Buffer< Allocator >::c_str ( )
inline

get contents of buffer as zero-terminated c-style-string This strings lifetime is tied to it's buffer.

Definition at line 489 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
const char* Buffer< Allocator >::c_str_copy ( )
inline

get copy contents of buffer as zero-terminated c-style-string You must free the returned string yourself ( use a copy of the buffer's allocator via get_allocator())

template<typename Allocator >
uint8_t * Buffer< Allocator >::data ( )
inline

get raw contents of buffer (not necessarily zero terminated).

Definition at line 523 of file buffer.hpp.

template<typename Allocator >
const uint8_t * Buffer< Allocator >::data ( ) const
inline

Definition at line 529 of file buffer.hpp.

template<typename Allocator >
void Buffer< Allocator >::ensure_capacity ( size_t  sz)

ensure buffer contains space for at least sz bytes

Definition at line 591 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
Buffer& Buffer< Allocator >::operator= ( const Buffer< Allocator > &  )
private

non-assignable

template<typename Allocator >
void Buffer< Allocator >::reset ( )
inline

Reset buffer position to start of buffer.

This effectively clears the buffer. O(1)

Definition at line 553 of file buffer.hpp.

template<typename Allocator >
void Buffer< Allocator >::rewind ( size_t  bytes_to_drop)
inline

remove data from the back of this buffer.

O(1)

Definition at line 574 of file buffer.hpp.

template<typename Allocator >
size_t Buffer< Allocator >::size ( )
inline

get size of buffer contents

Definition at line 541 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
void Buffer< Allocator >::skip ( size_t  num_bytes)
inline

advance buffer position by n bytes O(1)

template<typename Allocator >
Utf8String Buffer< Allocator >::utf8_str ( )
inline

get utf-8 string contents of buffer as utf8-string

Definition at line 506 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write ( char  c)
inline

Definition at line 280 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write ( Utf8String  u)
inline

Definition at line 207 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write ( JavaString  js)
inline

Definition at line 220 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write ( const char *  cs)
inline

Definition at line 233 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write ( const char *  cs,
size_t  sz 
)
inline

Definition at line 246 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write ( const uint16_t *  cs,
size_t  sz 
)
inline

Definition at line 265 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
template<typename A >
Buffer& Buffer< Allocator >::write ( Buffer< A > &  src)
inline

copy contents of buffer (calls c_str() on src)

Definition at line 82 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_dec ( s4  n)
inline

write number to buffer as decimal

Definition at line 366 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_dec ( s8  n)
inline

Definition at line 371 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_dec ( float  n)
inline

Definition at line 376 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_dec ( double  n)
inline

Definition at line 381 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_dot_to_slash ( Utf8String  u)
inline

write to buffer, replacing '.' by '/'

Definition at line 338 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_hex ( s4  n)
inline

write number to buffer as hexadecimal

Definition at line 386 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_hex ( s8  n)
inline

Definition at line 391 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_hex ( float  n)
inline

Definition at line 396 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_hex ( double  n)
inline

Definition at line 408 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_ptr ( void ptr)
inline

write address of pointer as hex to buffer

Definition at line 361 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_slash_to_dot ( const char *  cs)
inline

write to buffer, replacing '/' by '.'

Definition at line 297 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::write_slash_to_dot ( Utf8String  u)
inline

Definition at line 315 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::writef ( const char *  fmt,
  ... 
)
inline

Definition at line 426 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::writevf ( const char *  fmt,
va_list  ap 
)
inline

Definition at line 438 of file buffer.hpp.

template<typename Allocator >
Buffer< Allocator > & Buffer< Allocator >::zero_terminate ( )
inline

ensure string in buffer is zero terminated

Definition at line 470 of file buffer.hpp.

Field Documentation

template<typename Allocator = MemoryAllocator<uint8_t>>
Allocator Buffer< Allocator >::_alloc
private

Definition at line 156 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
uint8_t * Buffer< Allocator >::_end
private

Definition at line 155 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
uint8_t * Buffer< Allocator >::_pos
private

Definition at line 155 of file buffer.hpp.

template<typename Allocator = MemoryAllocator<uint8_t>>
uint8_t* Buffer< Allocator >::_start
private

Definition at line 155 of file buffer.hpp.


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