1/*
2 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#include "foldingregion.h"
8
9using namespace KSyntaxHighlighting;
10
11static_assert(sizeof(FoldingRegion) == sizeof(int), "FoldingRegion is size-sensitive to frequent use in KTextEditor!");
12
13FoldingRegion::FoldingRegion() = default;
14
15FoldingRegion::FoldingRegion(Type type, int id)
16 : m_idWithType((type == End) ? -id : id)
17{
18}
19
20bool FoldingRegion::operator==(const FoldingRegion &other) const
21{
22 return m_idWithType == other.m_idWithType;
23}
24
25bool FoldingRegion::isValid() const
26{
27 return m_idWithType != 0;
28}
29
30int FoldingRegion::id() const
31{
32 return (m_idWithType < 0) ? -m_idWithType : m_idWithType;
33}
34
35FoldingRegion::Type FoldingRegion::type() const
36{
37 if (isValid()) {
38 return (m_idWithType < 0) ? End : Begin;
39 }
40 return None;
41}
42
43FoldingRegion FoldingRegion::sibling() const
44{
45 return isValid() ? FoldingRegion(type() ? End : Begin, id()) : FoldingRegion();
46}
47

source code of syntax-highlighting/src/lib/foldingregion.cpp