PoDoFo 0.9.20
PoDoFo::PdfString Class Referencefinal

#include <PdfString.h>

Inheritance diagram for PoDoFo::PdfString:
PoDoFo::PdfDataProvider

Public Member Functions

 PdfString ()
 
 PdfString (const std::string_view &view)
 
 PdfString (const PdfString &rhs)
 
bool IsHex () const
 
PdfStringState GetState () const
 
const std::string & GetString () const
 
void Write (OutputStream &stream, PdfWriteFlags writeMode, const PdfStatefulEncrypt &encrypt, charbuff &buffer) const override
 
const PdfStringoperator= (const PdfString &rhs)
 
bool operator== (const PdfString &rhs) const
 
bool operator!= (const PdfString &rhs) const
 
 operator std::string_view () const
 
- Public Member Functions inherited from PoDoFo::PdfDataProvider
std::string ToString () const
 

Static Public Member Functions

static PdfString FromRaw (const bufferview &view, bool hex=true)
 
static PdfString FromHexData (const std::string_view &hexView, const PdfStatefulEncrypt &encrypt={ })
 

Additional Inherited Members

- Protected Member Functions inherited from PoDoFo::PdfDataProvider
 PdfDataProvider ()
 

Detailed Description

A string that can be written to a PDF document. If it contains binary data it is automatically converted into a hex string, otherwise a normal PDF string is written to the document.

PdfString is an implicitly shared class. As a reason it is very fast to copy PdfString objects.

Constructor & Destructor Documentation

◆ PdfString() [1/3]

PdfString::PdfString ( )

Create an empty string

◆ PdfString() [2/3]

PoDoFo::PdfString::PdfString ( const std::string_view & view)

Construct a new PdfString from a utf-8 string The input string will be copied.

Parameters
viewthe string to copy

◆ PdfString() [3/3]

PdfString::PdfString ( const PdfString & rhs)

Copy an existing PdfString

Parameters
rhsanother PdfString to copy

Member Function Documentation

◆ FromHexData()

PdfString PdfString::FromHexData ( const std::string_view & hexView,
const PdfStatefulEncrypt & encrypt = { } )
static

Set hex-encoded data as the strings data.

Parameters
hexViewmust be hex-encoded data.
lenlength of the hex-encoded data.
encryptif !nullptr, assume the hex data is encrypted and should be decrypted after hex-decoding.

◆ FromRaw()

PdfString PdfString::FromRaw ( const bufferview & view,
bool hex = true )
static

Construct a new PdfString from an utf-8 encoded string.

Parameters
viewa buffer
hextrue if the string should be written as hex string

◆ GetState()

PdfStringState PdfString::GetState ( ) const

A PdfString can be an unevaluated raw buffer, or can be a Ascii, PdfDocEncoding or Unicode string

◆ GetString()

const string & PdfString::GetString ( ) const

The contents of the string as UTF-8 string.

The string's contents are always returned as UTF-8 by this function. Works for Unicode strings and for non-Unicode strings.

This is the preferred way to access the string's contents.

Returns
the string's contents always as UTF-8

◆ IsHex()

bool PoDoFo::PdfString::IsHex ( ) const
inline

Check if this is a hex string.

If true the data will be hex-encoded when the string is written to a PDF file.

Returns
true if this is a hex string.
See also
GetString() will return the raw string contents (not hex-encoded)

◆ operator std::string_view()

PoDoFo::PdfString::operator std::string_view ( ) const

Default cast to utf8 string view

◆ operator!=()

bool PdfString::operator!= ( const PdfString & rhs) const

Comparison operator

Parameters
rhscompare to this string object
Returns
true if strings have different contents

◆ operator=()

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

Copy an existing PdfString

Parameters
rhsanother PdfString to copy
Returns
this object

◆ operator==()

bool PdfString::operator== ( const PdfString & rhs) const

Comparison operator

UTF-8 and strings of the same data compare equal. Whether the string will be written out as hex is not considered - only the real "text" is tested for equality.

Parameters
rhscompare to this string object
Returns
true if both strings have the same contents

◆ Write()

void PdfString::Write ( OutputStream & stream,
PdfWriteFlags writeMode,
const PdfStatefulEncrypt & encrypt,
charbuff & buffer ) 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 PoDoFo::PdfDataProvider.