oemolostream
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:
Constructors
oemolostream() -> oemolostream
Creates a new oemolostream object that is connected to standard output.
oemolostream(name: str) -> oemolostream
oemolostream(fn: str) -> oemolostream
Creates a new oemolostream object and opens the file specified by the given name (‘fname’).
oemolostream(arg2: oeostream, owned: bool = True) -> oemolostream
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.
Warning
Only in C++ can an oemolostream object own an existing oeostream object.
Usage in Python
i = oechem.oeostream()
owned = True
ofs = oechem.oemolostream(i, not owned)
See also
To associate a file or a stream with an
oemolostream after it has been created, see the
oemolstreambase.open method.
operator bool
IsValid() -> bool
GetString
std::string GetString(void)
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.
SetFlavor
SetFlavor(format: int, flavor: int) -> bool
Sets the file flavor for a given format associated with the
oemolostream object.
The set of valid formats are defined int the
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.
SetFormat
SetFormat(format: int) -> bool
Sets the file format associated with the
oemolostream object.
The set of valid formats are defined in the
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.
Note
The file format property is also set automatically by
oemolstreambase.open based upon the file
extension of the specified filename.
SetString
SetString(c: str) -> None
SetString(c: str, size: oesize_t) -> None
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.
Setgz
Setgz(gz: bool, sptr: oeostream = None, arg4: bool = False) -> bool
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.
close
close() -> None
Closes the oemolostream object. This method may be safely called multiple times.
flush
flush() -> oemolostream
openstring
openstring() -> bool
openstring(gzip: bool) -> bool
Allows the oemolostream to write to a buffer in memory, instead of to a file or standard output.
Calling oemolostream.openstring instructs the
oemolostream object to start accumulating
output in a buffer, which can later be retrieved by calling the
oemolostream.GetString method.
The form that accepts a ‘gzip’ argument can be used to instruct the oemolostream object to compress the contents of the in-memory buffer.
put
put(c: str) -> oemolostream
tell
tell() -> oefpos_t
write
write(str: str, size: oesize_t) -> oemolostream