summaryrefslogtreecommitdiffstats
path: root/examples/xml/tagreader
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/xml/tagreader
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/xml/tagreader')
-rw-r--r--examples/xml/tagreader/animals.xml7
-rw-r--r--examples/xml/tagreader/structureparser.cpp34
-rw-r--r--examples/xml/tagreader/structureparser.h29
-rw-r--r--examples/xml/tagreader/tagreader.cpp30
-rw-r--r--examples/xml/tagreader/tagreader.doc35
-rw-r--r--examples/xml/tagreader/tagreader.pro11
6 files changed, 146 insertions, 0 deletions
diff --git a/examples/xml/tagreader/animals.xml b/examples/xml/tagreader/animals.xml
new file mode 100644
index 000000000..e1284901d
--- /dev/null
+++ b/examples/xml/tagreader/animals.xml
@@ -0,0 +1,7 @@
+<animals>
+<mammals>
+ <monkeys> <gorilla/> <orangutan/> </monkeys>
+</mammals>
+<birds> <pigeon/> <penguin/> </birds>
+</animals>
+
diff --git a/examples/xml/tagreader/structureparser.cpp b/examples/xml/tagreader/structureparser.cpp
new file mode 100644
index 000000000..9c13f4568
--- /dev/null
+++ b/examples/xml/tagreader/structureparser.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "structureparser.h"
+
+#include <stdio.h>
+#include <qstring.h>
+
+bool StructureParser::startDocument()
+{
+ indent = "";
+ return TRUE;
+}
+
+bool StructureParser::startElement( const TQString&, const TQString&,
+ const TQString& qName,
+ const TQXmlAttributes& )
+{
+ printf( "%s%s\n", (const char*)indent, (const char*)qName );
+ indent += " ";
+ return TRUE;
+}
+
+bool StructureParser::endElement( const TQString&, const TQString&, const TQString& )
+{
+ indent.remove( (uint)0, 4 );
+ return TRUE;
+}
diff --git a/examples/xml/tagreader/structureparser.h b/examples/xml/tagreader/structureparser.h
new file mode 100644
index 000000000..c860f21a5
--- /dev/null
+++ b/examples/xml/tagreader/structureparser.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#ifndef STRUCTUREPARSER_H
+#define STRUCTUREPARSER_H
+
+#include <qxml.h>
+
+class TQString;
+
+class StructureParser : public TQXmlDefaultHandler
+{
+public:
+ bool startDocument();
+ bool startElement( const TQString&, const TQString&, const TQString& ,
+ const TQXmlAttributes& );
+ bool endElement( const TQString&, const TQString&, const TQString& );
+
+private:
+ TQString indent;
+};
+
+#endif
diff --git a/examples/xml/tagreader/tagreader.cpp b/examples/xml/tagreader/tagreader.cpp
new file mode 100644
index 000000000..93dd4cc59
--- /dev/null
+++ b/examples/xml/tagreader/tagreader.cpp
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "structureparser.h"
+#include <qfile.h>
+#include <qxml.h>
+#include <qwindowdefs.h>
+
+int main( int argc, char **argv )
+{
+ if ( argc < 2 ) {
+ fprintf( stderr, "Usage: %s <xmlfile> [<xmlfile> ...]\n", argv[0] );
+ return 1;
+ }
+ StructureParser handler;
+ TQXmlSimpleReader reader;
+ reader.setContentHandler( &handler );
+ for ( int i=1; i < argc; i++ ) {
+ TQFile xmlFile( argv[i] );
+ TQXmlInputSource source( &xmlFile );
+ reader.parse( source );
+ }
+ return 0;
+}
diff --git a/examples/xml/tagreader/tagreader.doc b/examples/xml/tagreader/tagreader.doc
new file mode 100644
index 000000000..9a0bad01d
--- /dev/null
+++ b/examples/xml/tagreader/tagreader.doc
@@ -0,0 +1,35 @@
+/*
+*/
+
+/*! \page tagreader-example.html
+
+ \ingroup xml-examples
+
+ \title A tiny SAX2 parser
+
+ This example presents a small \link xml.html#sax2 SAX2 \endlink
+ reader that outputs the names of all elements in an
+ XML document on the command line. The element names are
+ indented corresponding to their nesting
+
+ This example is thoroughly explained in a
+ \link xml-sax-walkthrough.html walkthrough. \endlink
+
+ <hr>
+
+ Header file:
+
+ \include xml/tagreader/structureparser.h
+
+ <hr>
+
+ Implementation:
+
+ \include xml/tagreader/structureparser.cpp
+
+ <hr>
+
+ Main:
+
+ \include xml/tagreader/tagreader.cpp
+*/
diff --git a/examples/xml/tagreader/tagreader.pro b/examples/xml/tagreader/tagreader.pro
new file mode 100644
index 000000000..b6ebf8b97
--- /dev/null
+++ b/examples/xml/tagreader/tagreader.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = tagreader
+
+CONFIG += qt console warn_on release
+
+REQUIRES = xml large-config
+
+HEADERS = structureparser.h
+SOURCES = tagreader.cpp \
+ structureparser.cpp
+INTERFACES =