libart-paperback 0.1.0-a.1.20260122225059.e5fea306241a
PDF (1.4) library for C++
Art::Paperback::Carousel::Object Class Reference

Represents a COS-file object. More...

#include <art/paperback/carousel/object.hxx>

Public Member Functions

 Object (Undefined const &)
 Constructor.
 
 Object (Array)
 Constructor.
 
 Object (Boolean)
 Constructor.
 
 Object (Dictionary)
 Constructor.
 
 Object (Integer)
 Constructor.
 
 Object (Name)
 Constructor.
 
 Object (Real)
 Constructor.
 
 Object (Text)
 Constructor.
 
 Object (Object const &)
 Constructor.
 
 Object (Object &&)
 Constructor.
 
void attach (Object_model::Owner &)
 Attach object to owner.
 
bool is_reference () const
 Check if the objcet is a reference.
 
Identity const & identity () const
 Get object identity, if reference.
 
Objectoperator= (Object const &)
 Assignment.
 
Objectoperator= (Object &&)
 Assignment.
 
bool operator== (Object const &) const
 Comparison.
 
bool operator!= (Object const &) const
 Comparison.
 

Private Member Functions

 Object (shared_ptr< Object_model::Abstract >)
 Constructor.
 
Object_model::Container_basecontainer ()
 Get the container of the object.
 
Object_model::Container_base const & container () const
 Get the container of the object.
 

Private Attributes

friend File
 
friend Writer
 
shared_ptr< Object_model::Abstract_data
 Holds the data of the object, either an instance of Object_model::Reference for references, or an instance of Object_model::Container for direct objects.
 

Friends

template<typename>
bool is_of_type (Object const &object)
 Check object type.
 
template<typename T>
T & object_cast (Object &object)
 This function provides access to the value of an object.
 
template<typename T>
T const & object_cast (Object const &object)
 This function provides access to the value of an object.
 
Object clone (Object &object)
 Clone an object.
 
void accept (Object &visitee, Visitor &v)
 Accept visitor on object.
 
void accept (Object const &visitee, Visitor &v)
 Accept visitor on object.
 

Detailed Description

Represents a COS-file object.

The Object class represents a COS-file object.

An object can be either a direct object or an indirect object. The eight supported object types are:

  • Boolean values
  • Integer and real numbers
  • Strings
  • Names
  • Arrays
  • Dictionaries
  • Streams
  • Null (undefined)

See Section 3.2, "Objects" in the PDF-1.4 specification for further information.

Instances of Object maintain a pointer to the underlying data. Copying an object creates a new reference to the same underlying data. This is not to be confused with indirect COS objects. See the example below for clarification. Also note, that an object can only have a maximum of one owner, so adding an object to say two different arrays at the same time will result in an exception being thrown.

Todo
Describe assigning to already created objects.
using namespace Art::Paperback::Carousel;
// Create a direct object of array type.
//
Object object0{Array{}};
// Create a new direct object pointing to the same data as object0.
//
Object object1{object0};
// Changes made in object0 will be reflected in object1, and vice versa.
//
// If an identitcal copy is desired, the clone function can be used:
//
Object object2{clone(object0)};
// Changes made to object2 will not be reflected in object0 nor object1.
//
// Indirect objects work differently. Cloning an indirect object
// will clone the reference to the indirect object, not the data
// of the object.
//
File file;
// Create an indirect object of array type.
//
Object object3{file.create_object<Array>()};
Object object4{object3};
Object object5{clone(object3)};
// At this point, both object4 and object5 point to the indirect
// object first allocated in object3. This includes object5 since
// it's a clone of a reference.
//
Definition array.hxx:14
Represents a COS-format file.
Definition file.hxx:19
Object create_object(Args &&... args)
Create a new object.
Definition file.hxx:49
Represents a COS-file object.
Definition object.hxx:16
Object(Undefined const &)
Constructor.
Definition object.cxx:105
friend Object clone(Object &)
Clone an object.
Definition object.cxx:303
COS file format implementation namespace.
Definition array.cxx:6

Access to the data of an object is provided by the object_cast function, see the example below:

using namespace Art::Paperback::Carousel;
Object my_array{Array{}};
object_cast<Array>(my_array).push_back(Integer{0});
Represents a COS integer.
Definition integer.hxx:16
friend T & object_cast(Object &)
This function provides access to the value of an object.
Definition object.hxx:161

Constructor & Destructor Documentation

◆ Object() [1/11]

Art::Paperback::Carousel::Object::Object ( Undefined const & undefined)

Constructor.

