PoDoFo  0.9.6
Public Member Functions | List of all members
PoDoFo::PdfDictionary Class Reference

#include <PdfDictionary.h>

Inheritance diagram for PoDoFo::PdfDictionary:
PoDoFo::PdfOwnedDataType PoDoFo::PdfDataType

Public Member Functions

 PdfDictionary ()
 
 PdfDictionary (const PdfDictionary &rhs)
 
virtual ~PdfDictionary ()
 
const PdfDictionaryoperator= (const PdfDictionary &rhs)
 
bool operator== (const PdfDictionary &rhs) const
 
bool operator!= (const PdfDictionary &rhs) const
 
void Clear ()
 
void AddKey (const PdfName &identifier, const PdfObject &rObject)
 
void AddKey (const PdfName &identifier, const PdfObject *pObject)
 
const PdfObjectGetKey (const PdfName &key) const
 
PdfObjectGetKey (const PdfName &key)
 
const PdfObjectFindKey (const PdfName &key) const
 
const PdfObjectFindKeyParent (const PdfName &key) const
 
const PdfObjectMustGetKey (const PdfName &key) const
 
bool HasKey (const PdfName &key) const
 
bool RemoveKey (const PdfName &identifier)
 
void Write (PdfOutputDevice *pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt *pEncrypt=NULL) const
 
void Write (PdfOutputDevice *pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt *pEncrypt, const PdfName &keyStop=PdfName::KeyNull) const
 
size_t GetSize () const
 
const TKeyMap & GetKeys () const
 
TKeyMap & GetKeys ()
 
virtual bool IsDirty () const
 
virtual void SetDirty (bool bDirty)
 
- Public Member Functions inherited from PoDoFo::PdfOwnedDataType
const PdfObjectGetOwner () const
 
- Public Member Functions inherited from PoDoFo::PdfDataType
void SetImmutable (bool bImmutable)
 
bool GetImmutable () const
 

Additional Inherited Members

- Protected Member Functions inherited from PoDoFo::PdfOwnedDataType
 PdfOwnedDataType ()
 
- Protected Member Functions inherited from PoDoFo::PdfDataType
 PdfDataType ()
 
void AssertMutable () const
 

Detailed Description

The PDF dictionary data type of PoDoFo (inherits from PdfDataType, the base class for such representations)

Constructor & Destructor Documentation

◆ PdfDictionary() [1/2]

PoDoFo::PdfDictionary::PdfDictionary ( )

Create a new, empty dictionary

◆ PdfDictionary() [2/2]

PoDoFo::PdfDictionary::PdfDictionary ( const PdfDictionary rhs)

Deep copy a dictionary

Parameters
rhsthe PdfDictionary to copy

◆ ~PdfDictionary()

PoDoFo::PdfDictionary::~PdfDictionary ( )
virtual

Destructor

Member Function Documentation

◆ AddKey() [1/2]

void PoDoFo::PdfDictionary::AddKey ( const PdfName identifier,
const PdfObject rObject 
)

Add a key to the dictionary. If an existing key of this name exists, its value is replaced and the old value object will be deleted. The passed object is copied.

Parameters
identifierthe key is identified by this name in the dictionary
rObjecta variant object containing the data. The object is copied.

This will set the dirty flag of this object.

See also
IsDirty

◆ AddKey() [2/2]

void PoDoFo::PdfDictionary::AddKey ( const PdfName identifier,
const PdfObject pObject 
)

Add a key to the dictionary. If an existing key of this name exists, its value is replaced and the old value object will be deleted. The passed object is copied.

This is an overloaded member function.

Parameters
identifierthe key is identified by this name in the dictionary
pObjectpointer to a variant object containing the data. The object is copied.

This will set the dirty flag of this object.

See also
IsDirty

◆ Clear()

void PoDoFo::PdfDictionary::Clear ( )

Removes all keys from the dictionary

◆ FindKey()

const PdfObject * PoDoFo::PdfDictionary::FindKey ( const PdfName key) const
inline

Get the keys value out of the dictionary

Lookup in the indirect objects as well, if the shallow object was a reference. The returned value is a pointer to the internal object in the dictionary so it MUST not be deleted.

Parameters
keylook for the key names pszKey in the dictionary
Returns
pointer to the found value or 0 if the key was not found.

◆ FindKeyParent()

const PdfObject * PoDoFo::PdfDictionary::FindKeyParent ( const PdfName key) const
inline

Get the keys value out of the dictionary

Lookup in the indirect objects as well, if the shallow object was a reference. Also lookup the parent objects, if /Parent key is found in the dictionary. The returned value is a pointer to the internal object in the dictionary so it MUST not be deleted.

Parameters
keylook for the key names pszKey in the dictionary
Returns
pointer to the found value or 0 if the key was not found.

◆ GetKey() [1/2]

PdfObject * PoDoFo::PdfDictionary::GetKey ( const PdfName key)
inline

