PoDoFo  1.0.0-dev
Public Member Functions | Static Public Attributes | Friends | List of all members
PoDoFo::PdfVariant Class Referencefinal

A variant data type which supports all data types supported by the PDF standard. More...

#include <PdfVariant.h>

Public Member Functions

 PdfVariant ()
 Construct an empty variant type IsNull() will return true.
 
 PdfVariant (bool value)
 Construct a PdfVariant that is a bool. More...
 
 PdfVariant (int64_t value)
 Construct a PdfVariant that is a number. More...
 
 PdfVariant (double value)
 Construct a PdfVariant that is a real number. More...
 
 PdfVariant (const PdfString &str)
 Construct a PdfVariant that is a string. More...
 
 PdfVariant (const PdfName &name)
 Construct a PdfVariant that is a name. More...
 
 PdfVariant (const PdfReference &ref)
 Construct a PdfVariant that is a name. More...
 
 PdfVariant (const PdfArray &arr)
 Construct a PdfVariant object with array data. More...
 
 PdfVariant (PdfArray &&arr) noexcept
 
 PdfVariant (const PdfDictionary &dict)
 Construct a PdfVariant that is a dictionary. More...
 
 PdfVariant (PdfDictionary &&dict) noexcept
 
 PdfVariant (const PdfData &data)
 Construct a PdfVariant that contains raw PDF data. More...
 
 PdfVariant (PdfData &&data) noexcept
 
 PdfVariant (const PdfVariant &rhs)
 Constructs a new PdfVariant which has the same contents as rhs. More...
 
 PdfVariant (PdfVariant &&rhs) noexcept
 
std::string_view 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 (PdfWriteFlags writeFlags=PdfWriteFlags::None) const
 Converts the current object into a string representation which can be written directly to a PDF file on disc. More...
 
void ToString (std::string &str, PdfWriteFlags writeFlags=PdfWriteFlags::None) const
 
bool GetBool () const
 Get the value if this object is a bool. More...
 
bool TryGetBool (bool &value) const
 
int64_t GetNumberLenient () const
 Get the value of the object as int64_t. More...
 
bool TryGetNumberLenient (int64_t &value) const
 
int64_t GetNumber () const
 Get the value of the object as int64_t. More...
 
bool TryGetNumber (int64_t &value) const
 
double GetReal () const
 Get the value of the object as a floating point. More...
 
bool TryGetReal (double &value) const
 
double GetRealStrict () const
 Get the value of the object as floating point number. More...
 
bool TryGetRealStrict (double &value) const
 
const PdfStringGetString () const
 
bool TryGetString (PdfString &str) const
 
bool TryGetString (const PdfString *&str) const
 
const PdfNameGetName () const
 
bool TryGetName (PdfName &name) const
 
bool TryGetName (const PdfName *&name) const
 
PdfReference GetReference () const
 Get the reference values of this object. More...
 
bool TryGetReference (PdfReference &ref) const
 
const PdfArrayGetArray () const
 Returns the value of the object as array. More...
 
PdfArrayGetArray ()
 
bool TryGetArray (const PdfArray *&arr) const
 
bool TryGetArray (PdfArray *&arr)
 
const PdfDictionaryGetDictionary () const
 Returns the dictionary value of this object. More...
 
PdfDictionaryGetDictionary ()
 
bool TryGetDictionary (const PdfDictionary *&dict) const
 
bool TryGetDictionary (PdfDictionary *&dict)
 
void SetBool (bool value)
 Set the value of this object as bool. More...
 
void SetNumber (int64_t value)
 Set the value of this object as int64_t. More...
 
void SetReal (double value)
 Set the value of this object as double. More...
 
void SetName (const PdfName &name)
 Set the name value of this object. More...
 
void SetString (const PdfString &str)
 Set the string value of this object. More...
 
void SetReference (const PdfReference &ref)
 
void Write (OutputStream &stream, PdfWriteFlags writeMode, const PdfStatefulEncrypt *encrypt, charbuff &buffer) const
 Write the complete variant to an output device. More...
 
PdfVariantoperator= (const PdfVariant &rhs)
 Assign the values of another PdfVariant to this one. More...
 
PdfVariantoperator= (PdfVariant &&rhs) noexcept
 
bool 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.
 
bool operator!= (const PdfVariant &rhs) const
 
PdfDataType GetDataType () const
 

Static Public Attributes

static const PdfVariant Null
 

Friends

class PdfObject
 
class PdfArray
 
class PdfDictionary
 
class PdfTokenizer
 

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/10]

PdfVariant::PdfVariant ( bool  value)

Construct a PdfVariant that is a bool.

Parameters
valuethe boolean value of this PdfVariant

◆ PdfVariant() [2/10]

PdfVariant::PdfVariant ( int64_t  value)

Construct a PdfVariant that is a number.

Parameters
valuethe value of the number.

◆ PdfVariant() [3/10]

PdfVariant::PdfVariant ( double  value)

Construct a PdfVariant that is a real number.

Parameters
valuethe value of the real number.

◆ PdfVariant() [4/10]

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() [5/10]

PdfVariant::PdfVariant ( const PdfName name)

Construct a PdfVariant that is a name.

Parameters
namethe value of the name

◆ PdfVariant() [6/10]

PdfVariant::PdfVariant ( const PdfReference ref)

Construct a PdfVariant that is a name.

Parameters
refthe value of the name

◆ PdfVariant() [7/10]

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() [8/10]

PdfVariant::PdfVariant ( const PdfDictionary dict)

Construct a PdfVariant that is a dictionary.

Parameters
dictthe value of the dictionary.

◆ PdfVariant() [9/10]

PdfVariant::PdfVariant ( const PdfData data)

Construct a PdfVariant that contains raw PDF data.

Parameters
dataraw and valid PDF data.

◆ PdfVariant() [10/10]

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()

string_view 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 number 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 number 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

◆ 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 ( PdfWriteFlags  writeFlags = PdfWriteFlags::None) 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

The documentation for this class was generated from the following files: