PoDoFo 0.9.20
Public Member Functions | List of all members
PoDoFo::PdfVariant Class Referencefinal

#include <PdfVariant.h>

Public Member Functions

 PdfVariant ()
 
 PdfVariant (bool value)
 
 PdfVariant (int64_t value)
 
 PdfVariant (double value)
 
 PdfVariant (const PdfString &str)
 
 PdfVariant (const PdfName &name)
 
 PdfVariant (const PdfReference &ref)
 
 PdfVariant (const PdfArray &arr)
 
 PdfVariant (const PdfDictionary &dict)
 
 PdfVariant (const PdfData &data)
 
 PdfVariant (const PdfVariant &rhs)
 
const char * GetDataTypeString () const
 
bool IsBool () const
 
bool IsNumber () const
 
bool IsRealStrict () const
 
bool IsNumberOrReal () const
 
bool IsString () const
 
bool IsName () const
 
bool IsArray () const
 
bool IsDictionary () const
 
bool IsRawData () const
 
bool IsNull () const
 
bool IsReference () const
 
std::string ToString () const
 
bool GetBool () const
 
int64_t GetNumberLenient () const
 
int64_t GetNumber () const
 
double GetReal () const
 
double GetRealStrict () const
 
const PdfStringGetString () const
 
const PdfNameGetName () const
 
PdfReference GetReference () const
 
const PdfArrayGetArray () const
 
const PdfDictionaryGetDictionary () const
 
void SetBool (bool value)
 
void SetNumber (int64_t value)
 
void SetReal (double value)
 
void SetName (const PdfName &name)
 
void SetString (const PdfString &str)
 
void Write (OutputStream &stream, PdfWriteFlags writeMode, const PdfStatefulEncrypt &encrypt, charbuff &buffer) const
 
PdfVariantoperator= (const PdfVariant &rhs)
 
bool operator== (const PdfVariant &rhs) const
 
bool operator!= (const PdfVariant &rhs) const
 

Detailed Description

A variant data type which supports all data types supported by the PDF standard. The data can be parsed directly from a string or set by one of the members. One can also convert the variant back to a string after setting the values.

Warning
All methods not marked otherwise may trigger a deferred load. This means that they are unsafe to call while a deferred load is already in progress (as recursion will occur).

Constructor & Destructor Documentation

◆ PdfVariant() [1/11]

PdfVariant::PdfVariant ( )

Construct an empty variant type IsNull() will return true.

◆ PdfVariant() [2/11]

PdfVariant::PdfVariant ( bool  value)

Construct a PdfVariant that is a bool.

Parameters
valuethe boolean value of this PdfVariant

◆ PdfVariant() [3/11]

PdfVariant::PdfVariant ( int64_t  value)

Construct a PdfVariant that is a number.

Parameters
valuethe value of the number.

◆ PdfVariant() [4/11]

PdfVariant::PdfVariant ( double  value)

Construct a PdfVariant that is a real number.

Parameters
valuethe value of the real number.

◆ PdfVariant() [5/11]

PdfVariant::PdfVariant ( const PdfString str)

Construct a PdfVariant that is a string. The argument string will be escaped where necessary, so it should be passed in unescaped form.

Parameters
strthe value of the string

◆ PdfVariant() [6/11]

PdfVariant::PdfVariant ( const PdfName name)

Construct a PdfVariant that is a name.

Parameters
namethe value of the name

◆ PdfVariant() [7/11]

PdfVariant::PdfVariant ( const PdfReference ref)

Construct a PdfVariant that is a name.

Parameters
refthe value of the name

◆ PdfVariant() [8/11]

PdfVariant::PdfVariant ( const PdfArray arr)

Construct a PdfVariant object with array data. The variant will automatically get the datatype PdfDataType::Array. This constructor is the fastest way to create a new PdfVariant that is an array.

Parameters
arra list of variants

◆ PdfVariant() [9/11]

PdfVariant::PdfVariant ( const PdfDictionary dict)

Construct a PdfVariant that is a dictionary.

Parameters
dictthe value of the dictionary.

◆ PdfVariant() [10/11]

PdfVariant::PdfVariant ( const PdfData data)

Construct a PdfVariant that contains raw PDF data.

Parameters
rDataraw and valid PDF data.

◆ PdfVariant() [11/11]

PdfVariant::PdfVariant ( const PdfVariant rhs)

Constructs a new PdfVariant which has the same contents as rhs.

Parameters
rhsan existing variant which is copied.

Member Function Documentation