This constructor creates a null (undefined) object.

◆ Object() [2/11]

Art::Paperback::Carousel::Object::Object ( Array array)

Constructor.

This constructor creates an array object.

Parameters
arrayThe array.

◆ Object() [3/11]

Art::Paperback::Carousel::Object::Object ( Boolean boolean)

Constructor.

This constructor creates a boolean object.

Parameters
booleanThe boolean value.

◆ Object() [4/11]

Art::Paperback::Carousel::Object::Object ( Dictionary dictionary)

Constructor.

This constructor creates a dictionary object.

Parameters
dictionaryThe dictionary.

◆ Object() [5/11]

Art::Paperback::Carousel::Object::Object ( Integer integer)

Constructor.

This constructor creates an integer object.

Parameters
integerThe integer value.

◆ Object() [6/11]

Art::Paperback::Carousel::Object::Object ( Name name)

Constructor.

This constructor creates a name object.

Parameters
nameThe name.

◆ Object() [7/11]

Art::Paperback::Carousel::Object::Object ( Real real)

Constructor.

This constructor creates a real object.

Parameters
realThe real value.

◆ Object() [8/11]

Art::Paperback::Carousel::Object::Object ( Text text)

Constructor.

This constructor creates a text (string) object.

Parameters
textThe text (string) value.

◆ Object() [9/11]

Art::Paperback::Carousel::Object::Object ( Object const & other)

Constructor.

Parameters
otherThe object to copy from.

◆ Object() [10/11]

Art::Paperback::Carousel::Object::Object ( Object && other)

Constructor.

This constructor makes a copy of other rather than moving from it.

This avoids the problem of having invalid-state objects.

Parameters
otherThe object to move from.

◆ Object() [11/11]

Art::Paperback::Carousel::Object::Object ( shared_ptr< Object_model::Abstract > data)
explicitprivate

Constructor.

This is an internal constructor to create an indirect object.

Member Function Documentation

◆ attach()

void Art::Paperback::Carousel::Object::attach ( Object_model::Owner & owner)

Attach object to owner.

Parameters
ownerThe owner to tie this object with.

◆ is_reference()

bool Art::Paperback::Carousel::Object::is_reference ( ) const

Check if the objcet is a reference.

Returns
Returns true if this object is an indirect reference.

◆ identity()

Identity const & Art::Paperback::Carousel::Object::identity ( ) const

Get object identity, if reference.

Exceptions
Internal_errorThrown if the object is not an indirect object.
Returns
Returns the identity of the object, if it is an indirect object.

◆ operator=() [1/2]

Object & Art::Paperback::Carousel::Object::operator= ( Object const & other)

Assignment.

Parameters
otherThe object to assign from.

◆ operator=() [2/2]

Object & Art::Paperback::Carousel::Object::operator= ( Object && other)

Assignment.

Parameters
otherThe object to assign from.

◆ operator==()

bool Art::Paperback::Carousel::Object::operator== ( Object const & other) const

Comparison.

Parameters
otherThe object to compare with.

◆ operator!=()

bool Art::Paperback::Carousel::Object::operator!= ( Object const & other) const

Comparison.

Parameters
otherThe object to compare with.

◆ container() [1/2]

Object_model::Container_base & Art::Paperback::Carousel::Object::container ( )
private

Get the container of the object.

◆ container() [2/2]

Object_model::Container_base const & Art::Paperback::Carousel::Object::container ( ) const
private

Get the container of the object.

Friends And Related Symbol Documentation

◆ is_of_type

template<typename>
bool is_of_type ( Object const & object)
friend

Check object type.

◆ object_cast [1/2]

template<typename T>
T & object_cast ( Object & object)
friend

This function provides access to the value of an object.

◆ object_cast [2/2]

template<typename T>
T const & object_cast ( Object const & object)
friend

This function provides access to the value of an object.

◆ clone

Object clone ( Object & object)
friend

Clone an object.

Parameters
objectThe object to clone.

◆ accept [1/2]

void accept ( Object & visitee,
Visitor & v )
friend

Accept visitor on object.

Parameters
visiteeThe visitee.
vThe visitor.

◆ accept [2/2]

void accept ( Object const & visitee,
Visitor & v )
friend

Accept visitor on object.

Parameters
visiteeThe visitee.
vThe visitor.

Member Data Documentation

◆ _data

shared_ptr<Object_model::Abstract> Art::Paperback::Carousel::Object::_data
private

Holds the data of the object, either an instance of Object_model::Reference for references, or an instance of Object_model::Container for direct objects.