#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 () |
| Destructor. | |
| std::size_t | line () const |
| Current line count. | |
| void | setLine (std::size_t n) |
| Sets the current line count. | |
| std::streamsize | import () |
| Import available bytes into buffer. More... | |
| int_type | get () |
| Returns the next character or EOF. | |
| const XmlDeclaration * | declaration () const |
| Returns the XML declaration or a nullptr if none was read. | |
| const Pt::String & | id () const |
| Returns the ID of the input stream. | |
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 std::streamsize | onImport ()=0 |
| Refills the stream buffer. | |
| virtual int_type | onGet ()=0 |
| Returns the next character or EOF. | |
| virtual const Pt::String & | onId () const =0 |
| Returns the ID of the input stream. | |
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.
| 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.
|
protected |
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.