InputSource Class Referenceabstract

#include <Pt/Xml/InputSource.h>

Input source for the XML reader. More...

Inherits NonCopyable.

Inherited by BinaryInputSource, NullInputSource, and TextInputSource.

Public Member Functions

 InputSource ()
 Construct an empty InputSource.
virtual ~InputSource ()
const XmlDeclarationdeclaration () const
 Returns the XML declaration or a nullptr if none was read.
int_type get ()
 Returns the next character or EOF.
const Pt::Stringid () const
 Returns the ID of the input stream.
std::streamsize import ()
 Import available bytes into buffer. More...
std::size_t line () const
 Current line count.
void setLine (std::size_t n)
 Sets the current line count.

Protected Member Functions

void init (std::basic_streambuf< Char > *rdbuf=0, XmlDeclaration *decl=0)
 Initialize to use an input buffer and XML declaration. More...
virtual int_type onGet ()=0
 Returns the next character or EOF.
virtual const Pt::StringonId () const =0
 Returns the ID of the input stream.
virtual std::streamsize onImport ()=0
 Refills the stream buffer.

Detailed Description

The InputSource allows the XML readers to read input as an unicode character stream. It converts the encoding, if required, and supports blocking and non-blocking operation. Line information and the XML or text declaration are provided by each input source. Input sources are not only used for the main document, but also for entites and external DTD subsets.

Member Function Documentation

std::streamsize import ( )

If no more characters can be read directly from the input stream buffer without blocking read operations, the virtual method onInput() is called. The number of available characters is returned, which can be 0 if no data is available.

void init ( std::basic_streambuf< Char > *  rdbuf = 0,
XmlDeclaration decl = 0 

The derived input sources must call this method once the XML or text declaration is parsed or if none was found. Normally, this is done in the virtual methods onGet() and onImport(), which are called by the public interface methods get() and import() when no buffer was set yet. The passed buffer and declaration are owned by the derived class.