BufWriter

The class BufWriter provides an interface for buffered writing to a file.
Whenever a write method fills the buffer, it is written to the file.

Typedefs

typedef unsigned int uint;
Code:

Public Methods

createInstance(string, int)

static BufWriter *createInstance(const std::string sOut, int iBufSize=DEF_BUF_SIZE);

Creates a new instance for writing to file sOut

Returns a BufWriter object.

destructor

~BufWriter();

The destructor.

addChars

int addChars(const char *pData, int iNum);

Writes iNum characters from pData to the buffer.

pData

String to read from

iNum

Number of characters to read

Returns 0 on success, -1 on failure

addChar

int addChar(char c);

Writes a single character to the buffer.

c

Character to write

Returns 0 on success, -1 on failure

addLine

int addLine(const char *pLine);

Writes a string to the buffer.

pLine

String to write.

Returns 0 on success, -1 on failure

getPos

long getPos();

Get position in file.

Returns position in file.

Protected Methods

constructor

BufWriter();

Initializes members.

initialize

int initialize((const std::string sOut, uint iBufSize);
sOut

Name of file to write to.

iBufSize

Buffer size.

Opens the file, allocate Buffer and resets members.

dump

int dump();

Writes the entire buffer to the file.