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

pdf::core::CArray Class Reference

the PDF array object More...

#include <Array.hh>

Inheritance diagram for pdf::core::CArray:

Inheritance graph
[legend]
Collaboration diagram for pdf::core::CArray:

Collaboration graph
[legend]
List of all members.

Public Types

Public Methods

Private Types

Private Attributes


Detailed Description

the PDF array object

the PDF array object contains a list of PDF objects. according to the PDF specs, each object in the same array can be of different type. as a result, the only avaliable implementation in code is to store a list of CObject pointers, which points to different derived classes of CObjects.

the array object owns all the contained CObject pointers. it will destroy them in its destructor.


Member Typedef Documentation

typedef boost::shared_ptr<CObject> pdf::core::CArray::CObjPtr [private]
 

short cut


Constructor & Destructor Documentation

pdf::core::CArray::CArray  
 

default constructor create an empty array

00039 {
00040 }

pdf::core::CArray::CArray const CArray &    array
 

the copy constructor will deep copy all object in the array.

See also:
Dup()

00054 {
00055     for ( iterator i = array.begin( ) ; i != array.end( ) ; ++i )
00056         push_back( i->Dup( ) ) ;
00057 }

pdf::core::CArray::CArray CObject   object
 

create an array with only one element

00045     : m_objects( 1, boost::shared_ptr<CObject>( object ) )
00046 {
00047 }

pdf::core::CArray::~CArray  
 

destructor do nothing. vector and shared_ptr's destructor will do the job nicely.

00063 {
00064 }

template<typename InputIt>
pdf::core::CArray::CArray InputIt    first,
InputIt    last
[inline]
 

this function will take a range of int/long/double/string and make an array of PDF objects out of them. the mapping from int/long/double to CNumber and string to CName is stored in the CType2PDF template.

Parameters:
first  the start of the range. InputIt::value_type should be one of int, long, double or string
last  the pass-the-end iterator of the range

00098     {
00099         typedef typename std::iterator_traits<InputIt>::value_type CRealType ;
00100         typedef typename CType2PDF<CRealType>::result CPDFType ;
00101 
00102         while ( first != last )
00103         {
00104             m_objects.push_back( CObjPtr( new CPDFType( *first ) ) ) ;
00105             ++first ;
00106         }
00107     }


Member Function Documentation

void pdf::core::CArray::push_back CObject   object
 

this function will add an object to the end of the array. note that the pointer is owned by the array.

Parameters:
object  the pointer to the object to be added. this object will be deleted by the array when the array is destroyed.

00073 {
00074     m_objects.push_back( boost::shared_ptr<CObject>( object ) ) ;
00075 }

CArray::iterator pdf::core::CArray::begin   const
 

return an iterator to point to the first CObject in the array. the iterator returns a constant reference to the contained CObject.

See also:
end()

00083 {
00084     return iterator( m_objects.begin( ) ) ;
00085 }

CArray::iterator pdf::core::CArray::end   const
 

return an iterator to point to the pass-the-end CObject in the array. the iterator returns a constant reference to the contained CObject.

See also:
begin()

00093 {
00094     return iterator( m_objects.end( ) ) ;
00095 }

CArray::size_type pdf::core::CArray::size   const
 

return the number of CObject objects in the array.

See also:
empty()

00102 {
00103     return m_objects.size( ) ;
00104 }

bool pdf::core::CArray::empty   const
 

return true if there is no objects in the array, otherwise false.

See also:
size()

00111 {
00112     return m_objects.empty( ) ;
00113 }

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

write the array to the output stream, which should be a PDF file. it will put a pair of square backets around the contained objects.

Implements pdf::core::CObject.

00119 {
00120     using namespace std ;
00121 
00122     os << '[' ;
00123     copy( begin( ), end( ), ostream_iterator<CObject>( os, " " ) ) ;
00124     return os << ']' ;
00125 }

CObject * pdf::core::CArray::Dup   const [virtual]
 

dynamic clone. call the real copy constructor. note that the copy constructor will deep copy the contained objects.

Implements pdf::core::CObject.

00131 {
00132     return new CArray( *this ) ;
00133 }


Member Data Documentation

CObjVec pdf::core::CArray::m_objects [private]
 

the list of CObject pointers


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