PoDoFo 1.2.0
Loading...
Searching...
No Matches
PoDoFo::PdfArray Class Referencefinal

This class represents a PdfArray Use it for all arrays that are written to a PDF file. More...

#include <PdfArray.h>

Inheritance diagram for PoDoFo::PdfArray:
PoDoFo::PdfDataContainer PoDoFo::PdfDataProvider< PdfDataContainer >

Public Types

using size_type = size_t
using value_type = PdfObject
using reference = value_type&
using const_reference = const value_type&
using iterator = PdfObject*
using const_iterator = const PdfObject*
using reverse_iterator = std::reverse_iterator<iterator>
using const_reverse_iterator = std::reverse_iterator<const_iterator>

Public Member Functions

 PdfArray ()
 Create an empty array.
 PdfArray (const PdfArray &rhs)
 Deep copy an existing PdfArray.
 PdfArray (PdfArray &&rhs) noexcept
PdfArray & operator= (const PdfArray &rhs)
 assignment operator
PdfArray & operator= (PdfArray &&rhs) noexcept
unsigned GetSize () const
bool IsEmpty () const
void Clear ()
 Remove all elements from the array.
void Write (OutputStream &stream, PdfWriteFlags writeMode, const PdfStatefulEncrypt *encrypt, charbuff &buffer) const override
 Write the complete datatype to a file.
template<typename T>
const ObjectAdapter< T >::TRet GetAtAs (unsigned idx) const
template<typename T>
ObjectAdapter< T >::TRet GetAtAs (unsigned idx)
template<typename T>
const ObjectAdapter< T >::TRet GetAtAsSafe (unsigned idx, const std::common_type_t< T > &fallback={ }) const
template<typename T>
ObjectAdapter< T >::TRet GetAtAsSafe (unsigned idx, const std::common_type_t< T > &fallback={ })
template<typename T>
bool TryGetAtAs (unsigned idx, T &value) const
template<typename T>
bool TryGetAtAs (unsigned idx, T &value)
const PdfObject * FindAt (unsigned idx) const
 Get the object at the given index out of the array.
PdfObject * FindAt (unsigned idx)
const PdfObject & MustFindAt (unsigned idx) const
PdfObject & MustFindAt (unsigned idx)
template<typename T>
const ObjectAdapter< T >::TRet FindAtAs (unsigned idx) const
template<typename T>
ObjectAdapter< T >::TRet FindAtAs (unsigned idx)
template<typename T>
const ObjectAdapter< T >::TRet FindAtAsSafe (unsigned idx, const std::common_type_t< T > &fallback={ }) const
template<typename T>
ObjectAdapter< T >::TRet FindAtAsSafe (unsigned idx, const std::common_type_t< T > &fallback={ })
template<typename T>
bool TryFindAtAs (unsigned idx, T &value) const
template<typename T>
bool TryFindAtAs (unsigned idx, T &value)
void RemoveAt (unsigned idx)
PdfObject & Add (const PdfObject &obj)
PdfObject & Add (PdfObject &&obj)
void AddIndirect (const PdfObject &obj)
PdfObject & AddIndirectSafe (const PdfObject &obj)
PdfObject & SetAt (unsigned idx, const PdfObject &obj)
PdfObject & SetAt (unsigned idx, PdfObject &&obj)
void SetAtIndirect (unsigned idx, const PdfObject *obj)
PdfObject & SetAtIndirectSafe (unsigned idx, const PdfObject &obj)
PdfArrayIndirectIterable GetIndirectIterator ()
PdfArrayConstIndirectIterable GetIndirectIterator () const
void Resize (unsigned count, const PdfObject &val=PdfObject())
 Resize the internal vector.
void Reserve (unsigned n)
void SwapAt (unsigned atIndex, unsigned toIndex)
 Swap two elements in the array.
void MoveTo (unsigned atIndex, unsigned toIndex)
 Move an element to a new position.
size_t size () const
PdfObject & operator[] (size_type idx)
const PdfObject & operator[] (size_type idx) const
iterator begin ()
 Returns a read/write iterator that points to the first element in the array.
const_iterator begin () const
 Returns a read-only (constant) iterator that points to the first element in the array.
iterator end ()
 Returns a read/write iterator that points one past the last element in the array.
const_iterator end () const
 Returns a read-only (constant) iterator that points one past the last element in the array.
reverse_iterator rbegin ()
 Returns a read/write reverse iterator that points to the last element in the array.
const_reverse_iterator rbegin () const
 Returns a read-only (constant) reverse iterator that points to the last element in the array.
reverse_iterator rend ()
 Returns a read/write reverse iterator that points to one before the first element in the array.
const_reverse_iterator rend () const
 Returns a read-only (constant) reverse iterator that points to one before the first element in the array.
void resize (size_t size)
void reserve (size_t size)
iterator insert (const iterator &pos, const PdfObject &obj)
iterator insert (const iterator &pos, PdfObject &&obj)
template<typename InputIterator>
void insert (const iterator &pos, const InputIterator &first, const InputIterator &last)
void erase (const iterator &pos)
void erase (const iterator &first, const iterator &last)
reference front ()
const_reference front () const
reference back ()
const_reference back () const
bool operator== (const PdfArray &rhs) const
bool operator!= (const PdfArray &rhs) const
Public Member Functions inherited from PoDoFo::PdfDataContainer
const PdfObject * GetOwner () const
PdfObject * GetOwner ()
PdfDocument * GetDocument () const
Public Member Functions inherited from PoDoFo::PdfDataProvider< PdfDataContainer >
std::string ToString (PdfWriteFlags flags=PdfWriteFlags::None) const
 Converts the current object into a string representation which can be written directly to a PDF file on disc.

