chemfiles::Trajectory
A Trajectory is a chemistry file on the hard drive. It is the main entry point of the chemfiles library.
A Trajectory is made with a File and a Format. The File implements all the physical operations, while the Format provides a way to interpret the file.
Public Functions
Trajectory
(const std::string & filename, const std::string & mode = "r", const std::string & format = "")Open a file, automatically gessing the file format and type from the extension.
filename
- The file path. In "w"
or "a"
modes, the file is created if it does not exist yet. In “r” mode, and exception is throwed is the file does not exist yet.
format
- Specific format to use. Needed when there is no way to guess the format from the extension of the file, or when this guess would be wrong.
mode
- Opening mode for the file. Default mode is “r” for read. Other supported modes depends on the underlying format and are “w” for write, and “a” for append. “w” mode discard any previously existing file.
operator>>
(Frame & frame)Read operator, in stream version.
read
()Read operator, in method version.
read_step
(const size_t)Read operator, in method version with specific step.
sync
()Synchronize any content in the underlying buffer to the disk.
operator<<
(const Frame & frame)Write operator, in stream version.
write
(const Frame & frame)Write operator, in method version.
topology
(const Topology &)Set a topology to use while writing or reading format where no topological information is present.
topology
(const std::string & filename)Use the topology of the first frame of the following file to read or write all the following files.
cell
(const UnitCell &)Set an unit cell to use while writing or reading format when no information about unit cell is present.
nsteps
() constGet the number of steps (the number of Frames) in this trajectory.
done
() constHave we read all the Frames in this file ?