repos
/
qt.examples
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
headblob
|
headfilediff
|
filehistory
normal
|
plain
|
shade
|
zebra
Qt XML Stream Lint Example.
Annotate for file src/qt/xmlstreamlint.lisp
2010-02-07 tobias
1
;;; Copyright (c) 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
15:06:42 '
2
;;; Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
'
3
;;; Contact: Qt Software Information (qt-info@nokia.com)
'
4
;;;
'
5
;;; This file is part of the examples of the Qt Toolkit.
'
6
;;;
'
7
;;; $QT_BEGIN_LICENSE:LGPL$
'
8
;;; Commercial Usage
'
9
;;; Licensees holding valid Qt Commercial licenses may use this file in
'
10
;;; accordance with the Qt Commercial License Agreement provided with the
'
11
;;; Software or, alternatively, in accordance with the terms contained in
'
12
;;; a written agreement between you and Nokia.
'
13
;;;
'
14
;;; GNU Lesser General Public License Usage
'
15
;;; Alternatively, this file may be used under the terms of the GNU Lesser
'
16
;;; General Public License version 2.1 as published by the Free Software
'
17
;;; Foundation and appearing in the file LICENSE.LGPL included in the
'
18
;;; packaging of this file. Please review the following information to
'
19
;;; ensure the GNU Lesser General Public License version 2.1 requirements
'
20
;;; will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
'
21
;;;
'
22
;;; In addition, as a special exception, Nokia gives you certain
'
23
;;; additional rights. These rights are described in the Nokia Qt LGPL
'
24
;;; Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
'
25
;;; package.
'
26
;;;
'
27
;;; GNU General Public License Usage
'
28
;;; Alternatively, this file may be used under the terms of the GNU
'
29
;;; General Public License version 3.0 as published by the Free Software
'
30
;;; Foundation and appearing in the file LICENSE.GPL included in the
'
31
;;; packaging of this file. Please review the following information to
'
32
;;; ensure the GNU General Public License version 3.0 requirements will be
'
33
;;; met: http://www.gnu.org/copyleft/gpl.html.
'
34
;;;
'
35
;;; If you are unsure which license is appropriate for your use, please
'
36
;;; contact the sales department at qt-sales@nokia.com.
'
37
;;; $QT_END_LICENSE$
'
38
'
39
(in-package :qt.examples)
'
40
'
41
;; Small example using only qt.core
'
42
'
43
(defun xml-lint (input-file-path)
'
44
"Reads the XML from the file at INPUT-FILE-PATH and returns a copy."
'
45
(qt:with-core-app ()
'
46
(let ((input-file (make-instance 'qt:file
'
47
:arg0 input-file-path)))
'
48
(unless (cxx:exists input-file)
'
49
(error "File ~A does not exist." input-file-path))
'
50
(unless (cxx:open input-file qt:iodevice.+read-only+)
'
51
(error "Failed to open file ~A." input-file-path))
'
52
'
53
(let* ((reader (make-instance 'qt:xml-stream-reader
'
54
:arg0 input-file))
'
55
(output (make-instance 'qt:byte-array))
'
56
(writer (make-instance 'qt:xml-stream-writer
'
57
:arg0 output)))
'
58
(loop until (cxx:at-end reader) do
'
59
(cxx:read-next reader)
'
60
(when (cxx:has-error reader)
'
61
(error "Error: ~A in file ~A at line ~A, column ~A."
'
62
(cxx:error-string reader)
'
63
input-file-path
'
64
(cxx:line-number reader) (cxx:column-number reader)))
'
65
(cxx:write-current-token writer reader))
'
66
(cxx:data output)))))