My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
GrowBuf Class Reference

#include <growbuf.h>

Public Member Functions

 GrowBuf ()
 
 ~GrowBuf ()
 
void clear ()
 
void addChar (char c)
 
void addStr (const char *s)
 
void addStr (const char *s, int n)
 
const char * get ()
 
int getPos () const
 
char at (int i) const
 

Private Attributes

char * str
 
int pos
 
int len
 

Detailed Description

Class representing a string buffer optimised for growing.

Definition at line 10 of file growbuf.h.

Constructor & Destructor Documentation

GrowBuf::GrowBuf ( )
inline

Definition at line 13 of file growbuf.h.

: str(0), pos(0), len(0) {}
GrowBuf::~GrowBuf ( )
inline

Definition at line 14 of file growbuf.h.

References len, pos, and str.

{ free(str); str=0; pos=0; len=0; }

Member Function Documentation

void GrowBuf::addChar ( char  c)
inline
void GrowBuf::addStr ( const char *  s)
inline
void GrowBuf::addStr ( const char *  s,
int  n 
)
inline

Definition at line 28 of file growbuf.h.

References GROW_AMOUNT, len, pos, and str.

{
if (s)
{
int l=strlen(s);
if (n<l) l=n;
if (pos+l>=len) { len+=l+GROW_AMOUNT; str = (char*)realloc(str,len); }
strncpy(&str[pos],s,n);
pos+=l;
}
}
char GrowBuf::at ( int  i) const
inline

Definition at line 40 of file growbuf.h.

References str.

{ return str[i]; }
void GrowBuf::clear ( )
inline
const char* GrowBuf::get ( )
inline
int GrowBuf::getPos ( ) const
inline

Definition at line 39 of file growbuf.h.

References pos.

Referenced by SearchIndexExternal::addWord(), and processCopyDoc().

{ return pos; }

Member Data Documentation

int GrowBuf::len
private

Definition at line 44 of file growbuf.h.

Referenced by addChar(), addStr(), and ~GrowBuf().

int GrowBuf::pos
private

Definition at line 43 of file growbuf.h.

Referenced by addChar(), addStr(), clear(), getPos(), and ~GrowBuf().

char* GrowBuf::str
private

Definition at line 42 of file growbuf.h.

Referenced by addChar(), addStr(), at(), get(), and ~GrowBuf().


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