summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/db/xmlsource.cpp
Unidiff
Diffstat (limited to 'noncore/apps/tableviewer/db/xmlsource.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/db/xmlsource.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/noncore/apps/tableviewer/db/xmlsource.cpp b/noncore/apps/tableviewer/db/xmlsource.cpp
index 94fec36..4ca6aee 100644
--- a/noncore/apps/tableviewer/db/xmlsource.cpp
+++ b/noncore/apps/tableviewer/db/xmlsource.cpp
@@ -15,18 +15,24 @@
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "xmlsource.h" 20#include "xmlsource.h"
21#include <qdict.h>
22#include <stdlib.h>
23#include <qtextstream.h>
24#include "../xmlencodeattr.h" 21#include "../xmlencodeattr.h"
25 22
23/* OPIE */
24#include <opie2/odebug.h>
25using namespace Opie::Core;
26 26
27/* QT */
28#include <qdict.h>
29#include <qtextstream.h>
30
31/* STD */
32#include <stdlib.h>
27 33
28DBXml::DBXml(DBStore *d) 34DBXml::DBXml(DBStore *d)
29{ 35{
30 dstore = d; 36 dstore = d;
31} 37}
32 38
@@ -137,13 +143,13 @@ DBXmlHandler::DBXmlHandler(DBStore *ds)
137DBXmlHandler::~DBXmlHandler() 143DBXmlHandler::~DBXmlHandler()
138{ 144{
139} 145}
140 146
141QString DBXmlHandler::errorProtocol() 147QString DBXmlHandler::errorProtocol()
142{ 148{
143 qWarning("Error reading file"); 149 owarn << "Error reading file" << oendl;
144 return errorProt; 150 return errorProt;
145} 151}
146 152
147bool DBXmlHandler::startDocument() 153bool DBXmlHandler::startDocument()
148{ 154{
149 errorProt = ""; 155 errorProt = "";
@@ -169,13 +175,13 @@ bool DBXmlHandler::startElement(const QString&, const QString&,
169 if (state == StateHeader && qName == "key") { 175 if (state == StateHeader && qName == "key") {
170 /* Ok, adding a new key to our KeyList TODO */ 176 /* Ok, adding a new key to our KeyList TODO */
171 state = StateKey; 177 state = StateKey;
172 last_key_type = TVVariant::String; 178 last_key_type = TVVariant::String;
173 key = atts.value("name"); 179 key = atts.value("name");
174 if (key.isEmpty()) { 180 if (key.isEmpty()) {
175 qWarning("empty key name"); 181 owarn << "empty key name" << oendl;
176 return FALSE; 182 return FALSE;
177 } 183 }
178 if(!atts.value("type").isEmpty()) 184 if(!atts.value("type").isEmpty())
179 last_key_type = TVVariant::nameToType(atts.value("type")); 185 last_key_type = TVVariant::nameToType(atts.value("type"));
180 return TRUE; 186 return TRUE;
181 } 187 }
@@ -187,19 +193,19 @@ bool DBXmlHandler::startElement(const QString&, const QString&,
187 } 193 }
188 if (state == StateRecord) { 194 if (state == StateRecord) {
189 state = StateField; 195 state = StateField;
190 /* the qName is the name of a key */ 196 /* the qName is the name of a key */
191 if (!keyIndexList[qName]) { 197 if (!keyIndexList[qName]) {
192 /* invalid key, we failed */ 198 /* invalid key, we failed */
193 qWarning("Invalid key in record"); 199 owarn << "Invalid key in record" << oendl;
194 return FALSE; 200 return FALSE;
195 } 201 }
196 keyIndex = *keyIndexList[qName]; 202 keyIndex = *keyIndexList[qName];
197 return TRUE; 203 return TRUE;
198 } 204 }
199 qWarning("Unable to determine tag type"); 205 owarn << "Unable to determine tag type" << oendl;
200 return FALSE; 206 return FALSE;
201} 207}
202 208
203bool DBXmlHandler::endElement(const QString&, const QString&, 209bool DBXmlHandler::endElement(const QString&, const QString&,
204 const QString& qName) 210 const QString& qName)
205{ 211{
@@ -222,13 +228,13 @@ bool DBXmlHandler::endElement(const QString&, const QString&,
222 break; 228 break;
223 case StateDocument: 229 case StateDocument:
224 // we are done... 230 // we are done...
225 break; 231 break;
226 default: 232 default:
227 // should only get a 'endElement' from one of the above states. 233 // should only get a 'endElement' from one of the above states.
228 qWarning("Invalid end tag"); 234 owarn << "Invalid end tag" << oendl;
229 return FALSE; 235 return FALSE;
230 break; 236 break;
231 } 237 }
232 return TRUE; 238 return TRUE;
233} 239}
234 240
@@ -251,13 +257,13 @@ bool DBXmlHandler::characters(const QString& ch)
251 if (state == StateField) { 257 if (state == StateField) {
252 /* Ok, need to add data here */ 258 /* Ok, need to add data here */
253 current_data->setField(keyIndex, ch_simplified); 259 current_data->setField(keyIndex, ch_simplified);
254 return TRUE; 260 return TRUE;
255 } 261 }
256 262
257 qWarning("Junk characters found... ignored"); 263 owarn << "Junk characters found... ignored" << oendl;
258 return TRUE; 264 return TRUE;
259} 265}
260 266
261QString DBXmlHandler::errorString() 267QString DBXmlHandler::errorString()
262{ 268{
263 return "the document is not in the expected file format"; 269 return "the document is not in the expected file format";
@@ -267,31 +273,31 @@ bool DBXmlHandler::warning(const QXmlParseException& exception)
267{ 273{
268 errorProt += QString("warning parsing error: %1 in line %2, column %3\n" ) 274 errorProt += QString("warning parsing error: %1 in line %2, column %3\n" )
269 .arg(exception.message()) 275 .arg(exception.message())
270 .arg(exception.lineNumber()) 276 .arg(exception.lineNumber())
271 .arg(exception.columnNumber()); 277 .arg(exception.columnNumber());
272 278
273 qWarning(errorProt); 279 owarn << errorProt << oendl;
274 return QXmlDefaultHandler::fatalError(exception); 280 return QXmlDefaultHandler::fatalError(exception);
275} 281}
276 282
277bool DBXmlHandler::error(const QXmlParseException& exception) 283bool DBXmlHandler::error(const QXmlParseException& exception)
278{ 284{
279 errorProt += QString("error parsing error: %1 in line %2, column %3\n" ) 285 errorProt += QString("error parsing error: %1 in line %2, column %3\n" )
280 .arg(exception.message()) 286 .arg(exception.message())
281 .arg(exception.lineNumber()) 287 .arg(exception.lineNumber())
282 .arg(exception.columnNumber()); 288 .arg(exception.columnNumber());
283 289
284 qWarning(errorProt); 290 owarn << errorProt << oendl;
285 return QXmlDefaultHandler::fatalError(exception); 291 return QXmlDefaultHandler::fatalError(exception);
286} 292}
287 293
288bool DBXmlHandler::fatalError(const QXmlParseException& exception) 294bool DBXmlHandler::fatalError(const QXmlParseException& exception)
289{ 295{
290 errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" ) 296 errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" )
291 .arg(exception.message()) 297 .arg(exception.message())
292 .arg(exception.lineNumber()) 298 .arg(exception.lineNumber())
293 .arg(exception.columnNumber()); 299 .arg(exception.columnNumber());
294 300
295 qWarning(errorProt); 301 owarn << errorProt << oendl;
296 return QXmlDefaultHandler::fatalError(exception); 302 return QXmlDefaultHandler::fatalError(exception);
297} 303}