You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qt3/doc/html/qxmlinputsource.html

194 lines
10 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/xml/qxml.cpp:892 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QXmlInputSource Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QXmlInputSource Class Reference<br><small>[<a href="xml.html">XML module</a>]</small></h1>
<p>The QXmlInputSource class provides the input data for the
QXmlReader subclasses.
<a href="#details">More...</a>
<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
<p><tt>#include &lt;<a href="qxml-h.html">qxml.h</a>&gt;</tt>
<p><a href="qxmlinputsource-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QXmlInputSource"><b>QXmlInputSource</b></a> ()</li>
<li class=fn><a href="#QXmlInputSource-2"><b>QXmlInputSource</b></a> ( QIODevice&nbsp;*&nbsp;dev )</li>
<li class=fn>QXmlInputSource ( QFile&nbsp;&amp;&nbsp;file ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>QXmlInputSource ( QTextStream&nbsp;&amp;&nbsp;stream ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>virtual <a href="#~QXmlInputSource"><b>~QXmlInputSource</b></a> ()</li>
<li class=fn>virtual void <a href="#setData"><b>setData</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dat )</li>
<li class=fn>virtual void <a href="#setData-2"><b>setData</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;dat )</li>
<li class=fn>virtual void <a href="#fetchData"><b>fetchData</b></a> ()</li>
<li class=fn>virtual QString <a href="#data"><b>data</b></a> ()</li>
<li class=fn>virtual QChar <a href="#next"><b>next</b></a> ()</li>
<li class=fn>virtual void <a href="#reset"><b>reset</b></a> ()</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual QString <a href="#fromRawData"><b>fromRawData</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;data, bool&nbsp;beginning = FALSE )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The QXmlInputSource class provides the input data for the
<a href="qxmlreader.html">QXmlReader</a> subclasses.
<p>
<p> All subclasses of QXmlReader read the input XML document from this
class.
<p> This class recognizes the encoding of the data by reading the
encoding declaration in the XML file if it finds one, and reading
the data using the corresponding encoding. If it does not find an
encoding declaration, then it assumes that the data is either in
UTF-8 or UTF-16, depending on whether it can find a byte-order
mark.
<p> There are two ways to populate the input source with data: you can
construct it with a <a href="qiodevice.html">QIODevice</a>* so that the input source reads the
data from that device. Or you can set the data explicitly with one
of the <a href="#setData">setData</a>() functions.
<p> Usually you either construct a QXmlInputSource that works on a
QIODevice* or you construct an empty QXmlInputSource and set the
data with setData(). There are only rare occasions where you would
want to mix both methods.
<p> The QXmlReader subclasses use the <a href="#next">next</a>() function to read the
input character by character. If you want to start from the
beginning again, use <a href="#reset">reset</a>().
<p> The functions <a href="#data">data</a>() and <a href="#fetchData">fetchData</a>() are useful if you want to do
something with the data other than parsing, e.g. displaying the
raw XML file. The benefit of using the QXmlInputClass in such
cases is that it tries to use the correct encoding.
<p> <p>See also <a href="qxmlreader.html">QXmlReader</a>, <a href="qxmlsimplereader.html">QXmlSimpleReader</a>, and <a href="xml-tools.html">XML</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QXmlInputSource"></a>QXmlInputSource::QXmlInputSource ()
</h3>
Constructs an input source which contains no data.
<p> <p>See also <a href="#setData">setData</a>().
<h3 class=fn><a name="QXmlInputSource-2"></a>QXmlInputSource::QXmlInputSource ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;dev )
</h3>
Constructs an input source and gets the data from device <em>dev</em>.
If <em>dev</em> is not open, it is opened in read-only mode. If <em>dev</em>
is 0 or it is not possible to read from the device, the input
source will contain no data.
<p> <p>See also <a href="#setData">setData</a>(), <a href="#fetchData">fetchData</a>(), and <a href="qiodevice.html">QIODevice</a>.
<h3 class=fn><a name="QXmlInputSource-3"></a>QXmlInputSource::QXmlInputSource ( <a href="qfile.html">QFile</a>&nbsp;&amp;&nbsp;file )
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Constructs an input source and gets the data from the file <em>file</em>. If the
file cannot be read the input source is empty.
<h3 class=fn><a name="QXmlInputSource-4"></a>QXmlInputSource::QXmlInputSource ( <a href="qtextstream.html">QTextStream</a>&nbsp;&amp;&nbsp;stream )
</h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Constructs an input source and gets the data from the text stream <em>stream</em>.
<h3 class=fn><a name="~QXmlInputSource"></a>QXmlInputSource::~QXmlInputSource ()<tt> [virtual]</tt>
</h3>
Destructor.
<h3 class=fn><a href="qstring.html">QString</a> <a name="data"></a>QXmlInputSource::data ()<tt> [virtual]</tt>
</h3>
Returns the data the input source contains or <a href="qstring.html#QString-null">QString::null</a> if the
input source does not contain any data.
<p> <p>See also <a href="#setData">setData</a>(), <a href="#QXmlInputSource">QXmlInputSource</a>(), and <a href="#fetchData">fetchData</a>().
<h3 class=fn>void <a name="fetchData"></a>QXmlInputSource::fetchData ()<tt> [virtual]</tt>
</h3>
This function reads more data from the device that was set during
construction. If the input source already contained data, this
function deletes that data first.
<p> This object contains no data after a call to this function if the
object was constructed without a device to read data from or if
this function was not able to get more data from the device.
<p> There are two occasions where a fetch is done implicitly by
another function call: during construction (so that the object
starts out with some initial data where available), and during a
call to <a href="#next">next</a>() (if the data had run out).
<p> You don't normally need to use this function if you use next().
<p> <p>See also <a href="#data">data</a>(), <a href="#next">next</a>(), and <a href="#QXmlInputSource">QXmlInputSource</a>().
<h3 class=fn><a href="qstring.html">QString</a> <a name="fromRawData"></a>QXmlInputSource::fromRawData ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;data, bool&nbsp;beginning = FALSE )<tt> [virtual protected]</tt>
</h3>
This function reads the XML file from <em>data</em> and tries to
recognize the encoding. It converts the raw data <em>data</em> into a
<a href="qstring.html">QString</a> and returns it. It tries its best to get the correct
encoding for the XML file.
<p> If <em>beginning</em> is TRUE, this function assumes that the data
starts at the beginning of a new XML document and looks for an
encoding declaration. If <em>beginning</em> is FALSE, it converts the
raw data using the encoding determined from prior calls.
<h3 class=fn><a href="qchar.html">QChar</a> <a name="next"></a>QXmlInputSource::next ()<tt> [virtual]</tt>
</h3>
Returns the next character of the input source. If this function
reaches the end of available data, it returns
QXmlInputSource::EndOfData. If you call <a href="#next">next</a>() after that, it
tries to fetch more data by calling <a href="#fetchData">fetchData</a>(). If the
fetchData() call results in new data, this function returns the
first character of that data; otherwise it returns
QXmlInputSource::EndOfDocument.
<p> <p>See also <a href="#reset">reset</a>(), <a href="#fetchData">fetchData</a>(), <a href="qxmlsimplereader.html#parse">QXmlSimpleReader::parse</a>(), and <a href="qxmlsimplereader.html#parseContinue">QXmlSimpleReader::parseContinue</a>().
<h3 class=fn>void <a name="reset"></a>QXmlInputSource::reset ()<tt> [virtual]</tt>
</h3>
This function sets the position used by <a href="#next">next</a>() to the beginning of
the data returned by <a href="#data">data</a>(). This is useful if you want to use the
input source for more than one parse.
<p> <p>See also <a href="#next">next</a>().
<p>Example: <a href="tagreader-with-features-example.html#x1975">xml/tagreader-with-features/tagreader.cpp</a>.
<h3 class=fn>void <a name="setData"></a>QXmlInputSource::setData ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dat )<tt> [virtual]</tt>
</h3>
Sets the data of the input source to <em>dat</em>.
<p> If the input source already contains data, this function deletes
that data first.
<p> <p>See also <a href="#data">data</a>().
<h3 class=fn>void <a name="setData-2"></a>QXmlInputSource::setData ( const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;dat )<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> The data <em>dat</em> is passed through the correct text-codec, before
it is set.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>