class oemolostream : public oemolstreambase
The oemolostream class provides a stream-like abstraction for writing molecules to files, streams or standard output. The oemolostream maintains the format and flavor of the writer used when writing molecules. The oemolostream is capable of compressing gzip files while writing.
The following methods are publicly inherited from oemolstreambase:
Creates a new oemolostream object 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 existing oeostream object. 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 destroyed.
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
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 OEFormat namespace.
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
The oemolostream constructors
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
the OEFormat namespace.
By default, when writing to standard output, the associated
file format is
The file format property of an oemolistream
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)
Allows the oemolostream to be opened for writing to a buffer and specify the initial contents of the buffer.
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 oemolostream
object is determined implicitly from the file extension used to
open the stream for writing.
The current ‘gz’ property of the oemolostream
object can be retrieved using the
Closes the oemolostream object. This method may be safely called multiple times.
bool openstring() bool openstring(bool gzip)
Allows the 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 the oemolostream object to compress the contents of the in-memory buffer.
oemolostream &put(char c)
oemolostream &write(const char *str, oesize_t size)