Skip to main content

Common Fluids Format 2025 R1

ansys::CffFileIO Class Reference

Last update: 19.05.2025

Base class that provides common function used in File providers such as ansys::CffFileProvider. More...

#include "CffInterface/CffFileIO.hpp"

Inheritance diagram for ansys::CffFileIO:
ansys::CffFileConsumeransys::CffFileProvider

Public Member Functions

 CffFileIO ()
 
virtual ~CffFileIO ()
 
virtual void setFile (const std::string &file, DataClass dataClass)
 
virtual bool getFileVersion (DataClass dataClass, std::string &version) const
 
virtual bool getFileVersion (DataClass dataClass, int &major, int &minor, int &patch) const
 

Protected Member Functions

std::vector< DataClassgetDataClasses () const
 
std::string getFile (DataClass source) const
 
virtual void setFileVersion (DataClass dataClass, const std::string &version)
 

Detailed Description

Base class that provides common function used in File providers such as ansys::CffFileProvider.

Functions such as ansys::CffFileIO::setFile need to be called prior to the call to ansys::CffProvider::startReading or ansys::CffConsumer::startWriting

A typical workflow would be:

// Use ansys::DataClass::CFF_RESULTS for a results file
provider->setFile(caseFileName, ansys::DataClass::CFF_CASE);
@ CFF_CASE
Definition: CffTypes.h:419
provider->startReading(ansys::DataClass::CFF_CASE);

Constructor & Destructor Documentation

◆ CffFileIO()

ansys::CffFileIO::CffFileIO ( )
inline

◆ ~CffFileIO()

virtual ansys::CffFileIO::~CffFileIO ( )
inlinevirtual

Member Function Documentation

◆ getDataClasses()

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()

std::string ansys::CffFileIO::getFile ( DataClass  dataClass) const
protected

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

Parameters
[in]dataClass- Data class to which file is associated.
Returns
- Associated filename.

◆ getFileVersion() [1/2]

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
[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]

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
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()

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
[in]file- Filename to associate with the data class.
[in]dataClass- Data class to which file is associated.

◆ setFileVersion()

void ansys::CffFileIO::setFileVersion ( DataClass  dataClass,
const std::string &  fileVersion 
)
protectedvirtual

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.

Parameters
[in]dataClass- file in which data in the source is read/written.
[in]fileVersion- version string of the form Maj.Min[.Patch].

Connect with Ansys