◆ GetArray()

const PdfArray & PdfVariant::GetArray ( ) const

Returns the value of the object as array

Returns
a array

◆ GetBool()

bool PdfVariant::GetBool ( ) const

Get the value if this object is a bool.

Returns
the bool value.

◆ GetDataTypeString()

const char * PdfVariant::GetDataTypeString ( ) const
Returns
a human readable string representation of GetDataType() The returned string must not be free'd.

◆ GetDictionary()

const PdfDictionary & PdfVariant::GetDictionary ( ) const

Returns the dictionary value of this object

Returns
a PdfDictionary

◆ GetName()

const PdfName & PdfVariant::GetName ( ) const
Returns
the value of the object as name

◆ GetNumber()

int64_t PdfVariant::GetNumber ( ) const

Get the value of the object as int64_t

This method throws if the numer is a floating point number

Returns
the value of the number

◆ GetNumberLenient()

int64_t PdfVariant::GetNumberLenient ( ) const

Get the value of the object as int64_t.

This method is lenient and narrows floating point numbers

Returns
the value of the number

◆ GetReal()

double PdfVariant::GetReal ( ) const

Get the value of the object as a floating point

This method is lenient and returns also strictly integral numbers

Returns
the value of the number

◆ GetRealStrict()

double PdfVariant::GetRealStrict ( ) const

Get the value of the object as floating point number

This method throws if the numer is integer

Returns
the value of the number

◆ GetReference()

PdfReference PdfVariant::GetReference ( ) const

Get the reference values of this object.

Returns
a PdfReference

◆ GetString()

const PdfString & PdfVariant::GetString ( ) const
Returns
the value of the object as string.

◆ IsArray()

bool PdfVariant::IsArray ( ) const
Returns
true if this variant is an array

◆ IsBool()

bool PdfVariant::IsBool ( ) const
Returns
true if this variant is a bool

◆ IsDictionary()

bool PdfVariant::IsDictionary ( ) const
Returns
true if this variant is a dictionary

◆ IsName()

bool PdfVariant::IsName ( ) const
Returns
true if this variant is a name

◆ IsNull()

bool PdfVariant::IsNull ( ) const
Returns
true if this variant is null

◆ IsNumber()

bool PdfVariant::IsNumber ( ) const
Returns
true if this variant is an integer

◆ IsNumberOrReal()

bool PdfVariant::IsNumberOrReal ( ) const
Returns
true if this variant is an integer or a floating point number

◆ IsRawData()

bool PdfVariant::IsRawData ( ) const
Returns
true if this variant is raw data

◆ IsRealStrict()

bool PdfVariant::IsRealStrict ( ) const
Returns
true if this variant is a real

This method strictly check for a floating point number and return false on integer

◆ IsReference()

bool PdfVariant::IsReference ( ) const
Returns
true if this variant is a reference

◆ IsString()

bool PdfVariant::IsString ( ) const
Returns
true if this variant is a string

◆ operator!=()

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

◆ operator=()

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

Assign the values of another PdfVariant to this one.

Parameters
rhsan existing variant which is copied.

This will set the dirty flag of this object.

See also
IsDirty

◆ operator==()

bool PdfVariant::operator== ( const PdfVariant rhs) const

Test to see if the value contained by this variant is the same as the value of the other variant.

◆ SetBool()

void PdfVariant::SetBool ( bool  value)

Set the value of this object as bool

Parameters
bthe value as bool.

This will set the dirty flag of this object.

See also
IsDirty

◆ SetName()

void PdfVariant::SetName ( const PdfName name)

Set the name value of this object

Parameters
dthe name value

This will set the dirty flag of this object.

See also
IsDirty

◆ SetNumber()

void PdfVariant::SetNumber ( int64_t  value)

Set the value of this object as int64_t

Parameters
lthe value as int64_t.

This will set the dirty flag of this object.

See also
IsDirty

◆ SetReal()

void PdfVariant::SetReal ( double  value)

Set the value of this object as double

Parameters
dthe value as double.

This will set the dirty flag of this object.

See also
IsDirty

◆ SetString()

void PdfVariant::SetString ( const PdfString str)

Set the string value of this object.

Parameters
strthe string value

This will set the dirty flag of this object.

See also
IsDirty

◆ ToString()

string PdfVariant::ToString ( ) const

Converts the current object into a string representation which can be written directly to a PDF file on disc.

Parameters
strthe object string is returned in this object.

◆ Write()

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

Write the complete variant to an output device.

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