Qt XML Stream Lint Example.
Sun Feb 7 16:06:42 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Qt XML Stream Lint Example.
diff -rN -u old-qt.examples/cl-smoke.qt.examples.asd new-qt.examples/cl-smoke.qt.examples.asd
--- old-qt.examples/cl-smoke.qt.examples.asd 2014-10-30 06:59:37.000000000 +0100
+++ new-qt.examples/cl-smoke.qt.examples.asd 2014-10-30 06:59:37.000000000 +0100
@@ -25,6 +25,7 @@
:depends-on ("package")
:components
((:file "analog-clock")
+ (:file "xmlstreamlint")
(:file "colliding-mice")))))))
;;(:module "origami"
;; :depends-on ("package")
diff -rN -u old-qt.examples/src/qt/xmlstreamlint.lisp new-qt.examples/src/qt/xmlstreamlint.lisp
--- old-qt.examples/src/qt/xmlstreamlint.lisp 1970-01-01 01:00:00.000000000 +0100
+++ new-qt.examples/src/qt/xmlstreamlint.lisp 2014-10-30 06:59:37.000000000 +0100
@@ -0,0 +1,66 @@
+;;; Copyright (c) 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
+;;; Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+;;; Contact: Qt Software Information (qt-info@nokia.com)
+;;;
+;;; This file is part of the examples of the Qt Toolkit.
+;;;
+;;; $QT_BEGIN_LICENSE:LGPL$
+;;; Commercial Usage
+;;; Licensees holding valid Qt Commercial licenses may use this file in
+;;; accordance with the Qt Commercial License Agreement provided with the
+;;; Software or, alternatively, in accordance with the terms contained in
+;;; a written agreement between you and Nokia.
+;;;
+;;; GNU Lesser General Public License Usage
+;;; Alternatively, this file may be used under the terms of the GNU Lesser
+;;; General Public License version 2.1 as published by the Free Software
+;;; Foundation and appearing in the file LICENSE.LGPL included in the
+;;; packaging of this file. Please review the following information to
+;;; ensure the GNU Lesser General Public License version 2.1 requirements
+;;; will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+;;;
+;;; In addition, as a special exception, Nokia gives you certain
+;;; additional rights. These rights are described in the Nokia Qt LGPL
+;;; Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+;;; package.
+;;;
+;;; GNU General Public License Usage
+;;; Alternatively, this file may be used under the terms of the GNU
+;;; General Public License version 3.0 as published by the Free Software
+;;; Foundation and appearing in the file LICENSE.GPL included in the
+;;; packaging of this file. Please review the following information to
+;;; ensure the GNU General Public License version 3.0 requirements will be
+;;; met: http://www.gnu.org/copyleft/gpl.html.
+;;;
+;;; If you are unsure which license is appropriate for your use, please
+;;; contact the sales department at qt-sales@nokia.com.
+;;; $QT_END_LICENSE$
+
+(in-package :qt.examples)
+
+;; Small example using only qt.core
+
+(defun xml-lint (input-file-path)
+ "Reads the XML from the file at INPUT-FILE-PATH and returns a copy."
+ (qt:with-core-app ()
+ (let ((input-file (make-instance 'qt:file
+ :arg0 input-file-path)))
+ (unless (cxx:exists input-file)
+ (error "File ~A does not exist." input-file-path))
+ (unless (cxx:open input-file qt:iodevice.+read-only+)
+ (error "Failed to open file ~A." input-file-path))
+
+ (let* ((reader (make-instance 'qt:xml-stream-reader
+ :arg0 input-file))
+ (output (make-instance 'qt:byte-array))
+ (writer (make-instance 'qt:xml-stream-writer
+ :arg0 output)))
+ (loop until (cxx:at-end reader) do
+ (cxx:read-next reader)
+ (when (cxx:has-error reader)
+ (error "Error: ~A in file ~A at line ~A, column ~A."
+ (cxx:error-string reader)
+ input-file-path
+ (cxx:line-number reader) (cxx:column-number reader)))
+ (cxx:write-current-token writer reader))
+ (cxx:data output)))))