source: trunk/doc/html/qxmlinputsource.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 10.7 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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
35QXmlReader 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 &lt;<a href="qxml-h.html">qxml.h</a>&gt;</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&nbsp;*&nbsp;dev )</li>
44<li class=fn>QXmlInputSource ( QFile&nbsp;&amp;&nbsp;file ) &nbsp;<em>(obsolete)</em></li>
45<li class=fn>QXmlInputSource ( QTextStream&nbsp;&amp;&nbsp;stream ) &nbsp;<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&nbsp;QString&nbsp;&amp;&nbsp;dat )</li>
48<li class=fn>virtual void <a href="#setData-2"><b>setData</b></a> ( const&nbsp;QByteArray&nbsp;&amp;&nbsp;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&nbsp;QByteArray&nbsp;&amp;&nbsp;data, bool&nbsp;beginning = FALSE )</li>
57</ul>
58<hr><a name="details"></a><h2>Detailed Description</h2>
59
60
61
62The 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
68class.
69<p> This class recognizes the encoding of the data by reading the
70encoding declaration in the XML file if it finds one, and reading
71the data using the corresponding encoding. If it does not find an
72encoding declaration, then it assumes that the data is either in
73UTF-8 or UTF-16, depending on whether it can find a byte-order
74mark.
75<p> There are two ways to populate the input source with data: you can
76construct it with a <a href="qiodevice.html">QIODevice</a>* so that the input source reads the
77data from that device. Or you can set the data explicitly with one
78of the <a href="#setData">setData</a>() functions.
79<p> Usually you either construct a QXmlInputSource that works on a
80QIODevice* or you construct an empty QXmlInputSource and set the
81data with setData(). There are only rare occasions where you would
82want to mix both methods.
83<p> The QXmlReader subclasses use the <a href="#next">next</a>() function to read the
84input character by character. If you want to start from the
85beginning 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
87something with the data other than parsing, e.g. displaying the
88raw XML file. The benefit of using the QXmlInputClass in such
89cases 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>
95Constructs 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>&nbsp;*&nbsp;dev )
99</h3>
100Constructs an input source and gets the data from device <em>dev</em>.
101If <em>dev</em> is not open, it is opened in read-only mode. If <em>dev</em>
102is 0 or it is not possible to read from the device, the input
103source 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>&nbsp;&amp;&nbsp;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
109file 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>&nbsp;&amp;&nbsp;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>
117Destructor.
118
119<h3 class=fn><a href="qstring.html">QString</a> <a name="data"></a>QXmlInputSource::data ()<tt> [virtual]</tt>
120</h3>
121Returns the data the input source contains or <a href="qstring.html#QString-null">QString::null</a> if the
122input 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>
127This function reads more data from the device that was set during
128construction. If the input source already contained data, this
129function deletes that data first.
130<p> This object contains no data after a call to this function if the
131object was constructed without a device to read data from or if
132this function was not able to get more data from the device.
133<p> There are two occasions where a fetch is done implicitly by
134another function call: during construction (so that the object
135starts out with some initial data where available), and during a
136call 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&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;data, bool&nbsp;beginning = FALSE )<tt> [virtual protected]</tt>
141</h3>
142This function reads the XML file from <em>data</em> and tries to
143recognize 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
145encoding for the XML file.
146<p> If <em>beginning</em> is TRUE, this function assumes that the data
147starts at the beginning of a new XML document and looks for an
148encoding declaration. If <em>beginning</em> is FALSE, it converts the
149raw 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>
153Returns the next character of the input source. If this function
154reaches the end of available data, it returns
155QXmlInputSource::EndOfData. If you call <a href="#next">next</a>() after that, it
156tries to fetch more data by calling <a href="#fetchData">fetchData</a>(). If the
157fetchData() call results in new data, this function returns the
158first character of that data; otherwise it returns
159QXmlInputSource::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>
164This function sets the position used by <a href="#next">next</a>() to the beginning of
165the data returned by <a href="#data">data</a>(). This is useful if you want to use the
166input 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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dat )<tt> [virtual]</tt>
171</h3>
172Sets the data of the input source to <em>dat</em>.
173<p> If the input source already contains data, this function deletes
174that 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&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;dat )<tt> [virtual]</tt>
178</h3>
179This 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
181it is set.
182
183<!-- eof -->
184<hr><p>
185This file is part of the <a href="index.html">Qt toolkit</a>.
186Copyright &copy; 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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.