IN2OSM  1.0.1
GenericMemoryBuffer< Allocator >

Represents an in-memory output byte stream. More...

#include <fwd.h>

Collaboration diagram for GenericMemoryBuffer< Allocator >:
Collaboration graph

Public Types

typedef char Ch
 

Public Member Functions

 GenericMemoryBuffer (Allocator *allocator=0, size_t capacity=kDefaultCapacity)
 
void Put (Ch c)
 
void Flush ()
 
void Clear ()
 
void ShrinkToFit ()
 
ChPush (size_t count)
 
void Pop (size_t count)
 
const ChGetBuffer () const
 
size_t GetSize () const
 

Public Attributes

internal::Stack< Allocator > stack_
 

Static Public Attributes

static const size_t kDefaultCapacity = 256
 

Detailed Description

template<typename Allocator = CrtAllocator>
struct GenericMemoryBuffer< Allocator >

Represents an in-memory output byte stream.

This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream.

It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file.

Differences between MemoryBuffer and StringBuffer:

  1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer.
  2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator.
Template Parameters
Allocatortype for allocating memory buffer.
Note
implements Stream concept

Definition at line 74 of file fwd.h.

Member Typedef Documentation

◆ Ch

typedef char Ch

Definition at line 38 of file memorybuffer.h.

Constructor & Destructor Documentation

◆ GenericMemoryBuffer()

GenericMemoryBuffer ( Allocator *  allocator = 0,
size_t  capacity = kDefaultCapacity 
)
inline

Definition at line 40 of file memorybuffer.h.

40 : stack_(allocator, capacity) {}
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

Member Function Documentation

◆ Clear()

void Clear ( )
inline

Definition at line 45 of file memorybuffer.h.

45 { stack_.Clear(); }
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

◆ Flush()

void Flush ( )
inline

Definition at line 43 of file memorybuffer.h.

43 {}

◆ GetBuffer()

const Ch* GetBuffer ( ) const
inline

Definition at line 50 of file memorybuffer.h.

50  {
51  return stack_.template Bottom<Ch>();
52  }
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

◆ GetSize()

size_t GetSize ( ) const
inline

Definition at line 54 of file memorybuffer.h.

54 { return stack_.GetSize(); }
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

◆ Pop()

void Pop ( size_t  count)
inline

Definition at line 48 of file memorybuffer.h.

48 { stack_.template Pop<Ch>(count); }
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

◆ Push()

Ch* Push ( size_t  count)
inline

Definition at line 47 of file memorybuffer.h.

47 { return stack_.template Push<Ch>(count); }
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

◆ Put()

void Put ( Ch  c)
inline

Definition at line 42 of file memorybuffer.h.

42 { *stack_.template Push<Ch>() = c; }
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

◆ ShrinkToFit()

void ShrinkToFit ( )
inline

Definition at line 46 of file memorybuffer.h.

46 { stack_.ShrinkToFit(); }
internal::Stack< Allocator > stack_
Definition: memorybuffer.h:57

Member Data Documentation

◆ kDefaultCapacity

const size_t kDefaultCapacity = 256
static

Definition at line 56 of file memorybuffer.h.

◆ stack_

internal::Stack<Allocator> stack_
mutable

Definition at line 57 of file memorybuffer.h.


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