Poco

class LineEndingConverterStreamBuf

Library: Foundation
Package: Streams
Header: Poco/LineEndingConverter.h

Description

This stream buffer performs line ending conversion on text streams. The converter can convert from and to the Unix (LF), Mac (CR) and DOS/Windows/Network (CF-LF) endings.

Any newline sequence in the source will be replaced by the target newline sequence.

Inheritance

Direct Base Classes: UnbufferedStreamBuf

All Base Classes: UnbufferedStreamBuf

Member Summary

Member Functions: getNewLine, readFromDevice, setNewLine, writeToDevice

Constructors

LineEndingConverterStreamBuf

LineEndingConverterStreamBuf(
    std::istream & istr
);

Creates the LineEndingConverterStreamBuf and connects it to the given input stream.

LineEndingConverterStreamBuf

LineEndingConverterStreamBuf(
    std::ostream & ostr
);

Creates the LineEndingConverterStreamBuf and connects it to the given output stream.

Destructor

~LineEndingConverterStreamBuf

~LineEndingConverterStreamBuf();

Destroys the LineEndingConverterStream.

Member Functions

getNewLine

const std::string & getNewLine() const;

Returns the line ending currently in use.

setNewLine

void setNewLine(
    const std::string & newLineCharacters
);

Sets the target line ending for the converter.

Possible values are:

  • NEWLINE_DEFAULT (whatever is appropriate for the current platform)
  • NEWLINE_CRLF (Windows),
  • NEWLINE_LF (Unix),
  • NEWLINE_CR (Macintosh)

In theory, any character sequence can be used as newline sequence. In practice, however, only the above three make sense.

readFromDevice protected

int readFromDevice();

writeToDevice protected

int writeToDevice(
    char c
);