#include <Dictionary.hh>
Inheritance diagram for pdf::core::CDictionary:
this class represents a PDF dictionary object. according to the PDF specs, the PDF dictionary is a collection of PDF name and PDF object pairs. the PDF name acts as a key to the corresponding object.
this class store the key pairs in a STL vector, not a map. it is because the key pairs will not be looked up frequently. using a vector can save the overhead of a map.
|
shortcut
|
|
the key pair
|
|
a vector of the key pair
|
|
immutable iterator
|
|
shortcut
|
|
default constructor create empty dictionary
|
|
destructor do nothing. vector and shared_ptr will do the job. |
|
the copy constructor will deep copy all contained objects.
00066 { 00067 using namespace std ; 00068 transform( dict.begin( ), dict.end( ), back_inserter( m_pairs ), 00069 DupKeyPair( ) ) ; 00070 } |
|
constructor will take a range of key pairs. assumes InputIt::value_type is the same as our own value_type.
00081 : m_pairs( first, last ) 00082 { 00083 } |
|
constructor to create a single key pair in the dictionary. it is like calling the default constructor and then call AddPair()
|
|
adds a new pair to the dictionary.
|
|
shortcut
00091 { AddPair( CName( name ), new CName( val_name ) ) ; } |
|
another shortcut
00095 { AddPair( CName( name ), object ) ; } |
|
read only access to the key pairs
00098 { return m_pairs.begin( ) ; } |
|
read only access to the key pairs
00101 { return m_pairs.end( ) ; } |
|
write the dictionary to the output stream, which should be a PDF file. Implements pdf::core::CObject.
|
|
dynamic clone. like CArray::Dup(),it will deep copy the contained objects. Implements pdf::core::CObject.
00105 { 00106 return new CDictionary( m_pairs.begin( ), m_pairs.end( ) ) ; 00107 } |
|
allows mutable access to the individual CObject inside the dictionary. this function uses a linear search to access the key.
00115 { 00116 using namespace std ; 00117 using namespace __gnu_cxx ; 00118 using namespace boost ; 00119 00120 CPairVec::iterator i 00121 = std::find_if( m_pairs.begin( ), m_pairs.end( ), 00122 bind( equal_to<CName>( ), 00123 bind( select1st<CKeyPair>( ), _1 ), 00124 CName( name ) ) ); 00125 00126 if ( i == m_pairs.end( ) ) 00127 throw std::out_of_range( "cannot find key" ) ; 00128 00129 return i->second ; 00130 } |
|
removes all key pairs. becomes an empty dictionary
00110 { m_pairs.clear( ) ; } |
|
the vector of key pairs
|