> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ansys::CffFileIO Class Reference

Base class that provides common function used in File providers such as [ansys::CffFileProvider](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_cff_file_provider.md).

`#include "CffInterface/CffFileIO.hpp"`

Inheritance diagram for ansys::CffFileIO:

![](https://mintcdn.com/synopsys-00a47cbc/Srh1_f--TdKCLyqD/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_cff_file_i_o.png?fit=max\&auto=format\&n=Srh1_f--TdKCLyqD\&q=85\&s=b6c28df7de5814c32c84da398b118d68)

## Public Member Functions

| Type | Name |
| - | - |
| | [CffFileIO](#a632ba44699605d0139bdbe27662407bf) () |
| virtual | [\~CffFileIO](#aec2a3cfcb38140a95f1f68eb8d4ec859) () |
| virtual void | [setFile](#a5e700a7a3cb529ab48fb759e339c85e7) (const std::string \&file, [DataClass](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/group__enums.md#gab852cc24891eb831942fb8da764d8ddb) dataClass) |
| virtual bool | [getFileVersion](#a548f6a285539d9d571ded617ba1a8041) ([DataClass](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/group__enums.md#gab852cc24891eb831942fb8da764d8ddb) dataClass, std::string \&version) const |
| virtual bool | [getFileVersion](#a00f3a9cd110d836abebdbafd1516cc6f) ([DataClass](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/group__enums.md#gab852cc24891eb831942fb8da764d8ddb) dataClass, int \&major, int \&minor, int \&patch) const |
| virtual void | [setFormat](#a5346d2aac3ac9d0bf340e9dfe515776d) (bool isBinary=true) Sets the output format (VTP/VTU files only). |

## Protected Member Functions

| Type | Name |
| - | - |
| std::vector\< [DataClass](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/group__enums.md#gab852cc24891eb831942fb8da764d8ddb) > | [getDataClasses](#a0ee7191bc49e9b689362e2195bacc3f4) () const |
| std::string | [getFile](#a77ef49cc6834d7f441c61e0128b5dac7) ([DataClass](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/group__enums.md#gab852cc24891eb831942fb8da764d8ddb) source) const |
| virtual void | [setFileVersion](#abaebab966110531b473dcdb219134822) ([DataClass](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/group__enums.md#gab852cc24891eb831942fb8da764d8ddb) dataClass, const std::string \&version) |

## Detailed Description

Base class that provides common function used in File providers such as [ansys::CffFileProvider](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_cff_file_provider.md).

Functions such as [ansys::CffFileIO::setFile](#a5e700a7a3cb529ab48fb759e339c85e7) need to be called prior to the call to [ansys::CffProvider::startReading](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_cff_provider.md#ae75f33106aba17bdc897ac8f7678a845) or [ansys::CffConsumer::startWriting](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_cff_consumer.md#acf12d6b60e936c525c8b5348d631ec78)

A typical workflow would be:

```cpp theme={null}
 // Use ansys::DataClass::CFF_RESULTS for a results file
    provider->setFile(caseFileName, ansys::DataClass::CFF_CASE);
```

```cpp theme={null}
    provider->startReading(ansys::DataClass::CFF_CASE);
```

## Constructor & Destructor Documentation

### CffFileIO()

```cpp theme={null}
ansys::CffFileIO::CffFileIO()
```

`inline`

### \~CffFileIO()

```cpp theme={null}
virtual ansys::CffFileIO::~CffFileIO()
```

`inline` `virtual`

## Member Function Documentation

### getDataClasses()

```cpp theme={null}
std::vector< DataClass > ansys::CffFileIO::getDataClasses() const
```

`protected`

Get all classes of data for which file names have been set.

**Returns**

* all data classes that have had files set.

### getFile()

```cpp theme={null}
std::string ansys::CffFileIO::getFile(DataClass dataClass) const
```

`protected`

Get the file name of the file associated ith the class of data.

**Parameters**

| Direction | Name | Description |
| - | - | - |
| \[in] | dataClass | - Data class to which file is associated. |

**Returns**

* Associated filename.

### getFileVersion() \[1/2]

```cpp theme={null}
bool ansys::CffFileIO::getFileVersion(
    DataClass dataClass,
    int & major,
    int & minor,
    int & patch
) const
```

`virtual`

Get the version number of API the file was written with as three integers representing the major, minor and patch numbers.

**Parameters**

| Direction | Name | Description |
| - | - | - |
| \[in] | dataClass | - Data class associated with the file from which to read the version. |
| \[out] | major | - Major version number. |
| \[out] | minor | - Minor version number. |
| \[out] | patch | - Patch version number. |

**Returns**

* true if successful, false if invalid.

### getFileVersion() \[2/2]

```cpp theme={null}
bool ansys::CffFileIO::getFileVersion(
    DataClass dataClass,
    std::string & version
) const
```

`virtual`

Get the version number of API the file was written with as a string.

**Parameters**

| Name | Description |
| - | - |
| dataClass | \[in] - Data class identifying the file from which to read the version. |
| version | \[out] - e.g. Maj.Min\[.Patch] |

**Returns**

* true if successful, false if invalid.

### setFile()

```cpp theme={null}
void ansys::CffFileIO::setFile(
    const std::string & file,
    DataClass dataClass
)
```

`virtual`

Set the file name of the file associated with a class of data.

**Parameters**

| Direction | Name | Description |
| - | - | - |
| \[in] | file | - Filename to associate with the data class. |
| \[in] | dataClass | - Data class to which file is associated. |

### setFileVersion()

```cpp theme={null}
void ansys::CffFileIO::setFileVersion(
    DataClass dataClass,
    const std::string & fileVersion
)
```

`protected` `virtual`

Set the version of the API the file, of the the provided data class, is written against.

Should be called at time of reading of the file by the [CffConsumer](https://developer.synopsys.com/docs/cff/common-fluids-format-sdk-guide/classansys_1_1_cff_consumer.md).

**Parameters**

| Direction | Name | Description |
| - | - | - |
| \[in] | dataClass | - file in which data in the source is read/written. |
| \[in] | fileVersion | - version string of the form Maj.Min\[.Patch]. |

### setFormat()

```cpp theme={null}
void ansys::CffFileIO::setFormat(bool isBinary = true)
```

`virtual`

Sets the output format (VTP/VTU files only).

Sets binary (`true`, default) or ASCII (`false`) format. Does nothing for non-VTP/VTU writers.

**Parameters**

| Name | Description |
| - | - |
| isBinary | Format type: `true` for binary, `false` for ASCII. |
