# NameTree Class

> The name tree is a common data structure in PDF files.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.4.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NameTree
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class NameTree
```

**Namespace:** `datalogics_interface`

## Description

The name tree is a common data structure in PDF files.

A name tree is a type of dictionary that can store many more pairs of matched records than a standard object dictionary.

A name tree uses keys that are character strings to map to data objects. The strings can use a standard coding format, such as Unicode, are sorted in order in the data structure, and can be associated with any type of object.

**Referenced by:** [`Document`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)

**Uses types:** [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md), [`PDFObject`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFObject.md)

## Constructors

### NameTree

```cpp
datalogics_interface::NameTree::NameTree(Document &doc)
```

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The Document in which to create the NameTree.

Creates a new, empty NameTree in the specified Document.

### NameTree

```cpp
datalogics_interface::NameTree::NameTree(NameTree &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`NameTree &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NameTree.md))

### ~NameTree

```cpp
datalogics_interface::NameTree::~NameTree()
```

*destructor*

## Methods

### get

```cpp
std::unique_ptr< PDFObject > datalogics_interface::NameTree::get(PDFString &key)
```

**Parameters**

- `key` ([`PDFString &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFString.md)): - The name of the PDFObject to get from the tree.

**Returns:** [`std::unique_ptr< PDFObject >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFObject.md)

- The PDFObject value corresponding to the supplied key

Retrieves an entry from this NameTree.

### get_pdf_dict

```cpp
PDFDict datalogics_interface::NameTree::get_pdf_dict()
```

**Returns:** [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md)

The PDFDict representing the NameTree's data structure.

Gets the underlying PDFDict of this NameTree.

### operator=

```cpp
NameTree & datalogics_interface::NameTree::operator=(NameTree &&) noexcept
```

**Parameters**

- (unnamed) ([`NameTree &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NameTree.md))

**Returns:** [`NameTree &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NameTree.md)

### put

```cpp
void datalogics_interface::NameTree::put(const std::string &key, ViewDestination &dest)
```

**Parameters**

- `key` (`const std::string &`)
- `dest` ([`ViewDestination &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ViewDestination.md))

**Returns:** `void`

Convenience overload: put a ViewDestination into the name tree under the given string key. Encodes the destination as its PDF array representation. Equivalent to building a PDFString key and calling put() with the destination's underlying array.

### put

```cpp
void datalogics_interface::NameTree::put(PDFString &key, PDFObject &value)
```

**Parameters**

- `key` ([`PDFString &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFString.md)): - The name of the PDFObject to put in the tree.
- `value` ([`PDFObject &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFObject.md)): - The PDFObject to be associated with key.

**Returns:** `void`

Puts a new entry in this NameTree. If an entry with this name is already in the tree, it is replaced.

### remove

```cpp
void datalogics_interface::NameTree::remove(PDFString &key)
```

**Parameters**

- `key` ([`PDFString &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFString.md)): - The name of the PDFObject to remove from the tree.

**Returns:** `void`

Removes the specified PDFObject from this NameTree. It does nothing if no PDFObject of that name exists in this NameTree.
