2016-01-11 15:20:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-01-28 18:31:05 +01:00
|
|
|
#pragma once
|
2016-01-11 15:20:04 +01:00
|
|
|
|
2016-02-01 16:49:08 +01:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
2016-01-11 15:20:04 +01:00
|
|
|
#include <clang-c/Index.h>
|
|
|
|
|
|
2016-01-28 18:31:05 +01:00
|
|
|
#include <iosfwd>
|
2016-01-11 15:20:04 +01:00
|
|
|
|
2016-01-28 18:31:05 +01:00
|
|
|
class Utf8String;
|
2016-01-11 15:20:04 +01:00
|
|
|
|
|
|
|
|
namespace ClangBackEnd {
|
|
|
|
|
|
2016-01-28 18:31:05 +01:00
|
|
|
using uint = unsigned int;
|
|
|
|
|
|
|
|
|
|
class UnsavedFile
|
2016-01-11 15:20:04 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2016-01-28 18:31:05 +01:00
|
|
|
friend void PrintTo(const UnsavedFile &unsavedFile, std::ostream *os);
|
|
|
|
|
|
2016-02-01 16:49:08 +01:00
|
|
|
UnsavedFile();
|
2016-01-28 18:31:05 +01:00
|
|
|
UnsavedFile(const Utf8String &filePath, const Utf8String &fileContent);
|
|
|
|
|
~UnsavedFile();
|
2016-01-11 15:20:04 +01:00
|
|
|
|
2016-01-28 18:31:05 +01:00
|
|
|
UnsavedFile(const UnsavedFile &other) = delete;
|
|
|
|
|
bool operator=(const UnsavedFile &other) = delete;
|
2016-01-11 15:20:04 +01:00
|
|
|
|
2016-02-01 16:49:08 +01:00
|
|
|
UnsavedFile(UnsavedFile &&other) Q_DECL_NOEXCEPT;
|
|
|
|
|
UnsavedFile &operator=(UnsavedFile &&other) Q_DECL_NOEXCEPT;
|
2016-01-11 15:20:04 +01:00
|
|
|
|
2016-01-28 18:31:05 +01:00
|
|
|
const char *filePath() const;
|
2016-01-11 15:20:04 +01:00
|
|
|
|
2016-04-29 11:35:42 +02:00
|
|
|
// 1-based line and column
|
2016-06-23 16:34:03 +02:00
|
|
|
uint toUtf8Position(uint line, uint column, bool *ok) const;
|
2016-04-29 11:35:42 +02:00
|
|
|
bool hasCharacterAt(uint line, uint column, char character) const;
|
2016-01-28 18:43:14 +01:00
|
|
|
bool hasCharacterAt(uint position, char character) const;
|
2016-01-28 18:31:05 +01:00
|
|
|
bool replaceAt(uint position, uint length, const Utf8String &replacement);
|
2016-01-11 15:20:04 +01:00
|
|
|
|
2016-01-28 18:31:05 +01:00
|
|
|
CXUnsavedFile *data();
|
|
|
|
|
|
|
|
|
|
public: // for tests
|
2016-02-01 16:49:08 +01:00
|
|
|
CXUnsavedFile cxUnsavedFile;
|
2016-01-11 15:20:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace ClangBackEnd
|