Static Public Member Functions

template<typename TReal, typename = std::enable_if_t<std::is_floating_point_v<TReal>>>
static PdfArray FromReals (cspan< TReal > reals)
template<typename TInt, typename = std::enable_if_t<std::is_integral_v<TInt>>>
static PdfArray FromNumbers (cspan< TInt > numbers)
static PdfArray FromBools (cspan< bool > bools)

Protected Member Functions

void resetDirty () override
void setChildrenParent () override
Protected Member Functions inherited from PoDoFo::PdfDataContainer
PdfObject * GetIndirectObject (const PdfReference &reference) const
PdfDocument * GetObjectDocument () const
void SetDirty ()
bool IsIndirectReferenceAllowed (const PdfObject &obj)
void AssertMutable () const

Friends

class PdfObject
class PdfTokenizer

Detailed Description

This class represents a PdfArray Use it for all arrays that are written to a PDF file.

A PdfArray can hold any PdfVariant.

See also
PdfVariant

Constructor & Destructor Documentation

◆ PdfArray()

PdfArray::PdfArray ( const PdfArray & rhs)

Deep copy an existing PdfArray.

Parameters
rhsthe array to copy

Member Function Documentation

◆ back() [1/2]

PdfObject & PdfArray::back ( )
Returns
a read/write reference to the data at the last element of the array.

◆ back() [2/2]

const PdfObject & PdfArray::back ( ) const
Returns
a read-only (constant) reference to the data at the last element of the array.

◆ begin() [1/2]

PdfArray::iterator PdfArray::begin ( )

Returns a read/write iterator that points to the first element in the array.

Iteration is done in ordinary element order.

◆ begin() [2/2]

PdfArray::const_iterator PdfArray::begin ( ) const

Returns a read-only (constant) iterator that points to the first element in the array.

Iteration is done in ordinary element order.

◆ end() [1/2]

PdfArray::iterator PdfArray::end ( )

Returns a read/write iterator that points one past the last element in the array.

Iteration is done in ordinary element order.

◆ end() [2/2]

PdfArray::const_iterator PdfArray::end ( ) const

Returns a read-only (constant) iterator that points one past the last element in the array.

Iteration is done in ordinary element order.

◆ FindAt()

const PdfObject * PdfArray::FindAt ( unsigned idx) const

Get the object at the given index out of the array.

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
idx
Returns
pointer to the found value. nullptr if the index was out of the boundaries

◆ front() [1/2]

PdfObject & PdfArray::front ( )
Returns
a read/write reference to the data at the first element of the array.

◆ front() [2/2]

const PdfObject & PdfArray::front ( ) const
Returns
a read-only (constant) reference to the data at the first element of the array.

◆ GetSize()

unsigned PdfArray::GetSize ( ) const
Returns
the size of the array

◆ IsEmpty()

bool PdfArray::IsEmpty ( ) const
Returns
true if is empty

◆ MoveTo()

void PdfArray::MoveTo ( unsigned atIndex,
unsigned toIndex )

Move an element to a new position.

Parameters
atIndexindex of the element to move
toIndexnew index position for the element

◆ operator=()

PdfArray & PdfArray::operator= ( const PdfArray & rhs)

assignment operator

Parameters
rhsthe array to assign

◆ rbegin() [1/2]

PdfArray::reverse_iterator PdfArray::rbegin ( )

Returns a read/write reverse iterator that points to the last element in the array.

Iteration is done in reverse element order.

◆ rbegin() [2/2]

PdfArray::const_reverse_iterator PdfArray::rbegin ( ) const

Returns a read-only (constant) reverse iterator that points to the last element in the array.

Iteration is done in reverse element order.

◆ rend() [1/2]

PdfArray::reverse_iterator PdfArray::rend ( )

Returns a read/write reverse iterator that points to one before the first element in the array.

Iteration is done in reverse element order.

◆ rend() [2/2]

PdfArray::const_reverse_iterator PdfArray::rend ( ) const

Returns a read-only (constant) reverse iterator that points to one before the first element in the array.

Iteration is done in reverse element order.

◆ resetDirty()

void PdfArray::resetDirty ( )
overrideprotectedvirtual

◆ Resize()

void PdfArray::Resize ( unsigned count,
const PdfObject & val = PdfObject() )

Resize the internal vector.

Parameters
countnew size
valreference value

◆ setChildrenParent()

void PdfArray::setChildrenParent ( )
overrideprotectedvirtual

◆ size()

size_t PdfArray::size ( ) const
Returns
the size of the array

◆ SwapAt()

void PdfArray::SwapAt ( unsigned atIndex,
unsigned toIndex )

Swap two elements in the array.

Parameters
atIndexindex of the first element to swap
toIndexindex of the second element to swap

◆ Write()

void PdfArray::Write ( OutputStream & stream,
PdfWriteFlags writeMode,
const PdfStatefulEncrypt * encrypt,
charbuff & buffer ) const
overridevirtual

Write the complete datatype to a file.

Parameters
streamwrite 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 PoDoFo::PdfDataContainer.


The documentation for this class was generated from the following files:
  • src/podofo/main/PdfArray.h
  • src/podofo/main/PdfArray.cpp