class oemolostream : public oemolstreambase
oemolostream class provides a stream-like
abstraction for writing molecules to files, streams or standard
oemolostream maintains the format and flavor
of the writer used when writing molecules.
oemolostream is capable of
compressing gzip files while writing.
The following methods are publicly inherited from
Creates a new
that is connected to standard output.
oemolostream(const char *fname) oemolostream(const std::string &fname)
Creates a new
oemolostream object and opens
the file specified by the given name (‘fname’).
oemolostream(OEPlatform::oeostream *, bool owned=true)
Creates a new
oemolostream object from the
The second optional argument is used to indicate whether the new
oemolostream now owns the given
oeostream and is therefore responsible for
closing and destroying it when it itself is closed and/or
Usage in Python
i = oechem.oeostream() owned = True ofs = oechem.oemolostream(i, not owned)
operator bool() const
operator OEPlatform::oeostream &¶
operator OEPlatform::oeostream &() const
Returns the contents of the in-memory buffer associated with the
oemolostream object must previously have
been opened for writing to an in-memory buffer using the
bool SetFlavor(unsigned int format, unsigned int flavor)
Sets the file flavor for a given format associated with the
The set of valid formats are defined int the
The set of valid bitmasks flavors are defined in the
The current flavor can be queried using the
Each format has its own specific flavor which must be set
to set the flavors for all of the formats to their default state.
bool SetFormat(unsigned int format)
Sets the file format associated with the
The set of valid formats are defined in the
By default, when writing to standard output, the associated
file format is
The file format property of an
may be retrieved using the
The file format property is also set automatically by
oemolstreambase.open based upon the file
extension of the specified filename.
void SetString(const char *c) void SetString(const unsigned char *c, oesize_t size)
oemolostream to be opened for
writing to a buffer and specify the initial contents of the
The contents of in-memory buffer when writing to a string may be
obtained using the
bool Setgz(bool gz, OEPlatform::oeostream *sptr=0, bool=false)
Specifies that the contents of the
oemolostream object should be GNU gzip
The compression takes place on-the-fly.
Usually the ‘gz’ property of a
object is determined implicitly from the file extension used to
open the stream for writing.
The current ‘gz’ property of the
object can be retrieved using the
This method may be safely called multiple times.
bool openstring() bool openstring(bool gzip)
oemolostream to write to a buffer in
memory, instead of to a file or standard output.
The form that accepts a ‘gzip’ argument can be used to instruct
oemolostream object to compress the contents
of the in-memory buffer.
oemolostream &put(char c)
oemolostream &write(const char *str, oesize_t size)