File classes

The File classes provide abstraction of the IO operation, allowing for the same format to be used with on-disk files, network files, memory-mapped files, compressed files, etc.

Interface for files

class chemfiles::File

Abstract base class for file representation.

Subclassed by chemfiles::final< F >, chemfiles::final< F >, chemfiles::TextFile

Public Types

enum Mode

Possible modes for opening a file.

Values:

READ = 'r'

Open in read-only mode.

WRITE = 'w'

Open in read-write mode, and replace the file if it is already present.

APPEND = 'a'

Open in read-write mode, and append new data at the end of the file.

Public Functions

const std::string &filename() const

File name, i.e. complete path to this file on disk.

Mode mode() const

File opening mode.

class chemfiles::TextFile

Abstract base class representing a text file. This class is inteded to be inherited by any form of text files: compressed files, memory-mapped files, etc.

Inherits from chemfiles::File

Subclassed by chemfiles::final< F >

Public Functions

virtual std::string readline() = 0

Read a line from the file.

virtual std::vector<std::string> readlines(size_t n) = 0

Read `n` lines from the file.

virtual void rewind() = 0

Reset the file cursor.

virtual bool eof() = 0

Are we at the end of the file ?

Public Static Functions

std::unique_ptr<TextFile> create(const std::string &path, File::Mode mode)

Open the most adaptated text file class for the given `path` and `mode`.

Implemented classes

These classes implement the File interface defined previously.

Warning

doxygenclass: Cannot find class “chemfiles::BasicFile” in doxygen xml output for project “chemfiles” from directory: /home/travis/build/chemfiles/chemfiles/build/doc/doxygen/xml

Warning

doxygenclass: Cannot find class “chemfiles::NcFile” in doxygen xml output for project “chemfiles” from directory: /home/travis/build/chemfiles/chemfiles/build/doc/doxygen/xml

Warning

doxygenclass: Cannot find class “chemfiles::TNGFile” in doxygen xml output for project “chemfiles” from directory: /home/travis/build/chemfiles/chemfiles/build/doc/doxygen/xml