pdftron::SDF::NumberTree Class Reference

A NumberTree is a common data structure in PDF. More...

#include <NumberTree.h>

List of all members.

Public Member Functions

 NumberTree (Obj number_tree)
 Create a high level NumberTree wrapper around an existing SDF/Cos NumberTree.
 NumberTree (const NumberTree &d)
 Copy constructor.
NumberTreeoperator= (const NumberTree &d)
 Assignment operator.
bool IsValid ()
 
Returns:
whether this is a valid (non-null) NumberTree.

NumberTreeIterator GetIterator (long key)
 Search for the specified key in the NumberTree.
NumberTreeIterator GetIterator ()
 
Returns:
an iterator to the first key/value pair (i.e.

Obj GetValue (long key)
void Put (long key, Obj value)
 Puts a new entry in the name tree.
void Erase (long key)
 Removes the specified object from the tree.
void Erase (DictIterator &pos)
 Removes the NumberTree entry pointed by the iterator.
Obj GetSDFObj () const
 
Returns:
the object to the underlying SDF/Cos object.


Protected Attributes

TRN_NumberTree mp_obj


Detailed Description

A NumberTree is a common data structure in PDF.

See section 3.8.6 'Number Trees' in PDF Reference Manual for more details.

A number tree serves a similar purpose to a dictionary - associating keys and values - but by different means. NumberTrees allow efficient storage of very large association collections (number/Obj* maps). A NumberTree can have many more entries than a SDF/Cos dictionary can.

Sample code:

   PDFDoc doc("../Data/test.pdf");
   NumberTree labels(doc.GetRoot().Get("PageLabels").Value());
   if (labels.IsValid()) {
     // Traversing the NumberTree 
     for (NumberTreeIterator i = labels.GetIterator(); i.HasNext(); i.Next()) 
         cout << "Key: " << i.Key().GetNumber() << endl;
   }

Constructor & Destructor Documentation

pdftron::SDF::NumberTree::NumberTree ( Obj  number_tree  ) 

Create a high level NumberTree wrapper around an existing SDF/Cos NumberTree.

This does not copy the object.

Parameters:
number_tree SDF/Cos root of the NumberTree object.

pdftron::SDF::NumberTree::NumberTree ( const NumberTree d  ) 

Copy constructor.


Member Function Documentation

NumberTree& pdftron::SDF::NumberTree::operator= ( const NumberTree d  ) 

Assignment operator.

bool pdftron::SDF::NumberTree::IsValid (  ) 

Returns:
whether this is a valid (non-null) NumberTree.

If the function returns false the underlying SDF/Cos object is null and the NumberTree object should be treated as null as well.

NumberTreeIterator pdftron::SDF::NumberTree::GetIterator ( long  key  ) 

Search for the specified key in the NumberTree.

Returns:
If the key is present the function returns a NumberTreeIterator the points to the given Key/Value pair. If the key is not found the function returns End() (a non-valid) iterator.
Parameters:
key the number representing the key to be found.
Sample code: NumberTreeIterator i = dests.Find(5); if (i.HasNext()) { cout << "Key: " << i.GetKey()->GetNumber() << endl; cout << "Value: " << i.GetValue()->GetType() << endl; }

NumberTreeIterator pdftron::SDF::NumberTree::GetIterator (  ) 

Returns:
an iterator to the first key/value pair (i.e.

NNTreeData) in the document. You can use the Next method on the returned iterator to traverese all entries stored under the NumberTree.

Sample code: for (NumberTreeIterator i = dests.getIterator(); i.HasNext(); i.Next()) cout << "Key: " << i.GetKey().GetNumber() << endl;

Obj pdftron::SDF::NumberTree::GetValue ( long  key  ) 

void pdftron::SDF::NumberTree::Put ( long  key,
Obj  value 
)

Puts a new entry in the name tree.

If an entry with this number is already in the tree, it is replaced.

Parameters:
key A number representing the key of the new entry.
the value associated with the key. It can be any SDF::Obj.

void pdftron::SDF::NumberTree::Erase ( long  key  ) 

Removes the specified object from the tree.

Does nothing if no object with that number exists.

Parameters:
key A number representing the key of the entry to be removed.

void pdftron::SDF::NumberTree::Erase ( DictIterator &  pos  ) 

Removes the NumberTree entry pointed by the iterator.

Obj pdftron::SDF::NumberTree::GetSDFObj (  )  const

Returns:
the object to the underlying SDF/Cos object.

If the NumberTree.IsValid() returns false the SDF/Cos object is NULL.


Member Data Documentation

TRN_NumberTree pdftron::SDF::NumberTree::mp_obj [protected]


© 2002-2008 PDFTron Systems Inc.