Module: XML Streams Package: XML Streams
RWTParsedTransformInputStreamImp FilteredInputStreamImp
#include <rw/xmlstreams/RWTParsedTransformInputStreamImp.h>
The class RWTParsedTransformInputStreamImp implements a buffer that can be used with any kind of input stream. The size of the buffer is specified as a parameter to the static make() function that is used to create it. If the buffer as initialized is not large enough to contain the entire XML document, it grows as needed to be able to do so. It is more efficient, though, to allocate a buffer of sufficient size initially.
RWTParsedTransformInputStreamImp is a class template that is derived from one of its own template parameters.
The class is defined as
template <class InputStream, class FilteredInputStreamImp, class Transform, class Traits> class RWTParsedTransformInputStreamImp : public FilteredInputStreamImp { ... };
typedef InputStream RWInputStream_type; typedef typename InputStream::element_type element_type; typedef RWCString string_type;
static InputStream make(const InputStream& sourceStream, Transform transform);
Constructs an RWTParsedTransformInputStreamImp instance that uses sourceStream as its source of elements, and returns a handle to it. The internal buffer is initialized to be of size RW_STREAM_BUFFER_SIZE, which is defined as 512 bytes. The buffer grows as needed to contain the entire XML document.
The parameter sourceStream is the input stream that serves as the source of elements.
The parameter transform is the transformation object and must provide a public interface of transform(RWXmlStreamElement&).
static InputStream make(const InputStream& sourceStream, Transform transform, RWSize bufSize);
Constructs an RWTParsedTransformInputStreamImp instance that uses sourceStream as its source of elements, and returns a handle to it. The internal buffer is initialized to be of size bufSize. The buffer grows as needed to contain the entire XML document.
The parameter sourceStream is the input stream that serves as the source of elements.
The parameter transform is the transformation object and must provide a public interface of transform(RWXmlStreamElement&).
The parameter bufSize is the initial buffer capacity in number of elements.
static InputStream make(const InputStream& sourceStream, Transform transform, element_type* buffer, RWSize bufSize);
Constructs an RWTParsedTransformInputStreamImp instance that uses sourceStream as its source of elements, and returns a handle to it. The internal buffer is initialized using a pre-allocated element array of size bufSize. The buffer grows as needed to contain the entire XML document.
The parameter sourceStream is the input stream that serves as the source of elements.
The parameter transform is the transformation object and must provide a public interface of transform(RWXmlStreamElement&).
The parameter buffer is a pre-allocated buffer of size bufSize to be used internally by the constructed RWTParsedTransformInputStreamImp object.
The parameter bufSize is the initial buffer capacity in number of elements.
virtual ~RWTParsedTransformInputStreamImp();
Virtual destructor. Throws no exceptions.
virtual RWSize available() const;
Returns the number of characters that can be read from the stream without blocking. Throws no exceptions.
virtual bool isEof() const;
Returns true if no character can be obtained from the input sequence, otherwise false. Throws no exceptions.
virtual bool isBad() const;
Returns true if the input stream is in bad state, otherwise false. Throws no exceptions.
virtual bool isFail() const;
Returns true if the input stream is in fail state, otherwise false. Throws no exceptions.
virtual bool isGood() const;
Returns false if the input stream is in fail or bad state, otherwise true. Throws no exceptions.
virtual element_type read();
Reads a single element from the input stream.
virtual RWSize read(element_type* array, RWSize num);
Reads an array of elements from the input stream. Returns the actual number of elements read.
array |
a pointer to the beginning of the array used to store the input. The array must have been pre-allocated to contain at least num elements. |
num |
the number of elements to be read from the stream |
virtual RWSize readUntil(element_type* array, RWSize maxSize, element_type delim);
Reads elements until the last element read is equivalent to delim, maxSize elements have been read, or the end of the input sequence is reached. The elements read are stored in array. The function returns the actual number of elements read from the stream.
The parameter array is a pointer to the beginning of the element array holding the elements extracted from the stream.
The parameter maxSize is the maximum number of elements to be read.
The parameter delim is the element value used as the delimiter.
virtual RWSize skip(RWSize numUnits);
Skips numUnits elements from the input sequence if possible. The function returns the actual number of elements skipped, which can be any value between 0 and numUnits.
numUnits |
the number of elements to be skipped |
RWTParsedTransformInputStreamImp(const InputStream& sourceStream, Transform transform);
Initializes the reference to the input stream used as the source of elements, as well as the internal buffer, whose capacity is set equal to RW_STREAM_BUFFER_SIZE, defined as 512 bytes.
The parameter sourceStream is the input stream that serves as the source of elements.
The parameter transform is the transformation object and must provide a public interface of transform(RWXmlStreamElement&).
RWTParsedTransformInputStreamImp(const InputStream& sourceStream, Transform transform, RWSize bufSize);
Initializes the reference to the input stream used as the source of elements, and the internal buffer, whose capacity is set to bufSize.
The parameter sourceStream is the input stream that serves as the source of elements.
The parameter transform is the transformation object and must provide a public interface of transform(RWXmlStreamElement&).
The parameter bufSize is the buffer capacity in number of elements.
RWTParsedTransformInputStreamImp(const InputStream& sourceStream, Transform transform, element_type* buffer, RWSize bufSize);
Initializes the reference to the input stream used as the source of elements, and the internal buffer, which is initialized using a pre-allocated element's array of size bufSize.
The parameter sourceStream is the input stream that serves as the source of elements.
The parameter transform is the transformation object and must provide a public interface of transform(RWXmlStreamElement&).
The parameter buffer is a pre-allocated buffer of size bufSize to be used internally by the constructed RWTParsedTransformInputStreamImp object.
The parameter bufSize is the buffer capacity in number of elements.
element_type* eback() const;
Returns a pointer to the first element in the input buffer array. Throws no exceptions.
element_type* ebuf() const;
Returns a pointer one position past the end of the input buffer array. Throws no exceptions.
element_type* egptr() const;
Returns a pointer one position past the last element in the input sequence. Throws no exceptions.
void freeBuffer();
Frees the memory allocated to the internal buffer, if necessary. Throws no exceptions.
void gbump(RWSize n);
Moves the input buffer array pointer n positions forward. The array position now pointed to is the one returned by gptr(). Throws no exceptions.
element_type* gptr() const;
Returns a pointer to the current position in the buffered input sequence. Throws no exceptions.
void putBack(element_type cur);
Puts back one element, so it will be available for the next read. The parameter cur is the element to be put back.
element_type readAttribute(element_type cur, string_type& token);
Reads in an entire attribute (name and value). The parameter cur holds the current character. The parameter token will contain the attribute string, or RWCString() if no attribute is available. Returns the last character read.
element_type readAttributes(element_type cur, RWXmlStreamElement& element);
Reads all attributes in an element. The parameter cur holds the current character. The parameter element will have the attributes added to it. Returns the last character read.
element_type readAttributeValue(element_type cur, string_type& token);
Reads in an attribute value. The parameter cur holds the current character. The parameter token will contain the value without quotes, or RWCString() if no value is available. Returns the last character read.
RWXmlStreamElement readNextElement(element_type& cur,
const RWXmlStreamElement& parent);
Reads the next XML element. The parameter cur holds the current character. The parameter parent holds the current element (the parent of the one to read). Returns the parsed element.
element_type readOne();
Reads one character from the input and returns the next character.
element_type readToClose(element_type cur, string_type& token);
Reads past the closing tag of the current element. The parameter cur holds the current character. The parameter token will contain any data read before the closing tag. Returns the last character read.
element_type readToken(element_type cur, string_type& token);
Reads a token. The parameter cur holds the current character. The parameter token will be returned with the token. Returns the last character read.
element_type readValue(element_type cur, RWXmlStreamElement& element);
Reads all values in an element. The parameter cur holds the current character. The parameter element will have the values added to it, including nested elements. Returns the last character read.
element_type readWholeName(element_type cur, string_type& token);
Reads everything to the next > character. The parameter cur holds the current character. The parameter token will contain any data read before the > character. Returns the last character read.
void setBufferEnd(element_type* gend_arg);
Sets the buffer's end pointer. Assigns the parameter value to gend_. Throws no exceptions.
void setg(element_type* gbeg_arg, element_type* gcur_arg, element_type* gend_arg);
Assigns the parameter values to gbeg_, gnext_, and gend_ respectively. These data members represent the beginning of the buffer array, the current position in the array, and the end of the array. Throws no exceptions.
void transform();
Parses the XML input and applies the transformation.
bool underflow();
Fills the input buffer. Throws no exceptions.
Returns true if there are elements available, otherwise false.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.