oemolstreambase

class oemolstreambase

The oemolstreambase is the abstract base class for reading and writing molecules.

The following classes derive from this class:

ClearCSVHeader

void ClearCSVHeader()

Clears out the OECSVHeader object owned by this stream allowing an alternative set of column names to be initialized.

GetBinaryIOHandler

OESystem::OEBinaryIOHandlerBase &GetBinaryIOHandler() const

GetCSVHeader

OECSVHeader &GetCSVHeader()

Returns a reference to the OECSVHeader object owned by this stream. The first molecule read or written to this stream will initialize the OECSVHeader object to the set of SD data tags and the order in which to read or write them.

GetFileName

const std::string &GetFileName() const

Returns the file name used in the previous call to oemolstreambase.open. An empty string is returned if oemolstreambase.open has not been called yet or oemolstreambase.close has been called.

GetFlavor

unsigned int GetFlavor(unsigned int format)

Returns the file flavor associated with the format for the oemolstreambase object. The set of valid formats are defined in the the OEFormat namespace. The set of valid bitmasks flavors of input streams are defined in the OEIFlavor namespace. The set of valid bitmasks flavors of output streams are defined in the OEOFlavor namespace.

The flavor for any format can be set using the oemolstreambase.SetFlavor method. The default flavors are automatically set by the oemolstreambase constructors.

GetFormat

unsigned int GetFormat() const

Returns the file format associated with the output oemolstreambase object. The set of valid formats are defined in the the OEFormat namespace.

By default, when writing to standard output or when reading from standard input the associated file format is OEFormat_SMI.

The file format property can be set using the oemolstreambase.SetFormat method.

Note

The file format property is also set automatically by oemolstreambase.open based upon the file extension of the specified filename.

Getgz

bool Getgz()

Returns whether the stream is writing to or reading from a gzip compressed oemolstreambase.

SetFlavor

bool SetFlavor(unsigned int format, unsigned int flavor)=0

This pure virtual method is designed to set the flavor for a given format associated with an input/output molstream.

SetFormat

bool SetFormat(unsigned int format)=0

This pure virtual method is designed to set the format associated with an input/output molstream.

Note

Setting the molstream format to .gz or .oez when it was previously a different (or default) format re-initializes the OEB handlers in the molstream. This means, any explicit changes to the OEB handlers for the stream should be made after setting the format.

close

void close()

This method clears the OECSVHeader object owned by this stream, and resets the file name returned by oemolstreambase.GetFileName back to an empty string. It is expected that the user will not need to call this method directly, but rely on the following subclass methods to call this function:

open

bool open()

The input molstreams (oemolistream, oemolithread) read from to standard input. The output molstreams (oemolostream, oemolothread) write to standard input. The default file format for both input and output molstreams are OEFormat_SMI. Calling oemolstreambase.open (no arguments) on input or output molstreams will force the stream format to the default OEFormat_SMI and the gzip compression property to false.

bool open(const char *fname)
bool open(const std::string &fname)

In case of an input molstream (oemolistream, oemolithread), this method opens a file , specified by its filename (‘fname’) for reading. The file format property of the input molstream is set based upon the extension of the given filename. If the file extension isn’t recognized, a warning is issued and the existing file format is unchanged. If the filename is appended with .gz, the input molstream will decompress the file on-the-fly when reading. If only a file extension is used as the filename (.oeb.gz), then the standard input is opened with the format specified by the given extensions.

In case of an output molstream (oemolostream, oemolothread), this method creates (or overwrite) a file , specified by its filename (‘fname’) for writing. The file format property of the output molstream is set based upon the extension of the given filename. If the filename is appended with .gz, the output molstream will compress the file on-the-fly when writing. If the file extension isn’t recognized, a warning is issued and the existing file format is unchanged. If only a file extension is used as the filename (.oeb.gz), then the standard output is opened with the format specified by the given extensions.

In case of both input and output molstream, the filename based file format may be overridden by calling oemolstreambase.SetFormat explicitly with the desired file format.