TextInputSource Class Reference

#include <Pt/Xml/InputSource.h>

Text input source for the XML reader. More...

Inherits InputSource.

Inherited by StringInputSource.

Public Member Functions

 TextInputSource ()
 Construct an empty TextInputSource.
 
 TextInputSource (std::basic_istream< Char > &is)
 Construct with input stream.
 
 ~TextInputSource ()
 Destructor.
 
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 reset ()
 Resets the input source and removes the input stream.
 
void reset (std::basic_istream< Char > &ios)
 Resets the input source to begin reading from a stream.
 
void setId (const Pt::String &id)
 Sets the ID.
 
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 ()
 Returns the next character or EOF.
 
const Pt::StringonId () const
 Returns the ID of the input stream.
 
virtual std::streamsize onImport ()
 Refills the stream buffer.
 
virtual bool onImportText ()
 Refill the character buffer.
 

Detailed Description

This input source can read characters from an unicode based input stream, so it does not convert the encoding, but only parses the XML declaration.

Member Function Documentation

std::streamsize import ( )
inherited

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 
)
protectedinherited

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.