File indexing completed on 2024-05-12 04:39:14

0001 /*
0002     SPDX-FileCopyrightText: 2015 Milian Wolff <mail@milianw.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef UNSAVEDFILE_H
0008 #define UNSAVEDFILE_H
0009 
0010 #include <QStringList>
0011 
0012 #include "clangprivateexport.h"
0013 
0014 struct CXUnsavedFile;
0015 
0016 /**
0017  * Wrapper API to map unsaved editor contents to the CXUnsavedFile API for clang.
0018  */
0019 class KDEVCLANGPRIVATE_EXPORT UnsavedFile
0020 {
0021 public:
0022     explicit UnsavedFile(const QString& fileName = {}, const QStringList& contents = {});
0023 
0024     CXUnsavedFile toClangApi() const;
0025 
0026 private:
0027     QString m_fileName;
0028     QStringList m_contents;
0029     // lazy-loaded byte arrays for usage in clang API
0030     void convertToUtf8();
0031     QByteArray m_fileNameUtf8;
0032     QByteArray m_contentsUtf8;
0033 };
0034 
0035 Q_DECLARE_TYPEINFO(UnsavedFile, Q_MOVABLE_TYPE);
0036 
0037 #endif // UNSAVEDFILE_H