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 oemolostream object. The oemolostream object must previously have been opened for writing to an in-memory buffer using the oemolostream.openstring method.
bool SetFlavor(unsigned int format, unsigned int flavor)
Sets the file flavor for a given format associated with the oemolostream object. The set of valid formats are defined int the OEFormat namespace. The set of valid bitmasks flavors are defined in the OEOFlavor namespace. The current flavor can be queried using the oemolstreambase.GetFlavor method. Each format has its own specific flavor which must be set separately. The oemolostream constructors calls the OESetDefaultFlavors function 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 oemolostream object. The set of valid formats are defined in the OEFormat namespace. By default, when writing to standard output, the associated file format is OEFormat_SMI. The file format property of an oemolistream may be retrieved using the oemolstreambase.GetFormat method.
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 oemolostream.GetString method.
bool Setgz(bool gz, OEPlatform::oeostream *sptr=0, bool=false)
Specifies that the contents of the oemolostream object should be GNU gzip compressed 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 oemolstreambase.Getgz method.
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)