|
#include <NameTree.h>
Public Member Functions | |
| NameTree (Obj name_tree) | |
| Create a high level NameTree wrapper around an existing SDF/Cos NameTree. | |
| NameTree (const NameTree &d) | |
| Copy constructor. | |
| NameTree & | operator= (const NameTree &d) |
| Assignment operator. | |
| bool | IsValid () |
| |
| NameTreeIterator | GetIterator (const UChar *key, int key_sz) |
| Search for the specified key in the NameTree. | |
| NameTreeIterator | GetIterator () |
| |
| Obj | GetValue (const UChar *key, int key_sz) |
| Search the NameTree for a given key. | |
| void | Put (const UChar *key, int key_sz, Obj value) |
| Puts a new entry in the name tree. | |
| void | Erase (const UChar *key, int key_sz) |
| Removes the specified object from the tree. | |
| void | Erase (DictIterator &pos) |
| Removes the NameTree entry pointed by the iterator. | |
| Obj | GetSDFObj () const |
| |
Static Public Member Functions | |
| static NameTree | Create (class SDFDoc &doc, const std::string &name) |
| Retrieves the NameTree inside the '/Root/Names' dictionary with the specified key name, or creates it if it does not exist. | |
| static NameTree | Find (class SDFDoc &doc, const std::string &name) |
| Retrieves a name tree, with the given key name, from the '/Root/Names' dictionary of the doc. | |
Protected Member Functions | |
| NameTree () | |
Protected Attributes | |
| TRN_NameTree | mp_obj |
See section 3.8.5 'Name Trees' in PDF Reference Manual for more details.
A name tree serves a similar purpose to a dictionary - associating keys and values - but by different means. NameTrees allow efficient storage of very large association collections (string/Obj* maps). A NameTree can have many more entries than a SDF/Cos dictionary can.
NameTree-s use SDF/Cos-style strings (not null-terminated C strings), which may use Unicode encoding etc.
PDFDoc doc("../Data/PDFReference.pdf"); NameTree dests = NameTree::Find(*doc.GetSDFDoc(), "Dests"); if (dests.IsValid()) { // Traversing the NameTree UString key; for (DictIterator i = dests.GetIterator(); i.HasNext(); i.Next()) i.Key().GetAsPDFText(key); // ... }
| pdftron::SDF::NameTree::NameTree | ( | Obj | name_tree | ) |
| pdftron::SDF::NameTree::NameTree | ( | const NameTree & | d | ) |
Copy constructor.
| pdftron::SDF::NameTree::NameTree | ( | ) | [inline, protected] |
| static NameTree pdftron::SDF::NameTree::Create | ( | class SDFDoc & | doc, | |
| const std::string & | name | |||
| ) | [static] |
Retrieves the NameTree inside the '/Root/Names' dictionary with the specified key name, or creates it if it does not exist.
| doc | - The document in which the name tree is created. | |
| name | - The name of the NameTree to create. |
| static NameTree pdftron::SDF::NameTree::Find | ( | class SDFDoc & | doc, | |
| const std::string & | name | |||
| ) | [static] |
Retrieves a name tree, with the given key name, from the '/Root/Names' dictionary of the doc.
| doc | - The document in which to search for the name. | |
| name | - The name of the name tree to find. |
| bool pdftron::SDF::NameTree::IsValid | ( | ) |
| NameTreeIterator pdftron::SDF::NameTree::GetIterator | ( | const UChar * | key, | |
| int | key_sz | |||
| ) |
Search for the specified key in the NameTree.
| key | data buffer representing the key to be found. | |
| key_sz | The size (in bytes) of the key. |
DictIterator i = dests.Find("MyKey", 5); if (i.HasNext()) { UString key; i.GetKey().GetAsPDFText(key); // ... cout << "Value: " << i.GetValue().GetType() << endl; }
| NameTreeIterator pdftron::SDF::NameTree::GetIterator | ( | ) |
The iterator can be used to traverse all entries stored in the NameTree.
UString key; for (NameTreeIterator i = dests.GetIterator(); i.HasNext(); i.Next()) { i.GetKey().GetAsPDFText(key); // ... }
Search the NameTree for a given key.
| key | - a key to search for in the dictionary | |
| key_sz | - the buffer size used to store the key. |
Puts a new entry in the name tree.
If an entry with this key is already in the tree, it is replaced.
| key | data buffer representing the key of the new entry. | |
| key_sz | The size (in bytes) of the key. | |
| the | value associated with the key. It can be any SDF::Obj. |
| void pdftron::SDF::NameTree::Erase | ( | const UChar * | key, | |
| int | key_sz | |||
| ) |
Removes the specified object from the tree.
Does nothing if no object with that name exists.
| key | data buffer representing the key of the entry to be removed. | |
| key_sz | The size (in bytes) of the key. |
| void pdftron::SDF::NameTree::Erase | ( | DictIterator & | pos | ) |
Removes the NameTree entry pointed by the iterator.
| Obj pdftron::SDF::NameTree::GetSDFObj | ( | ) | const |
If the NameTree.IsValid() returns false the SDF/Cos object is NULL.
TRN_NameTree pdftron::SDF::NameTree::mp_obj [protected] |