Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

pdf::core::CStream Class Reference

a PDF stream object More...

#include <Stream.hh>

Inheritance diagram for pdf::core::CStream:

Inheritance graph
Collaboration diagram for pdf::core::CStream:

Collaboration graph
List of all members.

Public Methods

Protected Types

Protected Methods

Detailed Description

a PDF stream object

this class represents streams in PDF files. streams objects contains a number of bytes. it is transformed by a filter before saving to the file. it is used to store page contents, images and embedded files in PDF files.

this class is a abstract base class. it has no data member. it has pure virtual function. it requires the derived classes to provide the stream data. the derived are free to store data in any form. it only need to override two pure virtual function: GetContent() and MakeDictionary(). by doing this the derived classes can specify the stream data and the fields in the stream dictionary.

Member Function Documentation

std::ostream & pdf::core::CStream::Write std::ostream &    os const [virtual]

write the stream object to the output stream, which should be a PDF file. this function is required by CObject

Implements pdf::core::CObject.

00044 {
00045     using namespace std ;
00047     // create stream dictionary
00048     CDictionary dict ;
00049     MakeDictionary( dict ) ;
00051     // get stream content. see 
00052     CByteVec temp ;
00053     const CByteVec& content = GetContent( temp ) ;
00055     // fields that must be presend in a stream dictionary
00056     dict.AddPair( "Length", new CNumber( content.size( ) ) ) ;
00058     os << dict << "\nstream\n" ;
00059     copy( content.begin( ), content.end( ), ostreambuf_iterator<char>( os ) ) ;
00060     return os << "\nendstream" ;
00061 }

virtual const CByteVec& pdf::core::CStream::GetContent CByteVec &    output const [protected, pure virtual]

the derived classes should override this function in order to provide the stream data. the prototype of this function is strange, but it allows the the derived classes to return a constrant reference of its own vector, such that a data copy can be avoided. in other cases, the derived classes can put the stream data to the output vector and return it.

output  a temperatory buffer that can be used to stored data.
the actual stream data that will be stored in the stream object. for classes that has an internel buffer, it can just return it and ignores the output parameter. otherwise it can put the data in the output buffer and return it.

Implemented in pdf::graph::CImage, and pdf::graph::CJpegImage.

void pdf::core::CStream::MakeDictionary CDictionary   dict const [protected, virtual]

this function will fill in the fields into the stream dictionary. derived classes must override it if it wants to customize the stream dictionary.

dict  the stream dictionary.
the "Length" field of the stream dictionary is always added to the stream after this function is called. there is no need for derived classes to add the length field here.

00072 {
00073 }

The documentation for this class was generated from the following files:
Generated on Sun Feb 2 09:17:18 2003 for libpdf++ by doxygen1.2.16