API  4.0
For C++ developers
OpenSim::FileAdapter Class Reference

FileAdapter is a DataAdapter that reads and writes files with methods readFile and writeFile respectively. More...

+ Inheritance diagram for OpenSim::FileAdapter:

Public Member Functions

 FileAdapter ()=default
 
 FileAdapter (const FileAdapter &)=default
 
 FileAdapter (FileAdapter &&)=default
 
FileAdapteroperator= (const FileAdapter &)=default
 
FileAdapteroperator= (FileAdapter &&)=default
 
virtual ~FileAdapter ()=default
 
- Public Member Functions inherited from OpenSim::DataAdapter
virtual DataAdapterclone () const =0
 
 DataAdapter ()=default
 
 DataAdapter (const DataAdapter &)=default
 
 DataAdapter (DataAdapter &&)=default
 
DataAdapteroperator= (const DataAdapter &)=default
 
DataAdapteroperator= (DataAdapter &&)=default
 
virtual ~DataAdapter ()=default
 

Static Public Member Functions

static OutputTables readFile (const std::string &fileName)
 Read a file with the given name. More...
 
static void writeFile (const InputTables &tables, const std::string &fileName)
 Write a collection of tables to the given file. More...
 
static std::string findExtension (const std::string &filename)
 Find the extension from a filename. More...
 
static std::vector< std::string > getNextLine (std::istream &stream, const std::string &delims)
 Get the next line from the stream and tokenize/split the line using the given delimiters. More...
 
- Static Public Member Functions inherited from OpenSim::DataAdapter
static bool registerDataAdapter (const std::string &identifier, const DataAdapter &adapter)
 Register a concrete DataAdapter by its unique string identifier. More...
 

Static Protected Member Functions

static std::vector< std::string > tokenize (const std::string &str, const std::string &delims)
 Tokenize/split a given string using the given delimiters. More...
 
- Static Protected Member Functions inherited from OpenSim::DataAdapter
static std::shared_ptr< DataAdaptercreateAdapter (const std::string &identifier)
 Creator of concrete DataAdapter(s) for the specified source type by its unique identifier (string). More...
 

Additional Inherited Members

- Public Types inherited from OpenSim::DataAdapter
typedef std::map< std::string, std::shared_ptr< DataAdapter > > RegisteredDataAdapters
 Type of the registry containing registered adapters. More...
 
typedef std::map< std::string, std::shared_ptr< AbstractDataTable > > OutputTables
 Collection of tables returned by reading methods implemented in derived classes. More...
 
typedef std::map< std::string, const AbstractDataTable * > InputTables
 Collection of tables accepted by writing methods implemented in derived classes. More...
 
- Protected Member Functions inherited from OpenSim::DataAdapter
virtual OutputTables extendRead (const std::string &sourceName) const =0
 Implements reading functionality. More...
 
virtual void extendWrite (const InputTables &tables, const std::string &sinkName) const =0
 Implements writing functionality. More...
 

Detailed Description

FileAdapter is a DataAdapter that reads and writes files with methods readFile and writeFile respectively.

Constructor & Destructor Documentation

◆ FileAdapter() [1/3]

OpenSim::FileAdapter::FileAdapter ( )
default

◆ FileAdapter() [2/3]

OpenSim::FileAdapter::FileAdapter ( const FileAdapter )
default

◆ FileAdapter() [3/3]

OpenSim::FileAdapter::FileAdapter ( FileAdapter &&  )
default

◆ ~FileAdapter()

virtual OpenSim::FileAdapter::~FileAdapter ( )
virtualdefault

Member Function Documentation

◆ findExtension()

static std::string OpenSim::FileAdapter::findExtension ( const std::string &  filename)
static

Find the extension from a filename.

◆ getNextLine()

static std::vector<std::string> OpenSim::FileAdapter::getNextLine ( std::istream &  stream,
const std::string &  delims 
)
static

Get the next line from the stream and tokenize/split the line using the given delimiters.

◆ operator=() [1/2]

FileAdapter& OpenSim::FileAdapter::operator= ( const FileAdapter )
default

◆ operator=() [2/2]

FileAdapter& OpenSim::FileAdapter::operator= ( FileAdapter &&  )
default

◆ readFile()

static OutputTables OpenSim::FileAdapter::readFile ( const std::string &  fileName)
static

Read a file with the given name.

Returns a collection of tables depending on the contents of the file read. For example, a TRC file contains just one table whereas a C3D file might contain multiple tables. Refer to the specific adapter's documentation to see what was returned.

Referenced by OpenSim::DataTable_< double, ValueT >::DataTable_(), and OpenSim::TimeSeriesTable_< ValueT >::TimeSeriesTable_().

◆ tokenize()

static std::vector<std::string> OpenSim::FileAdapter::tokenize ( const std::string &  str,
const std::string &  delims 
)
staticprotected

Tokenize/split a given string using the given delimiters.

The delimiters are each required to be one character and the string is split if/when any of those characters are found. For example, a delimiter string " \t" specifies that either a space or a tab can act as the delimiter.

◆ writeFile()

static void OpenSim::FileAdapter::writeFile ( const InputTables tables,
const std::string &  fileName 
)
static

Write a collection of tables to the given file.

Different file formats require different number/type of tables. See specific adapter's documentation to see what is required.


The documentation for this class was generated from the following file: