Commit 2fc604e6 authored by Marco Bubke's avatar Marco Bubke

Clang: Fix operator <

It is actually not used but have to be implemented because
QMetaType::registerComparators expect == and <.

Change-Id: Ia93e2e7bd856d1962b683482e42ace4136d9bf34
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent 9f2ed3b9
......@@ -36,6 +36,10 @@
#include <ostream>
#include <algorithm>
#include <container_common.h>
namespace CodeModelBackEnd {
RegisterProjectPartsForCodeCompletionCommand::RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers)
......@@ -69,7 +73,7 @@ bool operator==(const RegisterProjectPartsForCodeCompletionCommand &first, const
bool operator<(const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second)
{
return first.projectContainers_ < second.projectContainers_;
return compareContainer(first.projectContainers_, second.projectContainers_);
}
QDebug operator<<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command)
......
......@@ -36,6 +36,8 @@
#include <ostream>
#include <container_common.h>
namespace CodeModelBackEnd {
RegisterTranslationUnitForCodeCompletionCommand::RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers)
......@@ -69,7 +71,7 @@ bool operator==(const RegisterTranslationUnitForCodeCompletionCommand &first, co
bool operator<(const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second)
{
return first.fileContainers_ < second.fileContainers_;
return compareContainer(first.fileContainers_, second.fileContainers_);
}
QDebug operator<<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command)
......
......@@ -36,6 +36,8 @@
#include <ostream>
#include <container_common.h>
namespace CodeModelBackEnd {
......@@ -70,7 +72,7 @@ bool operator==(const UnregisterProjectPartsForCodeCompletionCommand &first, con
bool operator<(const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second)
{
return first.filePaths_ < second.filePaths_;
return compareContainer(first.filePaths_, second.filePaths_);
}
QDebug operator<<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command)
......
......@@ -38,6 +38,8 @@
#include <QDataStream>
#include <container_common.h>
namespace CodeModelBackEnd {
......@@ -72,7 +74,7 @@ bool operator==(const UnregisterTranslationUnitsForCodeCompletionCommand &first,
bool operator<(const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second)
{
return first.fileContainers_ < second.fileContainers_;
return compareContainer(first.fileContainers_, second.fileContainers_);
}
QDebug operator<<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command)
......
......@@ -67,6 +67,7 @@ HEADERS += $$PWD/codemodelbackendipc_global.h \
$$PWD/translationunitdoesnotexistcommand.h \
$$PWD/codecompletionchunk.h \
$$PWD/projectpartcontainer.h \
$$PWD/projectpartsdonotexistcommand.h
$$PWD/projectpartsdonotexistcommand.h \
$$PWD/container_common.h
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://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 http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CONTAINER_COMMON_H
#define CONTAINER_COMMON_H
namespace CodeModelBackEnd {
template <typename Container>
bool compareContainer(const Container &first, const Container &second)
{
if (first.size() != second.size())
return first.size() < second.size();
Container firstCopy = first;
Container secondCopy = second;
std::sort(firstCopy.begin(), firstCopy.end());
std::sort(secondCopy.begin(), secondCopy.end());
auto isProjectPartContainerSmaller = [] (decltype(*first.cbegin()) &firstElement,
decltype(*second.cbegin()) &secondElement) {
return firstElement < secondElement;
};
return std::equal(firstCopy.cbegin(),
firstCopy.cend(),
secondCopy.cbegin(),
isProjectPartContainerSmaller);
}
}
#endif // CONTAINER_COMMON_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment