pdfmm 0.9.20
Public Member Functions | List of all members
mm::PdfDictionary Class Referencefinal

#include <PdfDictionary.h>

Inheritance diagram for mm::PdfDictionary:
mm::PdfDataContainer mm::PdfDataProvider

Public Member Functions

 PdfDictionary ()
 
 PdfDictionary (const PdfDictionary &rhs)
 
const PdfDictionaryoperator= (const PdfDictionary &rhs)
 
bool operator== (const PdfDictionary &rhs) const
 
bool operator!= (const PdfDictionary &rhs) const
 
void Clear ()
 
PdfObjectAddKey (const PdfName &key, const PdfObject &obj)
 
void AddKeyIndirect (const PdfName &key, const PdfObject *obj)
 
PdfObjectAddKeyIndirectSafe (const PdfName &key, const PdfObject &obj)
 
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 &device, PdfWriteMode writeMode, const PdfEncrypt *encrypt) const override
 
unsigned GetSize () const
 
- Public Member Functions inherited from mm::PdfDataContainer
const PdfObjectGetOwner () const
 
bool IsImmutable () const
 
void SetImmutable (bool immutable)
 
virtual void Write (PdfOutputDevice &device, PdfWriteMode writeMode, const PdfEncrypt *encrypt) const =0
 

Additional Inherited Members

- Protected Member Functions inherited from mm::PdfDataContainer
 PdfDataContainer ()
 
- Protected Member Functions inherited from mm::PdfDataProvider
 PdfDataProvider ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ PdfDictionary() [1/2]

PdfDictionary::PdfDictionary ( )

Create a new, empty dictionary

◆ PdfDictionary() [2/2]

PdfDictionary::PdfDictionary ( const PdfDictionary rhs)

Deep copy a dictionary

Parameters
rhsthe PdfDictionary to copy

Member Function Documentation

◆ AddKey()

PdfObject & PdfDictionary::AddKey ( const PdfName key,
const PdfObject obj 
)

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 given object is copied.

This will set the dirty flag of this object.

See also
IsDirty
Parameters
keythe key is identified by this name in the dictionary
objobject containing the data. The object is copied.

◆ AddKeyIndirect()

void PdfDictionary::AddKeyIndirect ( const PdfName key,
const PdfObject obj 
)

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 object must be indirect and the object reference will be added instead to the dictionary

This will set the dirty flag of this object.

See also
IsDirty
Parameters
keythe key is identified by this name in the dictionary
objobject containing the data
Exceptions
PdfError::InvalidHandleon nullptr obj or if the object can't be added as an indirect reference

◆ AddKeyIndirectSafe()

PdfObject & PdfDictionary::AddKeyIndirectSafe ( const PdfName key,
const PdfObject obj 
)

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. If the object is indirect the object reference will be added instead to the dictionary, otherwise the object is copied

This will set the dirty flag of this object.

See also
IsDirty
Parameters
keythe key is identified by this name in the dictionary
obja variant object containing the data
Exceptions
PdfError::InvalidHandleon nullptr obj

◆ Clear()

void PdfDictionary::Clear ( )

Removes all keys from the dictionary

◆ FindKey()

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

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 key in the dictionary
Returns
pointer to the found value or 0 if the key was not found.

◆ FindKeyParent()

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

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 key in the dictionary
Returns
pointer to the found value or 0 if the key was not found.

◆ GetKey() [1/2]

PdfObject * PdfDictionary::GetKey ( const PdfName key)

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 * PdfDictionary::GetKey ( const PdfName key) const

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.

◆ GetSize()

unsigned PdfDictionary::GetSize ( ) const
Returns
the size of the internal map

◆ HasKey()

bool 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.

◆ MustGetKey()

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

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 PdfErrorCode::NoObject, instead of returning. This is intended to make code more readable by sparing (especially multiple) nullptr checks.

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

◆ operator!=()

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

◆ operator=()

const PdfDictionary & 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 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 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

◆ Write()

void PdfDictionary::Write ( PdfOutputDevice device,
PdfWriteMode  writeMode,
const PdfEncrypt encrypt 
) const
overridevirtual

Write the complete datatype to a file.

Parameters
devicewrite the object to this device
writeModeadditional options for writing this object
encryptan encryption object which is used to encrypt this object or nullptr to not encrypt this object

Implements mm::PdfDataProvider.