BaseTextDocument Class
(Core::BaseTextDocument)The BaseTextDocument class is a very general base class for documents that work with text. More...
Header: | #include <BaseTextDocument> |
Inherits: | Core::IDocument |
Public Types
typedef | ReadResult |
Public Functions
BaseTextDocument(QObject *parent = nullptr) | |
virtual | ~BaseTextDocument() override |
const QTextCodec * | codec() const |
QByteArray | decodingErrorSample() const |
Utils::TextFileFormat | format() const |
bool | hasDecodingError() const |
Utils::TextFileFormat::LineTerminationMode | lineTerminationMode() const |
Core::BaseTextDocument::ReadResult | read(const QString &fileName, QStringList *plainTextList, QString *errorString) |
Core::BaseTextDocument::ReadResult | read(const QString &fileName, QString *plainText, QString *errorString) |
void | setCodec(const QTextCodec *) |
void | setLineTerminationMode(Utils::TextFileFormat::LineTerminationMode mode) |
void | setSupportsUtf8Bom(bool value) |
bool | supportsUtf8Bom() const |
void | switchUtf8Bom() |
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 |
- 33 public functions inherited from Core::IDocument
Additional Inherited Members
- 6 signals inherited from Core::IDocument
Detailed Description
The BaseTextDocument class is a very general base class for documents that work with text.
This class contains helper methods for saving and reading text files with encoding and line ending settings.
See also Utils::TextFileFormat.
Member Function Documentation
BaseTextDocument::BaseTextDocument(QObject *parent = nullptr)
Default constructs an instance of BaseTextDocument.
[override virtual]
BaseTextDocument::~BaseTextDocument()
Destroys the instance of BaseTextDocument. The destructor is virtual.
const QTextCodec *BaseTextDocument::codec() const
See also setCodec().
QByteArray BaseTextDocument::decodingErrorSample() const
Utils::TextFileFormat BaseTextDocument::format() const
Returns the format obtained from the last call to read().
bool BaseTextDocument::hasDecodingError() const
Utils::TextFileFormat::LineTerminationMode BaseTextDocument::lineTerminationMode() const
See also setLineTerminationMode().
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.
void BaseTextDocument::setCodec(const QTextCodec *)
See also codec().
void BaseTextDocument::setLineTerminationMode(Utils::TextFileFormat::LineTerminationMode mode)
See also lineTerminationMode().
void BaseTextDocument::setSupportsUtf8Bom(bool value)
See also supportsUtf8Bom().
bool BaseTextDocument::supportsUtf8Bom() const
See also setSupportsUtf8Bom().
void BaseTextDocument::switchUtf8Bom()
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.