# OptionalContentOrderArray Class

> Array node class for items in the OptionalContentConfig Order array.

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

```cpp
class OptionalContentOrderArray : OptionalContentOrderNode
```

**Namespace:** `datalogics_interface`

**Inherits from:** [`OptionalContentOrderNode`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentOrderNode.md)

## Description

Array node class for items in the OptionalContentConfig Order array.

Items in the Order array can be arranged into a tree structure; subarrays within the parent array form 'branches' of the tree. Each OptionalContentOrderArray may contain OptionalContentOrderLeafs or OptionalContentOrderArrays in a specific order; this order determines how they will appear in the 'Layers' control of the viewer.

By placing OptionalContentOrderArrays into a higher-level array, branches can be added to the tree. The 'Title' property is a string that will appear next to the expand/collapse branch control in a PDF Viewer 'Layers' panel.

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

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

## Constructors

### OptionalContentOrderArray

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

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The Document this OptionalContentOrderArray is being created in

Create an OptionalContentOrderArray with no title.

### OptionalContentOrderArray

```cpp
datalogics_interface::OptionalContentOrderArray::OptionalContentOrderArray(Document &doc, const std::string &title)
```

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The Document this OptionalContentOrderArray is being created in
- `title` (`const std::string &`)

Create an OptionalContentOrderArray with no title.

### OptionalContentOrderArray

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

*constructor*

**Parameters**

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

### ~OptionalContentOrderArray

```cpp
datalogics_interface::OptionalContentOrderArray::~OptionalContentOrderArray() override
```

*destructor*

## Methods

### add

```cpp
void datalogics_interface::OptionalContentOrderArray::add(OptionalContentOrderNode &node)
```

**Parameters**

- `node` ([`OptionalContentOrderNode &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentOrderNode.md)): The OptionalContentOrderNode to append to the Array

**Returns:** `void`

Adds an OptionalContentOrderNode to the end of the Array.

### get

```cpp
std::unique_ptr< OptionalContentOrderNode > datalogics_interface::OptionalContentOrderArray::get(int index)
```

**Parameters**

- `index` (`int`): The index at which to fetch an OptionalContentOrderNode.

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

An OptionalContentOrderNode, or null if there is nothing at that index.

Returns the OptionalContentOrderNode at the given index.

### get_length

```cpp
int datalogics_interface::OptionalContentOrderArray::get_length() const
```

**Returns:** `int`

The number of nodes in this array.

Gets the number of OptionalContentOrderNodes in this array.

### get_title

```cpp
std::string datalogics_interface::OptionalContentOrderArray::get_title() const
```

**Returns:** `std::string`

The title string of this OptionalContentOrderArray, or NULL if no title is set.

Gets the title string of this Array.

This title will appear next to the expand/collapse control in the 'Layers' panel of a PDF Viewer.

### insert

```cpp
void datalogics_interface::OptionalContentOrderArray::insert(int index, OptionalContentOrderNode &node)
```

**Parameters**

- `index` (`int`): The index at which to insert the Node
- `node` ([`OptionalContentOrderNode &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentOrderNode.md)): The OptionalContentOrderNode to insert in the Array

**Returns:** `void`

Inserts an OptionalContentOrderNode at the given index, displacing existing objects. All objects following this will have their index increased by one.

### operator=

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

**Parameters**

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

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

### put

```cpp
void datalogics_interface::OptionalContentOrderArray::put(int index, OptionalContentOrderNode &node)
```

**Parameters**

- `index` (`int`): The index at which to replace the existing Node
- `node` ([`OptionalContentOrderNode &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentOrderNode.md)): The OptionalContentOrderNode to place in the Array

**Returns:** `void`

Puts an OptionalContentOrderNode at the given index, replacing the existing item. The index can be greater than the current length of the array; the array will be extended and the empty slots filled with null objects.

### remove_at

```cpp
void datalogics_interface::OptionalContentOrderArray::remove_at(int index)
```

**Parameters**

- `index` (`int`): The index of the OptionalContentOrderNode to remove

**Returns:** `void`

Removes the OptionalContentOrderNode at the given index. The length of the array is reduced by 1.

### set_title

```cpp
void datalogics_interface::OptionalContentOrderArray::set_title(const std::string &title)
```

**Parameters**

- `title` (`const std::string &`): The title string of this OptionalContentOrderArray, or NULL to remove the title.

**Returns:** `void`

Sets the title string of this Array.

This title will appear next to the expand/collapse control in the 'Layers' panel of a PDF Viewer. This field may be set to NULL to remove the title.

### try_as

```cpp
T * datalogics_interface::OptionalContentOrderNode::try_as()
```

**Parameters**

- (unnamed) (`typename T`)

**Returns:** `T *`

Attempt to downcast this node to a derived type. Returns a pointer to the derived type, or nullptr if the type doesn't match.

### try_as

```cpp
const T * datalogics_interface::OptionalContentOrderNode::try_as() const
```

**Parameters**

- (unnamed) (`typename T`)

**Returns:** `const T *`

Const overload of try_as(). Returns a const pointer, or nullptr.
