diff options
Diffstat (limited to 'examples/xml/xmlstreamlint')
-rw-r--r-- | examples/xml/xmlstreamlint/.prev_CMakeLists.txt | 35 | ||||
-rw-r--r-- | examples/xml/xmlstreamlint/CMakeLists.txt | 36 | ||||
-rw-r--r-- | examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc | 75 | ||||
-rw-r--r-- | examples/xml/xmlstreamlint/main.cpp | 137 | ||||
-rw-r--r-- | examples/xml/xmlstreamlint/xmlstreamlint.pro | 7 |
5 files changed, 0 insertions, 290 deletions
diff --git a/examples/xml/xmlstreamlint/.prev_CMakeLists.txt b/examples/xml/xmlstreamlint/.prev_CMakeLists.txt deleted file mode 100644 index 23d62e7b1c..0000000000 --- a/examples/xml/xmlstreamlint/.prev_CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Generated from xmlstreamlint.pro. - -cmake_minimum_required(VERSION 3.14) -project(xmlstreamlint LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/xmlstreamlint") - -find_package(Qt6 COMPONENTS Core) - -qt_add_executable(xmlstreamlint - main.cpp -) -set_target_properties(xmlstreamlint PROPERTIES - WIN32_EXECUTABLE FALSE - MACOSX_BUNDLE FALSE -) -target_link_libraries(xmlstreamlint PUBLIC - Qt::Core -) - -install(TARGETS xmlstreamlint - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/xml/xmlstreamlint/CMakeLists.txt b/examples/xml/xmlstreamlint/CMakeLists.txt deleted file mode 100644 index 8ed14a753c..0000000000 --- a/examples/xml/xmlstreamlint/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Generated from xmlstreamlint.pro. - -cmake_minimum_required(VERSION 3.16) -project(xmlstreamlint LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/xml/xmlstreamlint") - -find_package(Qt6 COMPONENTS Core Xml) # special case - -qt_add_executable(xmlstreamlint - main.cpp -) -set_target_properties(xmlstreamlint PROPERTIES - WIN32_EXECUTABLE FALSE - MACOSX_BUNDLE FALSE -) -target_link_libraries(xmlstreamlint PUBLIC - Qt::Core - Qt::Xml # special case: add -) - -install(TARGETS xmlstreamlint - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc b/examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc deleted file mode 100644 index 9a821342eb..0000000000 --- a/examples/xml/xmlstreamlint/doc/src/xmlstreamlint.qdoc +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example xmlstreamlint - \title XML Stream Lint Example - \ingroup xml-examples - \brief A commandline tool reading from an input file and writing to - the standard output file. - - The XML Stream Lint example provides a simple command line utility that - accepts a file name as its single argument and writes it to the standard - output file. - - The specified file is parsed using an QXmlStreamReader object and written - to the standard output file using an QXmlStreamWriter object. If the file - does not contain a well-formed XML document or the use of namespaces in - the document is incorrect, a description of the error is printed to - the standard error file and will appear in the console. - - \section1 Basic Operation - - The main function of the example opens the file specified by the user - for input (\c inputFile), and it uses QFile to access the standard output - file. - - Reading XML is handled by an instance of the QXmlStreamReader class, which - operates on the input file object; writing is handled by an instance of - QXmlStreamWriter operating on the output file object: - - \snippet xmlstreamlint/main.cpp 0 - - The work of parsing and rewriting the XML is done in a while loop, and is - driven by input from the reader: - - \snippet xmlstreamlint/main.cpp 1 - - If more input is available, the next token from the input file is read - and parsed. If an error occurred, information is written to the standard - error file via a stream, and the example exits by returning a non-zero - value from the main function. - - \snippet xmlstreamlint/main.cpp 2 - - For valid input, the writer is fed the current token from the reader, - and this is written to the output file that was specified when it was - constructed. - - When there is no more input, the loop terminates, and the example can - exit successfully. -*/ diff --git a/examples/xml/xmlstreamlint/main.cpp b/examples/xml/xmlstreamlint/main.cpp deleted file mode 100644 index 5f8b06a771..0000000000 --- a/examples/xml/xmlstreamlint/main.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QCoreApplication> -#include <QFile> -#include <QStringList> -#include <QTextStream> -#include <QXmlStreamReader> - -/* - This class exists for the sole purpose of creating a translation context. -*/ -class XmlStreamLint -{ -public: - Q_DECLARE_TR_FUNCTIONS(XmlStreamLint) -}; - -int main(int argc, char *argv[]) -{ - enum ExitCode - { - Success, - ParseFailure, - ArgumentError, - WriteError, - FileFailure - }; - - QCoreApplication app(argc, argv); - - QTextStream errorStream(stderr); - - if (argc != 2) - { - errorStream << XmlStreamLint::tr( - "Usage: xmlstreamlint <path to XML file>\n"); - return ArgumentError; - } - - QString inputFilePath(QCoreApplication::arguments().at(1)); - QFile inputFile(inputFilePath); - - if (!QFile::exists(inputFilePath)) - { - errorStream << XmlStreamLint::tr( - "File %1 does not exist.\n").arg(inputFilePath); - return FileFailure; - - } else if (!inputFile.open(QIODevice::ReadOnly)) { - errorStream << XmlStreamLint::tr( - "Failed to open file %1.\n").arg(inputFilePath); - return FileFailure; - } - - QFile outputFile; - if (!outputFile.open(stdout, QIODevice::WriteOnly)) - { - errorStream << XmlStreamLint::tr("Failed to open stdout."); - return WriteError; - } - -//! [0] - QXmlStreamReader reader(&inputFile); - QXmlStreamWriter writer(&outputFile); -//! [0] - -//! [1] - while (!reader.atEnd()) - { - reader.readNext(); - - if (reader.error()) - { - errorStream << XmlStreamLint::tr( - "Error: %1 in file %2 at line %3, column %4.\n").arg( - reader.errorString(), inputFilePath, - QString::number(reader.lineNumber()), - QString::number(reader.columnNumber())); - return ParseFailure; -//! [1] - -//! [2] - } else - writer.writeCurrentToken(reader); - } -//! [2] - - return Success; -} diff --git a/examples/xml/xmlstreamlint/xmlstreamlint.pro b/examples/xml/xmlstreamlint/xmlstreamlint.pro deleted file mode 100644 index 90a6387afe..0000000000 --- a/examples/xml/xmlstreamlint/xmlstreamlint.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += cmdline -QT -= gui -SOURCES += main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/xml/xmlstreamlint -INSTALLS += target |