Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
documentwriter.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef DOCUMENTWRITER_H
5#define DOCUMENTWRITER_H
6
7#include <QtCore/qstring.h>
8#include <QtCore/qstringview.h>
9
10QT_BEGIN_NAMESPACE
11
12/*!
13 \class DocumentWriter
14 \internal
15 \brief Interface for writing documentation output.
16
17 DocumentWriter abstracts the output destination for documentation
18 generators, enabling:
19
20 \list
21 \li Unit testing with in-memory writers (StringDocumentWriter)
22 \li Production file-based output (FileDocumentWriter)
23 \li Future extensions (network, database, etc.)
24 \endlist
25
26 This interface replaces Generator::out() which was coupled to a
27 QTextStream stack managed by beginSubPage()/endSubPage().
28
29 \section1 Usage Pattern
30
31 \code
32 void generateDocument(DocumentWriter &writer) {
33 writer.write("<html>");
34 writer.writeLine("<body>");
35 writer.write("Content here");
36 writer.writeLine("</body></html>");
37 }
38 \endcode
39
40 \sa FileDocumentWriter, StringDocumentWriter
41*/
42class DocumentWriter
43{
44public:
45 virtual ~DocumentWriter() = default;
46
47 /*!
48 Writes \a content to the output without a trailing newline.
49 */
50 virtual void write(QStringView content) = 0;
51
52 /*!
53 Writes \a content to the output followed by a newline.
54 */
55 virtual void writeLine(QStringView content = {}) = 0;
56
57 /*!
58 Returns \c true if a document is currently open for writing.
59 */
60 [[nodiscard]] virtual bool isOpen() const = 0;
61
62 /*!
63 Returns the file name of the currently open document,
64 or an empty string if no document is open.
65 */
66 [[nodiscard]] virtual QString currentFileName() const = 0;
67};
68
69QT_END_NAMESPACE
70
71#endif // DOCUMENTWRITER_H
The Location class provides a way to mark a location in a file.
Definition location.h:20
Location()
Constructs an empty location.
Definition location.cpp:48
Combined button and popup list for selecting options.
Bundles output configuration without static variables.