pdftron::Filters::FilterWriter Class Reference

FilterWriter is a utility class providing a convenient way to write data to an output filter (using Filter directly is not very intuitive). More...

#include <FilterWriter.h>

List of all members.

Public Member Functions

 FilterWriter ()
 FilterWriter (Filter &filter)
 ~FilterWriter ()
void WriteUChar (UChar ch)
 Write a single character to the output stream.
void WriteInt (int num)
 Write an integer to the output stream.
void WriteLong (long num)
 Write an long integer to the output stream.
void WriteULong (ULong num)
 Write an unsigned long to the output stream.
void WriteString (const std::string &str)
 Write a string to the output stream.
void WriteString (const char *str)
 Write a null terminated string.
void WriteFilter (FilterReader &reader)
 Write the entire input stream to the output stream (i.e.
void WriteLine (const char *line, char eol=0x0D)
 Write out a null terminated 'line' followed by a end of line character default end of line character is carriage return.
ULong WriteBuffer (const char *buf, ULong buf_size)
 
Returns:
- returns the number of bytes actually written to a stream.

void AttachFilter (Filter &filter)
 Attaches a filter to the this FilterWriter.
Filter GetAttachedFilter ()
 
Returns:
- The attached Filter or a NULL filter if no filter is attached.

void Seek (long offset, Filter::ReferencePos origin)
 Sets the position within the current stream.
ULong Tell ()
 Reports the current read position in the stream relative to the stream origin.
ULong Count ()
 
Returns:
- the number of bytes consumed since opening the filter or since the last Seek operation.

void Flush ()
 Forces any data remaining in the buffer to be written to input or output filter.
void FlushAll ()
 Forces any data remaining in the filter chain to the source or destination.


Detailed Description

FilterWriter is a utility class providing a convenient way to write data to an output filter (using Filter directly is not very intuitive).

For example:

 StdFile outfile("file.dat", StdFile::e_write_mode);
 FilterWriter fwriter(outfile);
 fwriter.WriteBuffer(buf, buf_sz);
 fwriter.Flush();

Constructor & Destructor Documentation

pdftron::Filters::FilterWriter::FilterWriter (  ) 

pdftron::Filters::FilterWriter::FilterWriter ( Filter filter  ) 

pdftron::Filters::FilterWriter::~FilterWriter (  ) 


Member Function Documentation

void pdftron::Filters::FilterWriter::WriteUChar ( UChar  ch  ) 

Write a single character to the output stream.

Parameters:
ch An unsigned character to write to the output stream.

void pdftron::Filters::FilterWriter::WriteInt ( int  num  ) 

Write an integer to the output stream.

Parameters:
num An integer to write to the output stream.

void pdftron::Filters::FilterWriter::WriteLong ( long  num  ) 

Write an long integer to the output stream.

Parameters:
num A long integer to be written to write to the output stream.

void pdftron::Filters::FilterWriter::WriteULong ( ULong  num  ) 

Write an unsigned long to the output stream.

Parameters:
num An unsigned long integer to write to the output stream.

void pdftron::Filters::FilterWriter::WriteString ( const std::string &  str  ) 

Write a string to the output stream.

Parameters:
str A string to write to the output stream.

void pdftron::Filters::FilterWriter::WriteString ( const char *  str  ) 

Write a null terminated string.

Parameters:
str A terminated string string to write to the output stream.

void pdftron::Filters::FilterWriter::WriteFilter ( FilterReader reader  ) 

Write the entire input stream to the output stream (i.e.

to this FilterWriter).

Parameters:
reader A FilterReader attached to an input stream.

void pdftron::Filters::FilterWriter::WriteLine ( const char *  line,
char  eol = 0x0D 
)

Write out a null terminated 'line' followed by a end of line character default end of line character is carriage return.

ULong pdftron::Filters::FilterWriter::WriteBuffer ( const char *  buf,
ULong  buf_size 
)

Returns:
- returns the number of bytes actually written to a stream.

This number may less than buf_size if the stream is corrupted.

void pdftron::Filters::FilterWriter::AttachFilter ( Filter filter  ) 

Attaches a filter to the this FilterWriter.

Filter pdftron::Filters::FilterWriter::GetAttachedFilter (  ) 

Returns:
- The attached Filter or a NULL filter if no filter is attached.

void pdftron::Filters::FilterWriter::Seek ( long  offset,
Filter::ReferencePos  origin 
)

Sets the position within the current stream.

Parameters:
offset - A byte offset relative to origin. If offset is negative, the new position will precede the position specified by origin by the number of bytes specified by offset. If offset is zero, the new position will be the position specified by origin. If offset is positive, the new position will follow the position specified by origin by the number of bytes specified by offset.
origin - A value of type ReferencePos indicating the reference point used to obtain the new position
Note:
- After each Seek() operation the number of consumed bytes (i.e. Count()) is set to 0.
Exceptions:
- throws an exception if the method is not implemented in the associated filter.

ULong pdftron::Filters::FilterWriter::Tell (  ) 

Reports the current read position in the stream relative to the stream origin.

Returns:
- The current position in the stream
Exceptions:
- throws an exception if the method is not implemented in the associated filter.

ULong pdftron::Filters::FilterWriter::Count (  ) 

Returns:
- the number of bytes consumed since opening the filter or since the last Seek operation.

void pdftron::Filters::FilterWriter::Flush (  ) 

Forces any data remaining in the buffer to be written to input or output filter.

void pdftron::Filters::FilterWriter::FlushAll (  ) 

Forces any data remaining in the filter chain to the source or destination.


© 2002-2008 PDFTron Systems Inc.