Storage Engine API
mongo::AlignedBuilder Class Reference

a page-aligned BufBuilder. More...

#include <aligned_builder.h>

Detailed Description

a page-aligned BufBuilder.

Classes

struct  AllocationInfo
 

Public Member Functions

 AlignedBuilder (unsigned init_size)
 
 ~AlignedBuilder ()
 
void reset (unsigned sz)
 reset with a hint as to the upcoming needed size specified More...
 
void reset ()
 reset for a re-use. More...
 
const char * buf () const
 note this may be deallocated (realloced) if you keep writing or reset(). More...
 
size_t skip (unsigned n)
 leave room for some stuff later More...
 
char * atOfs (unsigned ofs)
 if buffer grows pointer no longer valid More...
 
char * cur ()
 if buffer grows pointer no longer valid More...
 
void appendChar (char j)
 
void appendNum (char j)
 
void appendNum (short j)
 
void appendNum (int j)
 
void appendNum (unsigned j)
 
void appendNum (bool j)
 
void appendNum (double j)
 
void appendNum (long long j)
 
void appendNum (unsigned long long j)
 
void appendBuf (const void *src, size_t len)
 
template<class T >
void appendStruct (const T &s)
 
void appendStr (StringData str, bool includeEOO=true)
 
unsigned len () const
 

Private Member Functions

char * grow (unsigned by)
 returns the pre-grow write position More...
 
void growReallocate (unsigned oldLenInUse)
 
void kill ()
 
void mallocSelfAligned (unsigned sz)
 
void _malloc (unsigned sz)
 
void _realloc (unsigned newSize, unsigned oldLenInUse)
 
void _free (void *)
 

Private Attributes

struct mongo::AlignedBuilder::AllocationInfo _p
 
unsigned _len
 

Static Private Attributes

static const unsigned Alignment = 8192
 

Constructor & Destructor Documentation

◆ AlignedBuilder()

mongo::AlignedBuilder::AlignedBuilder ( unsigned  init_size)

◆ ~AlignedBuilder()

mongo::AlignedBuilder::~AlignedBuilder ( )
inline

Member Function Documentation

◆ _free()

void mongo::AlignedBuilder::_free ( void p)
private

◆ _malloc()

void mongo::AlignedBuilder::_malloc ( unsigned  sz)
private

◆ _realloc()

void mongo::AlignedBuilder::_realloc ( unsigned  newSize,
unsigned  oldLenInUse 
)
private

◆ appendBuf()

void mongo::AlignedBuilder::appendBuf ( const void src,
size_t  len 
)
inline

◆ appendChar()

void mongo::AlignedBuilder::appendChar ( char  j)
inline

◆ appendNum() [1/8]

void mongo::AlignedBuilder::appendNum ( char  j)
inline

◆ appendNum() [2/8]

void mongo::AlignedBuilder::appendNum ( short  j)
inline

◆ appendNum() [3/8]

void mongo::AlignedBuilder::appendNum ( int  j)
inline

◆ appendNum() [4/8]

void mongo::AlignedBuilder::appendNum ( unsigned  j)
inline

◆ appendNum() [5/8]

void mongo::AlignedBuilder::appendNum ( bool  j)
inline

◆ appendNum() [6/8]

void mongo::AlignedBuilder::appendNum ( double  j)
inline

◆ appendNum() [7/8]

void mongo::AlignedBuilder::appendNum ( long long  j)
inline

◆ appendNum() [8/8]

void mongo::AlignedBuilder::appendNum ( unsigned long long  j)
inline

◆ appendStr()

void mongo::AlignedBuilder::appendStr ( StringData  str,
bool  includeEOO = true 
)
inline

◆ appendStruct()

template<class T >
void mongo::AlignedBuilder::appendStruct ( const T &  s)
inline

◆ atOfs()

char* mongo::AlignedBuilder::atOfs ( unsigned  ofs)
inline

if buffer grows pointer no longer valid

◆ buf()

const char* mongo::AlignedBuilder::buf ( ) const
inline

note this may be deallocated (realloced) if you keep writing or reset().

◆ cur()

char* mongo::AlignedBuilder::cur ( )
inline

if buffer grows pointer no longer valid

◆ grow()

char* mongo::AlignedBuilder::grow ( unsigned  by)
inlineprivate

returns the pre-grow write position

◆ growReallocate()

void NOINLINE_DECL mongo::AlignedBuilder::growReallocate ( unsigned  oldLenInUse)
private

◆ kill()

void mongo::AlignedBuilder::kill ( )
private

◆ len()

unsigned mongo::AlignedBuilder::len ( ) const
inline
Returns
the in-use length

◆ mallocSelfAligned()

void mongo::AlignedBuilder::mallocSelfAligned ( unsigned  sz)
private

◆ reset() [1/2]

void mongo::AlignedBuilder::reset ( unsigned  sz)

reset with a hint as to the upcoming needed size specified

◆ reset() [2/2]

void mongo::AlignedBuilder::reset ( )

reset for a re-use.

shrinks if > 128MB

◆ skip()

size_t mongo::AlignedBuilder::skip ( unsigned  n)
inline

leave room for some stuff later

Returns
offset in the buffer that was our current position

Member Data Documentation

◆ _len

unsigned mongo::AlignedBuilder::_len
private

◆ _p

struct mongo::AlignedBuilder::AllocationInfo mongo::AlignedBuilder::_p
private

◆ Alignment

const unsigned mongo::AlignedBuilder::Alignment = 8192
staticprivate

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