![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
Production implementation of DocumentWriter that writes to files. More...
#include <filedocumentwriter.h>
Public Member Functions | |
| FileDocumentWriter (OutputContext context) | |
| The constructor takes a context. | |
| ~FileDocumentWriter () override | |
| The destructor ensures a call to endDocument before the object is destroyed. | |
| FileDocumentWriter (const FileDocumentWriter &)=delete | |
| FileDocumentWriter & | operator= (const FileDocumentWriter &)=delete |
| FileDocumentWriter (FileDocumentWriter &&) noexcept=default | |
| FileDocumentWriter & | operator= (FileDocumentWriter &&) noexcept=default |
| void | beginDocument (const QString &fileName) |
| Opens a new document with the given fileName for writing. | |
| void | endDocument () |
| Closes the current document, flushing any buffered content. | |
| void | write (QStringView content) override |
| Writes content to the output without a trailing newline. | |
| void | writeLine (QStringView content) override |
| Writes content to the output followed by a newline. | |
| bool | isOpen () const override |
Returns true if a document is currently open for writing. | |
| QString | currentFileName () const override |
| Returns the file name of the currently open document, or an empty string if no document is open. | |
| const OutputContext & | context () const |
| Returns the output context used by this writer. | |
| Public Member Functions inherited from DocumentWriter | |
| virtual | ~DocumentWriter ()=default |
Production implementation of DocumentWriter that writes to files.
FileDocumentWriter manages the lifecycle of output files, replacing the Generator's beginSubPage()/endSubPage() pattern with an explicit interface.
If the file cannot be opened, beginDocument() reports an error and subsequent write calls become no-ops.
Definition at line 17 of file filedocumentwriter.h.
|
explicit |
The constructor takes a context.
Definition at line 52 of file filedocumentwriter.cpp.
|
override |
The destructor ensures a call to endDocument before the object is destroyed.
Definition at line 62 of file filedocumentwriter.cpp.
|
delete |
|
defaultnoexcept |
Opens a new document with the given fileName for writing.
If a document is already open, it will be closed first.
Definition at line 72 of file filedocumentwriter.cpp.
References Location::Location().
|
inlinenodiscard |
Returns the output context used by this writer.
Definition at line 37 of file filedocumentwriter.h.
|
nodiscardoverridevirtual |
Returns the file name of the currently open document, or an empty string if no document is open.
Implements DocumentWriter.
Definition at line 137 of file filedocumentwriter.cpp.
| void FileDocumentWriter::endDocument | ( | ) |
Closes the current document, flushing any buffered content.
Safe to call even if no document is open.
Definition at line 107 of file filedocumentwriter.cpp.
|
nodiscardoverridevirtual |
Returns true if a document is currently open for writing.
Implements DocumentWriter.
Definition at line 132 of file filedocumentwriter.cpp.
|
delete |
|
defaultnoexcept |
|
overridevirtual |
Writes content to the output without a trailing newline.
Implements DocumentWriter.
Definition at line 120 of file filedocumentwriter.cpp.
|
overridevirtual |
Writes content to the output followed by a newline.
Implements DocumentWriter.
Definition at line 126 of file filedocumentwriter.cpp.