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

Implements the COS cross-reference table. More...

#include <art/paperback/carousel/cross-reference.hxx>

Classes

struct  Free_entry
 Represents a free entry in the cross-reference table. More...
 
struct  Used_entry
 Represents a used entry in the cross-reference table. More...
 

Public Member Functions

 cross_Reference ()
 Constructor.
 
 cross_Reference (cross_Reference const &)
 Constructor.
 
 cross_Reference (cross_Reference &&)
 Constructor.
 
 ~cross_Reference () noexcept
 Destructor.
 
uint32_t size () const
 Get the size of the cross-reference table.
 
Identity allocate ()
 Allocate a new object index.
 
int64_t get_offset (Identity) const
 Get the offset of a used entry.
 
void set_offset (Identity, int64_t)
 Set the offset of a used entry.
 
Identity next () const
 Get the next available object identity.
 
void write (Writer &, bool)
 Write the cross-reference to an output stream.
 
void clear_offsets ()
 Clears the offsets of used entries.
 
cross_Referenceoperator= (cross_Reference const &)
 Assignment.
 
cross_Referenceoperator= (cross_Reference &&)
 Assignment.
 

Private Types

using Entry = variant<Free_entry, Used_entry>
 

Private Attributes

map< Identity, Entry > _table
 Cross-reference table entries.
 

Detailed Description

Implements the COS cross-reference table.

The cross-reference table maintains a link between an object index/generation and its position in the COS-file.

The paperback implementation of the PDF 1.4 specification does not re-use the index of a previously deleted object, hence the generation of new objects will always be zero (0).

Constructor & Destructor Documentation

◆ cross_Reference() [1/3]

Art::Paperback::Carousel::cross_Reference::cross_Reference ( )

Constructor.

This constructor creates a new cross-reference table.

Object 0 will be automatically allocated.

◆ cross_Reference() [2/3]

Art::Paperback::Carousel::cross_Reference::cross_Reference ( cross_Reference const & )
default

Constructor.

◆ cross_Reference() [3/3]

Art::Paperback::Carousel::cross_Reference::cross_Reference ( cross_Reference && )
default

Constructor.

◆ ~cross_Reference()

Art::Paperback::Carousel::cross_Reference::~cross_Reference ( )
noexcept

Destructor.

Member Function Documentation

◆ size()

uint32_t Art::Paperback::Carousel::cross_Reference::size ( ) const

Get the size of the cross-reference table.

Returns
Returns the size of the cross-reference table.

◆ allocate()

Identity Art::Paperback::Carousel::cross_Reference::allocate ( )

Allocate a new object index.

Returns
Returns the identity of the newly allocated object.

◆ get_offset()

int64_t Art::Paperback::Carousel::cross_Reference::get_offset ( Identity identity) const

Get the offset of a used entry.

Parameters
identityThe object identity for which to retrieve the offset.
Returns
Returns the file offset of the object.

◆ set_offset()

void Art::Paperback::Carousel::cross_Reference::set_offset ( Identity identity,
int64_t offset )

Set the offset of a used entry.

Exceptions
Internal_errorThrown if the object is not allocated.

◆ next()

Identity Art::Paperback::Carousel::cross_Reference::next ( ) const

Get the next available object identity.

Returns
Returns the index of the next available object.

◆ write()

void Art::Paperback::Carousel::cross_Reference::write ( Writer & w,
bool update )

Write the cross-reference to an output stream.

Parameters
wThe COS-file writer.
updateTrue if this is an update; false otherwise.

◆ clear_offsets()

void Art::Paperback::Carousel::cross_Reference::clear_offsets ( )

Clears the offsets of used entries.

◆ operator=() [1/2]

cross_Reference & Art::Paperback::Carousel::cross_Reference::operator= ( cross_Reference const & )
default

Assignment.

◆ operator=() [2/2]

cross_Reference & Art::Paperback::Carousel::cross_Reference::operator= ( cross_Reference && )
default

Assignment.

Member Data Documentation

◆ _table

map<Identity, Entry> Art::Paperback::Carousel::cross_Reference::_table
private

Cross-reference table entries.