# CollectionSchema Class

> Provides for adding/removing/retrieving schema fields in a collection.

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

```cpp
class CollectionSchema
```

**Namespace:** `datalogics_interface`

## Description

Provides for adding/removing/retrieving schema fields in a collection.

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

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

## Constructors

### CollectionSchema

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

*constructor*

**Parameters**

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

### ~CollectionSchema

```cpp
datalogics_interface::CollectionSchema::~CollectionSchema()
```

*destructor*

## Methods

### add_field

```cpp
void datalogics_interface::CollectionSchema::add_field(CollectionSchemaField &field)
```

**Parameters**

- `field` ([`CollectionSchemaField &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/CollectionSchemaField.md)): CollectionSchemaField object which will be added to the schema.

**Returns:** `void`

AddField allows to set new field to the CollectionSchema object. If the target field exists, it is overwritten.

The schema fields contain all information required to organize Collection in a certain way.

### get_field

```cpp
std::unique_ptr< CollectionSchemaField > datalogics_interface::CollectionSchema::get_field(const std::string &name) const
```

**Parameters**

- `name` (`const std::string &`): textual field name.

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

CollectionSchemaField object if found or NULL otherwise.

GetField allows to obtain CollectionSchemaField by name.

### get_field

```cpp
std::unique_ptr< CollectionSchemaField > datalogics_interface::CollectionSchema::get_field(int index) const
```

**Parameters**

- `index` (`int`): textual field name.

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

CollectionSchemaField object if found or NULL otherwise.

GetField allows to obtain CollectionSchemaField by name.

### get_field_count

```cpp
int datalogics_interface::CollectionSchema::get_field_count() const
```

**Returns:** `int`

the fields number.

GetFieldsNumber allows to obtain fields number in the schema.

### operator=

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

**Parameters**

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

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

### remove_field

```cpp
void datalogics_interface::CollectionSchema::remove_field(CollectionSchemaField &field)
```

**Parameters**

- `field` ([`CollectionSchemaField &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/CollectionSchemaField.md)): CollectionSchemaField which will be removed from the schema.

**Returns:** `void`

RemoveField allows to remove specified field from the schema.

NOTE: to distinguish whether specified object belongs to the schema this uses CollectionSchemaField's name.
