#include <Filter.h>
Public Types | |
enum | ReferencePos { e_begin = SEEK_SET, e_end = SEEK_END, e_cur = SEEK_CUR } |
Public Member Functions | |
Filter () | |
~Filter () | |
Filter (const Filter ©) | |
Filter & | operator= (const Filter &other) |
operator bool () | |
void | AttachFilter (Filter attach_filter) |
Filter | ReleaseAttachedFilter () |
Filter | GetAttachedFilter () |
Filter | GetSourceFilter () |
const char * | GetName () const |
const char * | GetDecodeName () const |
UChar * | Begin () |
size_t | Size () |
void | Consume (size_t num_bytes) |
size_t | Count () |
size_t | SetCount (size_t new_count) |
void | SetStreamLength (size_t bytes) |
void | Flush () |
void | FlushAll () |
bool | IsInputFilter () |
bool | CanSeek () |
void | Seek (ptrdiff_t offset, ReferencePos origin) |
ptrdiff_t | Tell () |
size_t | Truncate (size_t new_size) |
Filter | CreateInputIterator () |
const UString | GetFilePath () const |
void | Destroy () |
void | WriteToFile (const UString &path, bool append) |
Provides a generic view of a sequence of bytes.
A Filter is the abstract base class of all filters. A filter is an abstraction of a sequence of bytes, such as a file, an input/output device, an inter-process communication pipe, or a TCP/IP socket. The Filter class and its derived classes provide a generic view of these different types of input and output, isolating the programmer from the specific details of the operating system and the underlying devices.
Besides providing access to input/output sources Filters can be also to transform the data (e.g. to compress the data stream, to normalize the image data, to encrypt data, etc). Filters can also be attached to each other to form pipelines. For example, a filter used to open an image data file can be attached to a filter that decompresses the data, which is attached to another filter that will normalize the image data.
Depending on the underlying data source or repository, filters might support only some of these capabilities. An application can query a stream for its capabilities by using the IsInputFilter() and CanSeek() properties.
For example:
pdftron::Filters::Filter::Filter | ( | ) |
pdftron::Filters::Filter::~Filter | ( | ) |
pdftron::Filters::Filter::Filter | ( | const Filter & | copy | ) |
void pdftron::Filters::Filter::AttachFilter | ( | Filter | attach_filter | ) |
Attaches a filter to the this filter. If this filter owns another filter it will be deleted. This filter then becomes the owner of the attached filter.
attach_filter | filter object to attach |
UChar* pdftron::Filters::Filter::Begin | ( | ) |
bool pdftron::Filters::Filter::CanSeek | ( | ) |
void pdftron::Filters::Filter::Consume | ( | size_t | num_bytes | ) |
size_t pdftron::Filters::Filter::Count | ( | ) |
Filter pdftron::Filters::Filter::CreateInputIterator | ( | ) |
Create Filter iterator. Filter iterator similar to a regular filter. However, there can be only one owner of the attached filter.
- | throws an exception if the method is not implemented in the derived class |
void pdftron::Filters::Filter::Destroy | ( | ) |
Frees the native memory of the object.
void pdftron::Filters::Filter::Flush | ( | ) |
Forces any data remaining in the buffer to be written to input or output filter.
void pdftron::Filters::Filter::FlushAll | ( | ) |
Forces any data remaining in the filter chain to the source or destination.
Filter pdftron::Filters::Filter::GetAttachedFilter | ( | ) |
const char* pdftron::Filters::Filter::GetDecodeName | ( | ) | const |
const UString pdftron::Filters::Filter::GetFilePath | ( | ) | const |
const char* pdftron::Filters::Filter::GetName | ( | ) | const |
Filter pdftron::Filters::Filter::GetSourceFilter | ( | ) |
bool pdftron::Filters::Filter::IsInputFilter | ( | ) |
|
inline |
Filter pdftron::Filters::Filter::ReleaseAttachedFilter | ( | ) |
Release the ownership of the attached filter. After the attached filter is released this filter points to NULL filter.
void pdftron::Filters::Filter::Seek | ( | ptrdiff_t | offset, |
ReferencePos | origin | ||
) |
When overridden in a derived class, sets the position within the current stream.
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 |
- | throws FilterExc if the method is not implemented in derived class |
size_t pdftron::Filters::Filter::SetCount | ( | size_t | new_count | ) |
Sets a new counting point for the current filter. All subsequent Consume() operations will increment this counter.
Make sure that the output filter is flushed before using SetCount().
new_count | number to set the counting point of the filter to. |
void pdftron::Filters::Filter::SetStreamLength | ( | size_t | bytes | ) |
The functions specifies the length of the data stream. The default implementation doesn't do anything. For some derived filters such as file segment filter it may be useful to override this function in order to limit the stream length.
bytes | the length of stream in bytes |
size_t pdftron::Filters::Filter::Size | ( | ) |
ptrdiff_t pdftron::Filters::Filter::Tell | ( | ) |
Reports the current read position in the stream relative to the stream origin.
- | throws FilterExc if the method is not implemented in derived class |
size_t pdftron::Filters::Filter::Truncate | ( | size_t | new_size | ) |
Truncates the underlying data.
This method is for a writeable, seekable filter only and will throw otherwise.
new_size | - the number of bytes to resize the filter to |
- | throws FilterExc if the method is not implemented in derived class |
void pdftron::Filters::Filter::WriteToFile | ( | const UString & | path, |
bool | append | ||
) |
Writes the entire filter, starting at current position, to specified filepath. Should only be called on an input filter.
path | the output filepath. |
append | 'true' to append to existing file contents, 'false' to overwrite. |