API  4.5.1
For C++ developers
OpenSim::DelimFileAdapter< T > Class Template Reference

DelimFileAdapter is a FileAdapter that reads and writes text files with given delimiters. More...

+ Inheritance diagram for OpenSim::DelimFileAdapter< T >:

Public Member Functions

 DelimFileAdapter ()=delete
 
 DelimFileAdapter (const DelimFileAdapter &)=default
 
 DelimFileAdapter (DelimFileAdapter &&)=default
 
DelimFileAdapteroperator= (const DelimFileAdapter &)=default
 
DelimFileAdapteroperator= (DelimFileAdapter &&)=default
 
 ~DelimFileAdapter ()=default
 
 DelimFileAdapter (const std::string &delimitersRead, const std::string &delimterWrite)
 Create the adapter by setting the delimiters. More...
 
 DelimFileAdapter (const std::string &delimitersRead, const std::string &delimterWrite, const std::string &compDelimRead, const std::string &compDelimWrite)
 Create the adapter by setting the delimiters. More...
 
DelimFileAdapterclone () const override
 
- Public Member Functions inherited from OpenSim::FileAdapter
 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
 DataAdapter ()=default
 
 DataAdapter (const DataAdapter &)=default
 
 DataAdapter (DataAdapter &&)=default
 
DataAdapteroperator= (const DataAdapter &)=default
 
DataAdapteroperator= (DataAdapter &&)=default
 
virtual ~DataAdapter ()=default
 
DataAdapter::OutputTables read (const std::string &dataSourceSpecification) const
 Public interface to read data from a dataSourceSpecification, typically a file or folder. More...
 
const std::shared_ptr< AbstractDataTablegetDataTable (const OutputTables &tables, const std::string tableName)
 Generic interface to retrieve a specific table by name from read result. More...
 

Static Public Member Functions

static const std::string tableString ()
 Key used for table associative array returned/accepted by write/read. More...
 
static std::string dataTypeName ()
 Name of the data type T (template parameter). More...
 
- Static Public Member Functions inherited from OpenSim::FileAdapter
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 std::vector< std::string > tokenize (const std::string &str, const std::string &delims)
 Tokenize/split a given string using the given delimiters. More...
 
static std::shared_ptr< DataAdaptercreateAdapterFromExtension (const std::string &fileName)
 Create a concerte FileAdapter based on the extension of the passed in file and return it. 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...
 

Protected Member Functions

OutputTables extendRead (const std::string &filename) const override
 Implementation of the read functionality. More...
 
void extendWrite (const InputTables &tables, const std::string &filename) const override
 Implementation of the write functionality. More...
 
SimTK::RowVector_< T > readElems (const std::vector< std::string > &tokens) const
 Read elements of type T (template parameter) from a sequence of tokens. More...
 
void writeElem (std::ostream &stream, const T &elem, const unsigned &prec) const
 Write an element of type T (template parameter) to stream with the specified precision. 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...
 
- 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...
 

Detailed Description

template<typename T>
class OpenSim::DelimFileAdapter< T >

DelimFileAdapter is a FileAdapter that reads and writes text files with given delimiters.

CSVFileAdapter and MOTFileAdapter derive from this class and set the delimiters appropriately for the files they parse. The read/write functions return/accept a specific type of DataTable referred to as Table in this class.
Header in the file is assumed to end with string "endheader" occupying a full line.

Constructor & Destructor Documentation

◆ DelimFileAdapter() [1/5]

template<typename T>
OpenSim::DelimFileAdapter< T >::DelimFileAdapter ( )
delete

◆ DelimFileAdapter() [2/5]

template<typename T>
OpenSim::DelimFileAdapter< T >::DelimFileAdapter ( const DelimFileAdapter< T > &  )
default

◆ DelimFileAdapter() [3/5]

template<typename T>
OpenSim::DelimFileAdapter< T >::DelimFileAdapter ( DelimFileAdapter< T > &&  )
default

◆ ~DelimFileAdapter()

template<typename T>
OpenSim::DelimFileAdapter< T >::~DelimFileAdapter ( )
default

◆ DelimFileAdapter() [4/5]

template<typename T >
OpenSim::DelimFileAdapter< T >::DelimFileAdapter ( const std::string &  delimitersRead,
const std::string &  delimterWrite 
)

Create the adapter by setting the delimiters.

◆ DelimFileAdapter() [5/5]

template<typename T >
OpenSim::DelimFileAdapter< T >::DelimFileAdapter ( const std::string &  delimitersRead,
const std::string &  delimterWrite,
const std::string &  compDelimRead,
const std::string &  compDelimWrite 
)

Create the adapter by setting the delimiters.

Member Function Documentation

◆ clone()

template<typename T >
DelimFileAdapter< T > * OpenSim::DelimFileAdapter< T >::clone ( ) const
overridevirtual

Implements OpenSim::DataAdapter.

Reimplemented in OpenSim::STOFileAdapter_< T >.

◆ dataTypeName()

template<typename T >
std::string OpenSim::DelimFileAdapter< T >::dataTypeName ( )
inlinestatic

Name of the data type T (template parameter).

◆ extendRead()

template<typename T >
DelimFileAdapter< T >::OutputTables OpenSim::DelimFileAdapter< T >::extendRead ( const std::string &  filename) const
overrideprotectedvirtual

Implementation of the read functionality.

Implements OpenSim::DataAdapter.

◆ extendWrite()

template<typename T >
void OpenSim::DelimFileAdapter< T >::extendWrite ( const InputTables tables,
const std::string &  filename 
) const
overrideprotectedvirtual

Implementation of the write functionality.

Implements OpenSim::DataAdapter.

Referenced by OpenSim::STOFileAdapter_< T >::write().

◆ operator=() [1/2]

template<typename T>
DelimFileAdapter& OpenSim::DelimFileAdapter< T >::operator= ( const DelimFileAdapter< T > &  )
default

◆ operator=() [2/2]

template<typename T>
DelimFileAdapter& OpenSim::DelimFileAdapter< T >::operator= ( DelimFileAdapter< T > &&  )
default

◆ readElems()

template<typename T >
SimTK::RowVector_< T > OpenSim::DelimFileAdapter< T >::readElems ( const std::vector< std::string > &  tokens) const
inlineprotected

Read elements of type T (template parameter) from a sequence of tokens.

◆ tableString()

template<typename T >
const std::string OpenSim::DelimFileAdapter< T >::tableString ( )
static

Key used for table associative array returned/accepted by write/read.

◆ writeElem()

template<typename T>
void OpenSim::DelimFileAdapter< T >::writeElem ( std::ostream &  stream,
const T &  elem,
const unsigned &  prec 
) const
inlineprotected

Write an element of type T (template parameter) to stream with the specified precision.


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