PDB record fields

namespace mdk
namespace pdb

Enums

enum Mode

A mode enum, which modifies how to position and parse strings. Note: most enums in the program are enum classes; here we need a standard enum in order for combining via | to work

Values:

enumerator Exact

Beginning of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

enumerator Trim

When parsing, the final value is a trimmed string read from the line.

enumerator Left

When writing, the string is written left-aligned in the line.

enumerator Right

When writing, the string is written right-aligned in the line.

class Field
#include <Field.hpp>

An object representing a single field of a PDB record, along with the means of parsing and printing it. The field objects signal parsing failure by throwing.

Subclassed by mdk::pdb::Char, mdk::pdb::Integer, mdk::pdb::Literal, mdk::pdb::Real, mdk::pdb::String, mdk::pdb::SymOp

Public Functions

virtual void read(const std::string &s) = 0

Read the value from a string (usually a line of a PDB file).

Parameters

sString to read the value from.

virtual void write(std::string &s) const = 0

Write the value to a string (usually a line of a PDB file). Overflows are handled depending on the type of field.

Parameters

sString to write the value to.

class Integer : public mdk::pdb::Field
#include <Field.hpp>

Integer field.

Public Functions

inline Integer(int i, int j, int &v, int offset = 0)
virtual void read(const std::string &s) override

Read the value from a string (usually a line of a PDB file).

Parameters

sString to read the value from.

virtual void write(std::string &s) const override

Write the value to a string (usually a line of a PDB file). Overflows are handled depending on the type of field.

Parameters

sString to write the value to.

Private Members

int i

Beginning of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

int j

End of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

int offset

A value that is added to the read value and subtracted when a value is written. It’s chiefly used to convert 0-indexed ordinals to 1-indexed and vice versa.

int *v

A pointer to the integer to save the value to and load the value from. It allows us in particular to have the same field class for many different PDB records, only having to provide different pointer to the underlying value.

class Real : public mdk::pdb::Field
#include <Field.hpp>

Real (floating number) field.

Public Functions

inline Real(int i, int j, int n, int m, double &v, double scalar = 1.0)
virtual void read(const std::string &s) override

Read the value from a string (usually a line of a PDB file).

Parameters

sString to read the value from.

virtual void write(std::string &s) const override

Write the value to a string (usually a line of a PDB file). Overflows are handled depending on the type of field.

Parameters

sString to write the value to.

Private Members

int i

Beginning of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

int j

End of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

int n

Width of the read real number. Follows the conventions from the PDB format docs and Fortran specifiers (it’s n in f{n}.{m})

int m

Precision of the read real number. Follows the conventions from the PDB format docs and Fortran specifiers (it’s m in f{n}.{m})

double *v

A pointer to the double to save the value to and load the value from. It allows us in particular to have the same field class for many different PDB records, only having to provide different pointer to the underlying value.

double scalar

Scalar by which to multiply a read value and divide a written value. In particular, it allows us to convert PDB file formats to internal units and back.

class String : public mdk::pdb::Field
#include <Field.hpp>

String field. By default read values are trimmed, and written values are right-aligned.

Public Functions

inline String(int i, int j, std::string &v, int8_t mode = Trim | Right)
virtual void read(const std::string &s) override

Read the value from a string (usually a line of a PDB file).

Parameters

sString to read the value from.

virtual void write(std::string &s) const override

Write the value to a string (usually a line of a PDB file). Overflows are handled depending on the type of field.

Parameters

sString to write the value to.

Private Members

int i

Beginning of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

int j

End of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

std::string *v

A pointer to the string to save the value to and load the value from. It allows us in particular to have the same field class for many different PDB records, only having to provide different pointer to the underlying value.

int8_t mode

Mode of string parsing and writing. See Mode for details.

class Char : public mdk::pdb::Field
#include <Field.hpp>

(Single) character field.

Public Functions

inline Char(int i, char &v)
virtual void read(const std::string &s) override

Read the value from a string (usually a line of a PDB file).

Parameters

sString to read the value from.

virtual void write(std::string &s) const override

Write the value to a string (usually a line of a PDB file). Overflows are handled depending on the type of field.

Parameters

sString to write the value to.

Private Members

int i

The location of the character in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

char *v

A pointer to the character to save the value to and load the value from. It allows us in particular to have the same field class for many different PDB records, only having to provide different pointer to the underlying value.

class SymOp : public mdk::pdb::Field
#include <Field.hpp>

“Symmetry operator” field. At the moment it’s parsed just like a normal string.

Public Functions

inline SymOp(int i, int j, std::string &v)
virtual void read(const std::string &s) override

Read the value from a string (usually a line of a PDB file).

Parameters

sString to read the value from.

virtual void write(std::string &s) const override

Write the value to a string (usually a line of a PDB file). Overflows are handled depending on the type of field.

Parameters

sString to write the value to.

Private Members

int i

Beginning of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

int j

End of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

std::string *v

A pointer to the string to save the value to and load the value from. It allows us in particular to have the same field class for many different PDB records, only having to provide different pointer to the underlying value.

class Literal : public mdk::pdb::Field
#include <Field.hpp>

A literal. As opposed to a normal field, here there’s no reading or writing values by pointers, rather comparing the read value with the literal and printing out the literal. It’s chiefly used for parsing the record headers, like “ATOM ” or “MODEL “.

Public Functions

inline Literal(int i, int j, std::string lit)
virtual void read(const std::string &s) override

Read the value from a string (usually a line of a PDB file).

Parameters

sString to read the value from.

virtual void write(std::string &s) const override

Write the value to a string (usually a line of a PDB file). Overflows are handled depending on the type of field.

Parameters

sString to write the value to.

Private Members

int i

Beginning of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

int j

End of the field in the line. Inclusive and 1-indexed, as in the PDB format docs, in order to make writing new fields easier.

std::string lit

Literal to compare the read value with and print out to the line when writing.