summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/db/xmlsource.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/tableviewer/db/xmlsource.cpp') (more/less context) (show 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
@@ -9,30 +9,36 @@
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "xmlsource.h"
-#include <qdict.h>
-#include <stdlib.h>
-#include <qtextstream.h>
#include "../xmlencodeattr.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+/* QT */
+#include <qdict.h>
+#include <qtextstream.h>
+
+/* STD */
+#include <stdlib.h>
DBXml::DBXml(DBStore *d)
{
dstore = d;
}
QString DBXml::type()
{
return "xml";
}
bool DBXml::openSource(QIODevice *inDev)
@@ -131,25 +137,25 @@ DBXmlHandler::DBXmlHandler(DBStore *ds)
current_keyrep = 0;
}
/*!
Destroys the DBXmlHandler
*/
DBXmlHandler::~DBXmlHandler()
{
}
QString DBXmlHandler::errorProtocol()
{
- qWarning("Error reading file");
+ owarn << "Error reading file" << oendl;
return errorProt;
}
bool DBXmlHandler::startDocument()
{
errorProt = "";
state = StateInit;
return TRUE;
}
bool DBXmlHandler::startElement(const QString&, const QString&,
const QString& qName, const QXmlAttributes& atts)
@@ -163,49 +169,49 @@ bool DBXmlHandler::startElement(const QString&, const QString&,
if (state == StateDocument && qName == "header") {
state = StateHeader;
if (current_keyrep) delete current_keyrep;
current_keyrep = new KeyList();
return TRUE;
}
if (state == StateHeader && qName == "key") {
/* Ok, adding a new key to our KeyList TODO */
state = StateKey;
last_key_type = TVVariant::String;
key = atts.value("name");
if (key.isEmpty()) {
- qWarning("empty key name");
+ owarn << "empty key name" << oendl;
return FALSE;
}
if(!atts.value("type").isEmpty())
last_key_type = TVVariant::nameToType(atts.value("type"));
return TRUE;
}
if (state == StateDocument && qName == "record") {
state = StateRecord;
current_data = new DataElem(data_store);
// Now expecting a <record> tag
return TRUE;
}
if (state == StateRecord) {
state = StateField;
/* the qName is the name of a key */
if (!keyIndexList[qName]) {
/* invalid key, we failed */
- qWarning("Invalid key in record");
+ owarn << "Invalid key in record" << oendl;
return FALSE;
}
keyIndex = *keyIndexList[qName];
return TRUE;
}
- qWarning("Unable to determine tag type");
+ owarn << "Unable to determine tag type" << oendl;
return FALSE;
}
bool DBXmlHandler::endElement(const QString&, const QString&,
const QString& qName)
{
switch(state) {
case StateField:
// TODO checks 'could' be done of the popped value
state = StateRecord;
break;
case StateKey:
@@ -216,25 +222,25 @@ bool DBXmlHandler::endElement(const QString&, const QString&,
data_store->setKeys(current_keyrep);
state = StateDocument;
break;
case StateRecord:
data_store->addItem(current_data);
state = StateDocument;
break;
case StateDocument:
// we are done...
break;
default:
// should only get a 'endElement' from one of the above states.
- qWarning("Invalid end tag");
+ owarn << "Invalid end tag" << oendl;
return FALSE;
break;
}
return TRUE;
}
bool DBXmlHandler::characters(const QString& ch)
{
// this is where the 'between tag' stuff happens.
// e.g. the stuff between tags.
QString ch_simplified = ch.simplifyWhiteSpace();
@@ -245,53 +251,53 @@ bool DBXmlHandler::characters(const QString& ch)
int *tmp_val = new int;
/* We just grabbed the display name of a key */
*tmp_val = current_keyrep->addKey(ch_simplified, last_key_type);
keyIndexList.insert(key, tmp_val);
return TRUE;
}
if (state == StateField) {
/* Ok, need to add data here */
current_data->setField(keyIndex, ch_simplified);
return TRUE;
}
- qWarning("Junk characters found... ignored");
+ owarn << "Junk characters found... ignored" << oendl;
return TRUE;
}
QString DBXmlHandler::errorString()
{
return "the document is not in the expected file format";
}
bool DBXmlHandler::warning(const QXmlParseException& exception)
{
errorProt += QString("warning parsing error: %1 in line %2, column %3\n" )
.arg(exception.message())
.arg(exception.lineNumber())
.arg(exception.columnNumber());
- qWarning(errorProt);
+ owarn << errorProt << oendl;
return QXmlDefaultHandler::fatalError(exception);
}
bool DBXmlHandler::error(const QXmlParseException& exception)
{
errorProt += QString("error parsing error: %1 in line %2, column %3\n" )
.arg(exception.message())
.arg(exception.lineNumber())
.arg(exception.columnNumber());
- qWarning(errorProt);
+ owarn << errorProt << oendl;
return QXmlDefaultHandler::fatalError(exception);
}
bool DBXmlHandler::fatalError(const QXmlParseException& exception)
{
errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" )
.arg(exception.message())
.arg(exception.lineNumber())
.arg(exception.columnNumber());
- qWarning(errorProt);
+ owarn << errorProt << oendl;
return QXmlDefaultHandler::fatalError(exception);
}