~gabriel1984sibiu/minitube/qt5.6

« back to all changes in this revision

Viewing changes to examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc

  • Committer: Grevutiu Gabriel
  • Date: 2017-06-13 08:43:17 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20170613084317-ek0zqe0u9g3ocvi8
OriginalĀ upstreamĀ code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2016 The Qt Company Ltd.
 
4
** Contact: https://www.qt.io/licensing/
 
5
**
 
6
** This file is part of the documentation of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:FDL$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and The Qt Company. For licensing terms
 
14
** and conditions see https://www.qt.io/terms-conditions. For further
 
15
** information use the contact form at https://www.qt.io/contact-us.
 
16
**
 
17
** GNU Free Documentation License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU Free
 
19
** Documentation License version 1.3 as published by the Free Software
 
20
** Foundation and appearing in the file included in the packaging of
 
21
** this file. Please review the following information to ensure
 
22
** the GNU Free Documentation License version 1.3 requirements
 
23
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
 
24
** $QT_END_LICENSE$
 
25
**
 
26
****************************************************************************/
 
27
 
 
28
/*!
 
29
    \example xmlstreamlint
 
30
    \title XML Stream Lint Example
 
31
    \ingroup xml-examples
 
32
    \brief A commandline tool reading from an input file and writing to
 
33
    the standard output file.
 
34
 
 
35
    The XML Stream Lint example provides a simple command line utility that
 
36
    accepts a file name as its single argument and writes it to the standard
 
37
    output file.
 
38
 
 
39
    The specified file is parsed using an QXmlStreamReader object and written
 
40
    to the standard output file using an QXmlStreamWriter object. If the file
 
41
    does not contain a well-formed XML document or the use of namespaces in
 
42
    the document is incorrect, a description of the error is printed to
 
43
    the standard error file and will appear in the console.
 
44
 
 
45
    \section1 Basic Operation
 
46
 
 
47
    The main function of the example opens the file specified by the user
 
48
    for input (\c inputFile), and it uses QFile to access the standard output
 
49
    file.
 
50
 
 
51
    Reading XML is handled by an instance of the QXmlStreamReader class, which
 
52
    operates on the input file object; writing is handled by an instance of
 
53
    QXmlStreamWriter operating on the output file object:
 
54
 
 
55
    \snippet xmlstreamlint/main.cpp 0
 
56
 
 
57
    The work of parsing and rewriting the XML is done in a while loop, and is
 
58
    driven by input from the reader:
 
59
 
 
60
    \snippet xmlstreamlint/main.cpp 1
 
61
 
 
62
    If more input is available, the next token from the input file is read
 
63
    and parsed. If an error occurred, information is written to the standard
 
64
    error file via a stream, and the example exits by returning a non-zero
 
65
    value from the main function.
 
66
 
 
67
    \snippet xmlstreamlint/main.cpp 2
 
68
 
 
69
    For valid input, the writer is fed the current token from the reader,
 
70
    and this is written to the output file that was specified when it was
 
71
    constructed.
 
72
 
 
73
    When there is no more input, the loop terminates, and the example can
 
74
    exit successfully.
 
75
*/