PTypes: streams: outstm

Top: Streams: outstm

>     #include <pstreams.h>

>     class outstm: iobase {
>         void putf(const char* fmt, ...);
>         void put(char);
>         void put(string);
>         void puteol();
>         void putline(string);
>         int  write(const char* buf, int count);
>         void flush();
>         bool get/set_flusheol(bool);
>     }

This class implements the basic functionality of output streams. Outstm is derived from iobase and inherits all its public methods and properties.

End-of-line sequences are not translated when you send data through the output methods. To write an end-of-line sequence appropriate to the given operating environment use puteol() instead.

void outstm::putf(const char* fmt, ...) is a printf-style output method. PTypes supports a subset of format specifiers common to all platforms: <blank>, '#', '+' and '-' formatting flags, 'L', 'h', 'l' and 'll' format modifiers, and the following standard format specifiers: cdiouxXeEfgGps. In addition, PTypes supports a format specifier a for IP addresses (ipaddress type) and also t and T for timestamps (datetime type). Note that some compilers require to explicitly cast ipaddress arguments to long type, and also string arguments to const char* (or pconst).

void outstm::put(char c) writes the character c to the stream.

void outstm::put(string str) writes the string str to the stream.

void outstm::puteol() writes an end-of-line sequence to the stream. The actual sequence depends on the platform the library was compiled on. May flush data if the property flusheol is set to true.

void outstm::putline(string str) writes the string str to the stream followed by an end-of-line sequence, as in call to puteol().

int outstm::write(const char* buf, int count) writes count bytes from the buffer buf to the stream.

void outstm::flush() writes the remaining data in the buffer to the media, if any. This method is called automatically when the stream is being closed.

bool outstm::get/set_flusheol(bool) -- set this property to true if you want each line to be written to the media or communication stream immediately. Default is false.

See also: iobase, instm, Error handling

PTypes home