PoDoFo
1.0.0-dev
|
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 PdfString & | GetString () const |
bool | TryGetString (PdfString &str) const |
bool | TryGetString (const PdfString *&str) const |
const PdfName & | GetName () 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 PdfArray & | GetArray () const |
Returns the value of the object as array. More... | |
PdfArray & | GetArray () |
bool | TryGetArray (const PdfArray *&arr) const |
bool | TryGetArray (PdfArray *&arr) |
const PdfDictionary & | GetDictionary () const |
Returns the dictionary value of this object. More... | |
PdfDictionary & | GetDictionary () |
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... | |
PdfVariant & | operator= (const PdfVariant &rhs) |
Assign the values of another PdfVariant to this one. More... | |
PdfVariant & | operator= (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 |
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.
PdfVariant::PdfVariant | ( | bool | value | ) |
Construct a PdfVariant that is a bool.
value | the boolean value of this PdfVariant |
PdfVariant::PdfVariant | ( | int64_t | value | ) |
Construct a PdfVariant that is a number.
value | the value of the number. |
PdfVariant::PdfVariant | ( | double | value | ) |
Construct a PdfVariant that is a real number.
value | the value of the real number. |
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.
str | the value of the string |
PdfVariant::PdfVariant | ( | const PdfName & | name | ) |
Construct a PdfVariant that is a name.
name | the value of the name |
PdfVariant::PdfVariant | ( | const PdfReference & | ref | ) |
Construct a PdfVariant that is a name.
ref | the value of the name |
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.
arr | a list of variants |
PdfVariant::PdfVariant | ( | const PdfDictionary & | dict | ) |
Construct a PdfVariant that is a dictionary.
dict | the value of the dictionary. |
PdfVariant::PdfVariant | ( | const PdfData & | data | ) |
Construct a PdfVariant that contains raw PDF data.
data | raw and valid PDF data. |
PdfVariant::PdfVariant | ( | const PdfVariant & | rhs | ) |
Constructs a new PdfVariant which has the same contents as rhs.
rhs | an existing variant which is copied. |
const PdfArray & PdfVariant::GetArray | ( | ) | const |
Returns the value of the object as array.
bool PdfVariant::GetBool | ( | ) | const |
Get the value if this object is a bool.
string_view PdfVariant::GetDataTypeString | ( | ) | const |
const PdfDictionary & PdfVariant::GetDictionary | ( | ) | const |
Returns the dictionary value of this object.
const PdfName & PdfVariant::GetName | ( | ) | const |
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
int64_t PdfVariant::GetNumberLenient | ( | ) | const |
Get the value of the object as int64_t.
This method is lenient and narrows floating point numbers
double PdfVariant::GetReal | ( | ) | const |
Get the value of the object as a floating point.
This method is lenient and returns also strictly integral numbers
double PdfVariant::GetRealStrict | ( | ) | const |
Get the value of the object as floating point number.
This method throws if the number is integer
PdfReference PdfVariant::GetReference | ( | ) | const |
Get the reference values of this object.
const PdfString & PdfVariant::GetString | ( | ) | const |
bool PdfVariant::IsArray | ( | ) | const |
bool PdfVariant::IsBool | ( | ) | const |
bool PdfVariant::IsDictionary | ( | ) | const |
bool PdfVariant::IsName | ( | ) | const |
bool PdfVariant::IsNull | ( | ) | const |
bool PdfVariant::IsNumber | ( | ) | const |
bool PdfVariant::IsNumberOrReal | ( | ) | const |
bool PdfVariant::IsRawData | ( | ) | const |
bool PdfVariant::IsRealStrict | ( | ) | const |
This method strictly check for a floating point number and return false on integer
bool PdfVariant::IsReference | ( | ) | const |
bool PdfVariant::IsString | ( | ) | const |
bool PdfVariant::operator!= | ( | const PdfVariant & | rhs | ) | const |
PdfVariant & PdfVariant::operator= | ( | const PdfVariant & | rhs | ) |
Assign the values of another PdfVariant to this one.
rhs | an existing variant which is copied. |
This will set the dirty flag of this object.
void PdfVariant::SetBool | ( | bool | value | ) |
Set the value of this object as bool.
b | the value as bool. |
This will set the dirty flag of this object.
void PdfVariant::SetName | ( | const PdfName & | name | ) |
Set the name value of this object.
d | the name value |
This will set the dirty flag of this object.
void PdfVariant::SetNumber | ( | int64_t | value | ) |
Set the value of this object as int64_t.
l | the value as int64_t. |
This will set the dirty flag of this object.
void PdfVariant::SetReal | ( | double | value | ) |
Set the value of this object as double.
d | the value as double. |
This will set the dirty flag of this object.
void PdfVariant::SetString | ( | const PdfString & | str | ) |
Set the string value of this object.
str | the string value |
This will set the dirty flag of this object.
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.
str | the object string is returned in this object. |
void PdfVariant::Write | ( | OutputStream & | stream, |
PdfWriteFlags | writeMode, | ||
const PdfStatefulEncrypt * | encrypt, | ||
charbuff & | buffer | ||
) | const |
Write the complete variant to an output device.
stream | write the object to this stream |
writeMode | additional options for writing this object |
encrypt | an encryption object which is used to encrypt this object or nullptr to not encrypt this object |