BaseTextDocument Class

class Core::BaseTextDocument

The BaseTextDocument class is a very general base class for documents that work with text. More...

Header: #include <coreplugin/textdocument.h>
Inherits: Core::IDocument

Public Functions

Utils::TextFileFormat format() const
Core::BaseTextDocument::ReadResult read(const QString &fileName, QStringList *plainTextList, QString *errorString)
Core::BaseTextDocument::ReadResult read(const QString &fileName, QString *plainText, QString *errorString)
bool write(const QString &fileName, const QString &data, QString *errorMessage) const
bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const

Detailed Description

This class contains helper methods for saving and reading text files with encoding and line ending settings.

See also Utils::TextFileFormat.

Member Function Documentation

Utils::TextFileFormat BaseTextDocument::format() const

Returns the format obtained from the last call to read().

Core::BaseTextDocument::ReadResult BaseTextDocument::read(const QString &fileName, QStringList *plainTextList, QString *errorString)

Autodetects file format and reads the text file specified by fileName into a list of strings specified by plainTextList.

If an error occurs while writing the file, errorString is set to the error details.

Returns whether the operation was successful.

Core::BaseTextDocument::ReadResult BaseTextDocument::read(const QString &fileName, QString *plainText, QString *errorString)

Autodetects file format and reads the text file specified by fileName into plainText.

If an error occurs while writing the file, errorString is set to the error details.

Returns whether the operation was successful.

bool BaseTextDocument::write(const QString &fileName, const QString &data, QString *errorMessage) const

Writes out the contents (data) of the text file fileName. Uses the format obtained from the last read() of the file.

If an error occurs while writing the file, errorMessage is set to the error details.

Returns whether the operation was successful.

bool BaseTextDocument::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const

Writes out the contents (data) of the text file fileName. Uses the custom format format.

If an error occurs while writing the file, errorMessage is set to the error details.

Returns whether the operation was successful.

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.