Get the key's value out of the dictionary. This is an overloaded member function.

The returned value is a pointer to the internal object in the dictionary. It may be modified but is still owned by the dictionary so it MUST not be deleted.

Parameters
keylook for the key named key in the dictionary
Returns
the found value, or 0 if the key was not found.

◆ GetKey() [2/2]

const PdfObject * PoDoFo::PdfDictionary::GetKey ( const PdfName key) const
inline

Get the key's value out of the dictionary.

The returned value is a pointer to the internal object in the dictionary so it MUST not be deleted.

Parameters
keylook for the key named key in the dictionary
Returns
pointer to the found value, or 0 if the key was not found.

◆ GetKeys() [1/2]

TKeyMap & PoDoFo::PdfDictionary::GetKeys ( )
inline

Get access to the internal map of keys.

Returns
all keys of this dictionary

◆ GetKeys() [2/2]

const TKeyMap & PoDoFo::PdfDictionary::GetKeys ( ) const
inline

Get access to the internal map of keys.

Returns
all keys of this dictionary

◆ GetSize()

size_t PoDoFo::PdfDictionary::GetSize ( ) const
inline
Returns
the size of the internal map

◆ HasKey()

bool PoDoFo::PdfDictionary::HasKey ( const PdfName key) const

Allows to check if a dictionary contains a certain key.

Parameters
keylook for the key named key.Name() in the dictionary
Returns
true if the key is part of the dictionary, otherwise false.

◆ IsDirty()

bool PoDoFo::PdfDictionary::IsDirty ( ) const
virtual

The dirty flag is set if this variant has been modified after construction.

Usually the dirty flag is also set if you call any non-const member function as we cannot determine if you actually changed something or not.

Returns
true if the value is dirty and has been modified since construction

Reimplemented from PoDoFo::PdfDataType.

◆ MustGetKey()

const PdfObject & PoDoFo::PdfDictionary::MustGetKey ( const PdfName key) const
inline

Get the key's value out of the dictionary.

The returned value is a reference to the internal object in the dictionary so it MUST not be deleted. If the key is not found, this throws a PdfError exception with error code ePdfError_NoObject, instead of returning. This is intended to make code more readable by sparing (especially multiple) NULL checks.

Parameters
keylook for the key named key in the dictionary
Returns
reference to the found value (never 0).
Exceptions
PdfError(ePdfError_NoObject).

◆ operator!=()

bool PoDoFo::PdfDictionary::operator!= ( const PdfDictionary rhs) const
inline
See also
operator==

◆ operator=()

const PdfDictionary & PoDoFo::PdfDictionary::operator= ( const PdfDictionary rhs)

Assignment operator. Assign another PdfDictionary to this dictionary. This is a deep copy; all elements of the source dictionary are duplicated.

Parameters
rhsthe PdfDictionary to copy.
Returns
this PdfDictionary

This will set the dirty flag of this object.

See also
IsDirty

◆ operator==()

bool PoDoFo::PdfDictionary::operator== ( const PdfDictionary rhs) const

Comparison operator. If this dictionary contains all the same keys as the other dictionary, and for each key the values compare equal, the dictionaries are considered equal.

◆ RemoveKey()

bool PoDoFo::PdfDictionary::RemoveKey ( const PdfName identifier)

Remove a key from this dictionary. If the key does not exist, this function does nothing.

Parameters
identifierthe name of the key to delete
Returns
true if the key was found in the object and was removed. If there was no key with this name, false is returned.

This will set the dirty flag of this object.

See also
IsDirty

◆ SetDirty()

void PoDoFo::PdfDictionary::SetDirty ( bool  bDirty)
virtual

Sets the dirty flag of this PdfVariant

Parameters
bDirtytrue if this PdfVariant has been modified from the outside
See also
IsDirty

Reimplemented from PoDoFo::PdfDataType.

◆ Write() [1/2]

void PoDoFo::PdfDictionary::Write ( PdfOutputDevice pDevice,
EPdfWriteMode  eWriteMode,
const PdfEncrypt pEncrypt,
const PdfName keyStop = PdfName::KeyNull 
) const

Write the complete dictionary to a file.

Parameters
pDevicewrite the object to this device
eWriteModeadditional options for writing this object
pEncryptan encryption object which is used to encrypt this object or NULL to not encrypt this object
keyStopif not KeyNull and a key == keyStop is found writing will stop right before this key!

◆ Write() [2/2]

void PoDoFo::PdfDictionary::Write ( PdfOutputDevice pDevice,
EPdfWriteMode  eWriteMode,
const PdfEncrypt pEncrypt = NULL 
) const
inlinevirtual

Write the complete dictionary to a file.

Parameters
pDevicewrite the object to this device
eWriteModeadditional options for writing this object
pEncryptan encryption object which is used to encrypt this object or NULL to not encrypt this object

Implements PoDoFo::PdfDataType.