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()
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.
Warning
Only in C++ can an oemolostream object own an existing oeostream object.
See also
To associate a file or a stream with an
oemolostream after it has been created, see the
oemolstreambase::open
method.
operator bool¶
operator bool() const
operator OEPlatform::oeostream &¶
operator OEPlatform::oeostream &() const
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¶
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
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¶
bool SetFormat(unsigned int format)
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¶
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.
Setgz¶
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.
close¶
void close()
Closes the oemolostream object. This method may be safely called multiple times.
flush¶
oemolostream &flush()
openstring¶
bool openstring()
bool openstring(bool gzip)
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¶
oemolostream &put(char c)
tell¶
oefpos_t tell()
write¶
oemolostream &write(const char *str, oesize_t size)