[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/xml/qxml.cpp:892 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QXmlInputSource Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <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>
|
---|
| 33 |
|
---|
| 34 | <p>The QXmlInputSource class provides the input data for the
|
---|
| 35 | QXmlReader subclasses.
|
---|
| 36 | <a href="#details">More...</a>
|
---|
| 37 | <p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
---|
| 38 | <p><tt>#include <<a href="qxml-h.html">qxml.h</a>></tt>
|
---|
| 39 | <p><a href="qxmlinputsource-members.html">List of all member functions.</a>
|
---|
| 40 | <h2>Public Members</h2>
|
---|
| 41 | <ul>
|
---|
| 42 | <li class=fn><a href="#QXmlInputSource"><b>QXmlInputSource</b></a> ()</li>
|
---|
| 43 | <li class=fn><a href="#QXmlInputSource-2"><b>QXmlInputSource</b></a> ( QIODevice * dev )</li>
|
---|
| 44 | <li class=fn>QXmlInputSource ( QFile & file ) <em>(obsolete)</em></li>
|
---|
| 45 | <li class=fn>QXmlInputSource ( QTextStream & stream ) <em>(obsolete)</em></li>
|
---|
| 46 | <li class=fn>virtual <a href="#~QXmlInputSource"><b>~QXmlInputSource</b></a> ()</li>
|
---|
| 47 | <li class=fn>virtual void <a href="#setData"><b>setData</b></a> ( const QString & dat )</li>
|
---|
| 48 | <li class=fn>virtual void <a href="#setData-2"><b>setData</b></a> ( const QByteArray & dat )</li>
|
---|
| 49 | <li class=fn>virtual void <a href="#fetchData"><b>fetchData</b></a> ()</li>
|
---|
| 50 | <li class=fn>virtual QString <a href="#data"><b>data</b></a> ()</li>
|
---|
| 51 | <li class=fn>virtual QChar <a href="#next"><b>next</b></a> ()</li>
|
---|
| 52 | <li class=fn>virtual void <a href="#reset"><b>reset</b></a> ()</li>
|
---|
| 53 | </ul>
|
---|
| 54 | <h2>Protected Members</h2>
|
---|
| 55 | <ul>
|
---|
| 56 | <li class=fn>virtual QString <a href="#fromRawData"><b>fromRawData</b></a> ( const QByteArray & data, bool beginning = FALSE )</li>
|
---|
| 57 | </ul>
|
---|
| 58 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | The QXmlInputSource class provides the input data for the
|
---|
| 63 | <a href="qxmlreader.html">QXmlReader</a> subclasses.
|
---|
| 64 |
|
---|
| 65 | <p>
|
---|
| 66 |
|
---|
| 67 | <p> All subclasses of QXmlReader read the input XML document from this
|
---|
| 68 | class.
|
---|
| 69 | <p> This class recognizes the encoding of the data by reading the
|
---|
| 70 | encoding declaration in the XML file if it finds one, and reading
|
---|
| 71 | the data using the corresponding encoding. If it does not find an
|
---|
| 72 | encoding declaration, then it assumes that the data is either in
|
---|
| 73 | UTF-8 or UTF-16, depending on whether it can find a byte-order
|
---|
| 74 | mark.
|
---|
| 75 | <p> There are two ways to populate the input source with data: you can
|
---|
| 76 | construct it with a <a href="qiodevice.html">QIODevice</a>* so that the input source reads the
|
---|
| 77 | data from that device. Or you can set the data explicitly with one
|
---|
| 78 | of the <a href="#setData">setData</a>() functions.
|
---|
| 79 | <p> Usually you either construct a QXmlInputSource that works on a
|
---|
| 80 | QIODevice* or you construct an empty QXmlInputSource and set the
|
---|
| 81 | data with setData(). There are only rare occasions where you would
|
---|
| 82 | want to mix both methods.
|
---|
| 83 | <p> The QXmlReader subclasses use the <a href="#next">next</a>() function to read the
|
---|
| 84 | input character by character. If you want to start from the
|
---|
| 85 | beginning again, use <a href="#reset">reset</a>().
|
---|
| 86 | <p> The functions <a href="#data">data</a>() and <a href="#fetchData">fetchData</a>() are useful if you want to do
|
---|
| 87 | something with the data other than parsing, e.g. displaying the
|
---|
| 88 | raw XML file. The benefit of using the QXmlInputClass in such
|
---|
| 89 | cases is that it tries to use the correct encoding.
|
---|
| 90 | <p> <p>See also <a href="qxmlreader.html">QXmlReader</a>, <a href="qxmlsimplereader.html">QXmlSimpleReader</a>, and <a href="xml-tools.html">XML</a>.
|
---|
| 91 |
|
---|
| 92 | <hr><h2>Member Function Documentation</h2>
|
---|
| 93 | <h3 class=fn><a name="QXmlInputSource"></a>QXmlInputSource::QXmlInputSource ()
|
---|
| 94 | </h3>
|
---|
| 95 | Constructs an input source which contains no data.
|
---|
| 96 | <p> <p>See also <a href="#setData">setData</a>().
|
---|
| 97 |
|
---|
| 98 | <h3 class=fn><a name="QXmlInputSource-2"></a>QXmlInputSource::QXmlInputSource ( <a href="qiodevice.html">QIODevice</a> * dev )
|
---|
| 99 | </h3>
|
---|
| 100 | Constructs an input source and gets the data from device <em>dev</em>.
|
---|
| 101 | If <em>dev</em> is not open, it is opened in read-only mode. If <em>dev</em>
|
---|
| 102 | is 0 or it is not possible to read from the device, the input
|
---|
| 103 | source will contain no data.
|
---|
| 104 | <p> <p>See also <a href="#setData">setData</a>(), <a href="#fetchData">fetchData</a>(), and <a href="qiodevice.html">QIODevice</a>.
|
---|
| 105 |
|
---|
| 106 | <h3 class=fn><a name="QXmlInputSource-3"></a>QXmlInputSource::QXmlInputSource ( <a href="qfile.html">QFile</a> & file )
|
---|
| 107 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 108 | <p> Constructs an input source and gets the data from the file <em>file</em>. If the
|
---|
| 109 | file cannot be read the input source is empty.
|
---|
| 110 |
|
---|
| 111 | <h3 class=fn><a name="QXmlInputSource-4"></a>QXmlInputSource::QXmlInputSource ( <a href="qtextstream.html">QTextStream</a> & stream )
|
---|
| 112 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 113 | <p> Constructs an input source and gets the data from the text stream <em>stream</em>.
|
---|
| 114 |
|
---|
| 115 | <h3 class=fn><a name="~QXmlInputSource"></a>QXmlInputSource::~QXmlInputSource ()<tt> [virtual]</tt>
|
---|
| 116 | </h3>
|
---|
| 117 | Destructor.
|
---|
| 118 |
|
---|
| 119 | <h3 class=fn><a href="qstring.html">QString</a> <a name="data"></a>QXmlInputSource::data ()<tt> [virtual]</tt>
|
---|
| 120 | </h3>
|
---|
| 121 | Returns the data the input source contains or <a href="qstring.html#QString-null">QString::null</a> if the
|
---|
| 122 | input source does not contain any data.
|
---|
| 123 | <p> <p>See also <a href="#setData">setData</a>(), <a href="#QXmlInputSource">QXmlInputSource</a>(), and <a href="#fetchData">fetchData</a>().
|
---|
| 124 |
|
---|
| 125 | <h3 class=fn>void <a name="fetchData"></a>QXmlInputSource::fetchData ()<tt> [virtual]</tt>
|
---|
| 126 | </h3>
|
---|
| 127 | This function reads more data from the device that was set during
|
---|
| 128 | construction. If the input source already contained data, this
|
---|
| 129 | function deletes that data first.
|
---|
| 130 | <p> This object contains no data after a call to this function if the
|
---|
| 131 | object was constructed without a device to read data from or if
|
---|
| 132 | this function was not able to get more data from the device.
|
---|
| 133 | <p> There are two occasions where a fetch is done implicitly by
|
---|
| 134 | another function call: during construction (so that the object
|
---|
| 135 | starts out with some initial data where available), and during a
|
---|
| 136 | call to <a href="#next">next</a>() (if the data had run out).
|
---|
| 137 | <p> You don't normally need to use this function if you use next().
|
---|
| 138 | <p> <p>See also <a href="#data">data</a>(), <a href="#next">next</a>(), and <a href="#QXmlInputSource">QXmlInputSource</a>().
|
---|
| 139 |
|
---|
| 140 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fromRawData"></a>QXmlInputSource::fromRawData ( const <a href="qbytearray.html">QByteArray</a> & data, bool beginning = FALSE )<tt> [virtual protected]</tt>
|
---|
| 141 | </h3>
|
---|
| 142 | This function reads the XML file from <em>data</em> and tries to
|
---|
| 143 | recognize the encoding. It converts the raw data <em>data</em> into a
|
---|
| 144 | <a href="qstring.html">QString</a> and returns it. It tries its best to get the correct
|
---|
| 145 | encoding for the XML file.
|
---|
| 146 | <p> If <em>beginning</em> is TRUE, this function assumes that the data
|
---|
| 147 | starts at the beginning of a new XML document and looks for an
|
---|
| 148 | encoding declaration. If <em>beginning</em> is FALSE, it converts the
|
---|
| 149 | raw data using the encoding determined from prior calls.
|
---|
| 150 |
|
---|
| 151 | <h3 class=fn><a href="qchar.html">QChar</a> <a name="next"></a>QXmlInputSource::next ()<tt> [virtual]</tt>
|
---|
| 152 | </h3>
|
---|
| 153 | Returns the next character of the input source. If this function
|
---|
| 154 | reaches the end of available data, it returns
|
---|
| 155 | QXmlInputSource::EndOfData. If you call <a href="#next">next</a>() after that, it
|
---|
| 156 | tries to fetch more data by calling <a href="#fetchData">fetchData</a>(). If the
|
---|
| 157 | fetchData() call results in new data, this function returns the
|
---|
| 158 | first character of that data; otherwise it returns
|
---|
| 159 | QXmlInputSource::EndOfDocument.
|
---|
| 160 | <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>().
|
---|
| 161 |
|
---|
| 162 | <h3 class=fn>void <a name="reset"></a>QXmlInputSource::reset ()<tt> [virtual]</tt>
|
---|
| 163 | </h3>
|
---|
| 164 | This function sets the position used by <a href="#next">next</a>() to the beginning of
|
---|
| 165 | the data returned by <a href="#data">data</a>(). This is useful if you want to use the
|
---|
| 166 | input source for more than one parse.
|
---|
| 167 | <p> <p>See also <a href="#next">next</a>().
|
---|
| 168 |
|
---|
| 169 | <p>Example: <a href="tagreader-with-features-example.html#x1975">xml/tagreader-with-features/tagreader.cpp</a>.
|
---|
| 170 | <h3 class=fn>void <a name="setData"></a>QXmlInputSource::setData ( const <a href="qstring.html">QString</a> & dat )<tt> [virtual]</tt>
|
---|
| 171 | </h3>
|
---|
| 172 | Sets the data of the input source to <em>dat</em>.
|
---|
| 173 | <p> If the input source already contains data, this function deletes
|
---|
| 174 | that data first.
|
---|
| 175 | <p> <p>See also <a href="#data">data</a>().
|
---|
| 176 |
|
---|
| 177 | <h3 class=fn>void <a name="setData-2"></a>QXmlInputSource::setData ( const <a href="qbytearray.html">QByteArray</a> & dat )<tt> [virtual]</tt>
|
---|
| 178 | </h3>
|
---|
| 179 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 180 | <p> The data <em>dat</em> is passed through the correct text-codec, before
|
---|
| 181 | it is set.
|
---|
| 182 |
|
---|
| 183 | <!-- eof -->
|
---|
| 184 | <hr><p>
|
---|
| 185 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 186 | Copyright © 1995-2007
|
---|
| 187 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 188 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 189 | <td>Copyright © 2007
|
---|
| 190 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 191 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 192 | </table></div></address></body>
|
---|
| 193 | </html>
|
---|