/src/libreoffice/include/o3tl/enumrange.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_O3TL_ENUMRANGE_HXX |
21 | | #define INCLUDED_O3TL_ENUMRANGE_HXX |
22 | | |
23 | | namespace o3tl { |
24 | | |
25 | | /// |
26 | | /// This is a container convenience class iterating over scoped enumerations. |
27 | | /// |
28 | | /// This assumes that the 'enum class' definition |
29 | | /// - starts at zero |
30 | | /// - has no holes in its sequence of values |
31 | | /// - defines a value called LAST which refers to the greatest constant. |
32 | | /// |
33 | | /// Use like this: |
34 | | /// enum class COLOR { RED, GREEN, BLUE, LAST=BLUE }; |
35 | | /// for( auto e : o3tl::enumrange<Color>() ) |
36 | | /// ....; |
37 | | /// |
38 | | /// \param T the 'enum class' type. |
39 | | template< typename T> |
40 | | class enumrange |
41 | | { |
42 | | public: |
43 | | class Iterator |
44 | | { |
45 | | public: |
46 | | Iterator( int value ) : |
47 | 319k | m_value( value ) |
48 | 319k | { |
49 | 319k | } Unexecuted instantiation: o3tl::enumrange<VclPackType>::Iterator::Iterator(int) Unexecuted instantiation: hdrcont.cxx:o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>::Iterator::Iterator(int) Unexecuted instantiation: o3tl::enumrange<model::ThemeColorType>::Iterator::Iterator(int) o3tl::enumrange<SvxBoxItemLine>::Iterator::Iterator(int) Line | Count | Source | 47 | 2.07k | m_value( value ) | 48 | 2.07k | { | 49 | 2.07k | } |
o3tl::enumrange<TSS_Type>::Iterator::Iterator(int) Line | Count | Source | 47 | 42.0k | m_value( value ) | 48 | 42.0k | { | 49 | 42.0k | } |
o3tl::enumrange<XPropertyListType>::Iterator::Iterator(int) Line | Count | Source | 47 | 270k | m_value( value ) | 48 | 270k | { | 49 | 270k | } |
o3tl::enumrange<GlobalEventId>::Iterator::Iterator(int) Line | Count | Source | 47 | 12 | m_value( value ) | 48 | 12 | { | 49 | 12 | } |
Unexecuted instantiation: o3tl::enumrange<vcl::ImageType>::Iterator::Iterator(int) Unexecuted instantiation: o3tl::enumrange<SwFieldGroup>::Iterator::Iterator(int) o3tl::enumrange<SwFieldTypesEnum>::Iterator::Iterator(int) Line | Count | Source | 47 | 2 | m_value( value ) | 48 | 2 | { | 49 | 2 | } |
Unexecuted instantiation: o3tl::enumrange<ContentTypeId>::Iterator::Iterator(int) o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>::Iterator::Iterator(int) Line | Count | Source | 47 | 4.96k | m_value( value ) | 48 | 4.96k | { | 49 | 4.96k | } |
Unexecuted instantiation: o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>::Iterator::Iterator(int) |
50 | | |
51 | | T operator*( void ) const |
52 | 1.15M | { |
53 | 1.15M | return static_cast<T>(m_value); |
54 | 1.15M | } Unexecuted instantiation: o3tl::enumrange<VclPackType>::Iterator::operator*() const Unexecuted instantiation: hdrcont.cxx:o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>::Iterator::operator*() const Unexecuted instantiation: o3tl::enumrange<model::ThemeColorType>::Iterator::operator*() const o3tl::enumrange<SvxBoxItemLine>::Iterator::operator*() const Line | Count | Source | 52 | 4.15k | { | 53 | 4.15k | return static_cast<T>(m_value); | 54 | 4.15k | } |
o3tl::enumrange<TSS_Type>::Iterator::operator*() const Line | Count | Source | 52 | 189k | { | 53 | 189k | return static_cast<T>(m_value); | 54 | 189k | } |
o3tl::enumrange<XPropertyListType>::Iterator::operator*() const Line | Count | Source | 52 | 945k | { | 53 | 945k | return static_cast<T>(m_value); | 54 | 945k | } |
o3tl::enumrange<GlobalEventId>::Iterator::operator*() const Line | Count | Source | 52 | 168 | { | 53 | 168 | return static_cast<T>(m_value); | 54 | 168 | } |
Unexecuted instantiation: o3tl::enumrange<vcl::ImageType>::Iterator::operator*() const Unexecuted instantiation: o3tl::enumrange<SwFieldGroup>::Iterator::operator*() const o3tl::enumrange<SwFieldTypesEnum>::Iterator::operator*() const Line | Count | Source | 52 | 45 | { | 53 | 45 | return static_cast<T>(m_value); | 54 | 45 | } |
Unexecuted instantiation: o3tl::enumrange<ContentTypeId>::Iterator::operator*() const o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>::Iterator::operator*() const Line | Count | Source | 52 | 14.8k | { | 53 | 14.8k | return static_cast<T>(m_value); | 54 | 14.8k | } |
Unexecuted instantiation: o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>::Iterator::operator*() const |
55 | | |
56 | | void operator++( void ) |
57 | 1.15M | { |
58 | 1.15M | ++m_value; |
59 | 1.15M | } Unexecuted instantiation: o3tl::enumrange<VclPackType>::Iterator::operator++() Unexecuted instantiation: hdrcont.cxx:o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>::Iterator::operator++() Unexecuted instantiation: o3tl::enumrange<model::ThemeColorType>::Iterator::operator++() o3tl::enumrange<SvxBoxItemLine>::Iterator::operator++() Line | Count | Source | 57 | 4.15k | { | 58 | 4.15k | ++m_value; | 59 | 4.15k | } |
o3tl::enumrange<TSS_Type>::Iterator::operator++() Line | Count | Source | 57 | 189k | { | 58 | 189k | ++m_value; | 59 | 189k | } |
o3tl::enumrange<XPropertyListType>::Iterator::operator++() Line | Count | Source | 57 | 945k | { | 58 | 945k | ++m_value; | 59 | 945k | } |
o3tl::enumrange<GlobalEventId>::Iterator::operator++() Line | Count | Source | 57 | 168 | { | 58 | 168 | ++m_value; | 59 | 168 | } |
Unexecuted instantiation: o3tl::enumrange<vcl::ImageType>::Iterator::operator++() Unexecuted instantiation: o3tl::enumrange<SwFieldGroup>::Iterator::operator++() o3tl::enumrange<SwFieldTypesEnum>::Iterator::operator++() Line | Count | Source | 57 | 45 | { | 58 | 45 | ++m_value; | 59 | 45 | } |
Unexecuted instantiation: o3tl::enumrange<ContentTypeId>::Iterator::operator++() o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>::Iterator::operator++() Line | Count | Source | 57 | 14.8k | { | 58 | 14.8k | ++m_value; | 59 | 14.8k | } |
Unexecuted instantiation: o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>::Iterator::operator++() |
60 | | |
61 | | bool operator!=( Iterator rhs ) const |
62 | 1.31M | { |
63 | 1.31M | return m_value != rhs.m_value; |
64 | 1.31M | } Unexecuted instantiation: o3tl::enumrange<VclPackType>::Iterator::operator!=(o3tl::enumrange<VclPackType>::Iterator) const Unexecuted instantiation: hdrcont.cxx:o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>::Iterator::operator!=(o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>::Iterator) const Unexecuted instantiation: o3tl::enumrange<model::ThemeColorType>::Iterator::operator!=(o3tl::enumrange<model::ThemeColorType>::Iterator) const o3tl::enumrange<SvxBoxItemLine>::Iterator::operator!=(o3tl::enumrange<SvxBoxItemLine>::Iterator) const Line | Count | Source | 62 | 5.19k | { | 63 | 5.19k | return m_value != rhs.m_value; | 64 | 5.19k | } |
o3tl::enumrange<TSS_Type>::Iterator::operator!=(o3tl::enumrange<TSS_Type>::Iterator) const Line | Count | Source | 62 | 210k | { | 63 | 210k | return m_value != rhs.m_value; | 64 | 210k | } |
o3tl::enumrange<XPropertyListType>::Iterator::operator!=(o3tl::enumrange<XPropertyListType>::Iterator) const Line | Count | Source | 62 | 1.08M | { | 63 | 1.08M | return m_value != rhs.m_value; | 64 | 1.08M | } |
o3tl::enumrange<GlobalEventId>::Iterator::operator!=(o3tl::enumrange<GlobalEventId>::Iterator) const Line | Count | Source | 62 | 174 | { | 63 | 174 | return m_value != rhs.m_value; | 64 | 174 | } |
Unexecuted instantiation: o3tl::enumrange<vcl::ImageType>::Iterator::operator!=(o3tl::enumrange<vcl::ImageType>::Iterator) const Unexecuted instantiation: o3tl::enumrange<SwFieldGroup>::Iterator::operator!=(o3tl::enumrange<SwFieldGroup>::Iterator) const o3tl::enumrange<SwFieldTypesEnum>::Iterator::operator!=(o3tl::enumrange<SwFieldTypesEnum>::Iterator) const Line | Count | Source | 62 | 46 | { | 63 | 46 | return m_value != rhs.m_value; | 64 | 46 | } |
Unexecuted instantiation: o3tl::enumrange<ContentTypeId>::Iterator::operator!=(o3tl::enumrange<ContentTypeId>::Iterator) const o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>::Iterator::operator!=(o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>::Iterator) const Line | Count | Source | 62 | 17.3k | { | 63 | 17.3k | return m_value != rhs.m_value; | 64 | 17.3k | } |
Unexecuted instantiation: o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>::Iterator::operator!=(o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>::Iterator) const |
65 | | |
66 | | private: |
67 | | int m_value; |
68 | | }; |
69 | | }; |
70 | | |
71 | | template< typename T > |
72 | | typename enumrange<T>::Iterator begin( enumrange<T> ) |
73 | 159k | { |
74 | 159k | return typename enumrange<T>::Iterator( int(0) ); |
75 | 159k | } Unexecuted instantiation: o3tl::enumrange<VclPackType>::Iterator o3tl::begin<VclPackType>(o3tl::enumrange<VclPackType>) Unexecuted instantiation: hdrcont.cxx:o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>::Iterator o3tl::begin<(anonymous namespace)::HeaderPaintPass>(o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>) Unexecuted instantiation: o3tl::enumrange<model::ThemeColorType>::Iterator o3tl::begin<model::ThemeColorType>(o3tl::enumrange<model::ThemeColorType>) o3tl::enumrange<SvxBoxItemLine>::Iterator o3tl::begin<SvxBoxItemLine>(o3tl::enumrange<SvxBoxItemLine>) Line | Count | Source | 73 | 1.03k | { | 74 | 1.03k | return typename enumrange<T>::Iterator( int(0) ); | 75 | 1.03k | } |
o3tl::enumrange<TSS_Type>::Iterator o3tl::begin<TSS_Type>(o3tl::enumrange<TSS_Type>) Line | Count | Source | 73 | 21.0k | { | 74 | 21.0k | return typename enumrange<T>::Iterator( int(0) ); | 75 | 21.0k | } |
o3tl::enumrange<XPropertyListType>::Iterator o3tl::begin<XPropertyListType>(o3tl::enumrange<XPropertyListType>) Line | Count | Source | 73 | 135k | { | 74 | 135k | return typename enumrange<T>::Iterator( int(0) ); | 75 | 135k | } |
o3tl::enumrange<GlobalEventId>::Iterator o3tl::begin<GlobalEventId>(o3tl::enumrange<GlobalEventId>) Line | Count | Source | 73 | 6 | { | 74 | 6 | return typename enumrange<T>::Iterator( int(0) ); | 75 | 6 | } |
Unexecuted instantiation: o3tl::enumrange<vcl::ImageType>::Iterator o3tl::begin<vcl::ImageType>(o3tl::enumrange<vcl::ImageType>) Unexecuted instantiation: o3tl::enumrange<SwFieldGroup>::Iterator o3tl::begin<SwFieldGroup>(o3tl::enumrange<SwFieldGroup>) o3tl::enumrange<SwFieldTypesEnum>::Iterator o3tl::begin<SwFieldTypesEnum>(o3tl::enumrange<SwFieldTypesEnum>) Line | Count | Source | 73 | 1 | { | 74 | 1 | return typename enumrange<T>::Iterator( int(0) ); | 75 | 1 | } |
Unexecuted instantiation: o3tl::enumrange<ContentTypeId>::Iterator o3tl::begin<ContentTypeId>(o3tl::enumrange<ContentTypeId>) o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>::Iterator o3tl::begin<writerfilter::dmapper::BorderHandler::BorderPosition>(o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>) Line | Count | Source | 73 | 2.48k | { | 74 | 2.48k | return typename enumrange<T>::Iterator( int(0) ); | 75 | 2.48k | } |
Unexecuted instantiation: o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>::Iterator o3tl::begin<sd::ToolBarManager::ToolBarGroup>(o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>) |
76 | | |
77 | | template< typename T > |
78 | | typename enumrange<T>::Iterator end( enumrange<T> ) |
79 | 159k | { |
80 | 159k | return typename enumrange<T>::Iterator( static_cast<int>(T::LAST) + 1 ); |
81 | 159k | } Unexecuted instantiation: o3tl::enumrange<VclPackType>::Iterator o3tl::end<VclPackType>(o3tl::enumrange<VclPackType>) Unexecuted instantiation: hdrcont.cxx:o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>::Iterator o3tl::end<(anonymous namespace)::HeaderPaintPass>(o3tl::enumrange<(anonymous namespace)::HeaderPaintPass>) Unexecuted instantiation: o3tl::enumrange<model::ThemeColorType>::Iterator o3tl::end<model::ThemeColorType>(o3tl::enumrange<model::ThemeColorType>) o3tl::enumrange<SvxBoxItemLine>::Iterator o3tl::end<SvxBoxItemLine>(o3tl::enumrange<SvxBoxItemLine>) Line | Count | Source | 79 | 1.03k | { | 80 | 1.03k | return typename enumrange<T>::Iterator( static_cast<int>(T::LAST) + 1 ); | 81 | 1.03k | } |
o3tl::enumrange<TSS_Type>::Iterator o3tl::end<TSS_Type>(o3tl::enumrange<TSS_Type>) Line | Count | Source | 79 | 21.0k | { | 80 | 21.0k | return typename enumrange<T>::Iterator( static_cast<int>(T::LAST) + 1 ); | 81 | 21.0k | } |
o3tl::enumrange<XPropertyListType>::Iterator o3tl::end<XPropertyListType>(o3tl::enumrange<XPropertyListType>) Line | Count | Source | 79 | 135k | { | 80 | 135k | return typename enumrange<T>::Iterator( static_cast<int>(T::LAST) + 1 ); | 81 | 135k | } |
o3tl::enumrange<GlobalEventId>::Iterator o3tl::end<GlobalEventId>(o3tl::enumrange<GlobalEventId>) Line | Count | Source | 79 | 6 | { | 80 | 6 | return typename enumrange<T>::Iterator( static_cast<int>(T::LAST) + 1 ); | 81 | 6 | } |
Unexecuted instantiation: o3tl::enumrange<vcl::ImageType>::Iterator o3tl::end<vcl::ImageType>(o3tl::enumrange<vcl::ImageType>) Unexecuted instantiation: o3tl::enumrange<SwFieldGroup>::Iterator o3tl::end<SwFieldGroup>(o3tl::enumrange<SwFieldGroup>) o3tl::enumrange<SwFieldTypesEnum>::Iterator o3tl::end<SwFieldTypesEnum>(o3tl::enumrange<SwFieldTypesEnum>) Line | Count | Source | 79 | 1 | { | 80 | 1 | return typename enumrange<T>::Iterator( static_cast<int>(T::LAST) + 1 ); | 81 | 1 | } |
Unexecuted instantiation: o3tl::enumrange<ContentTypeId>::Iterator o3tl::end<ContentTypeId>(o3tl::enumrange<ContentTypeId>) o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>::Iterator o3tl::end<writerfilter::dmapper::BorderHandler::BorderPosition>(o3tl::enumrange<writerfilter::dmapper::BorderHandler::BorderPosition>) Line | Count | Source | 79 | 2.48k | { | 80 | 2.48k | return typename enumrange<T>::Iterator( static_cast<int>(T::LAST) + 1 ); | 81 | 2.48k | } |
Unexecuted instantiation: o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>::Iterator o3tl::end<sd::ToolBarManager::ToolBarGroup>(o3tl::enumrange<sd::ToolBarManager::ToolBarGroup>) |
82 | | |
83 | | }; // namespace o3tl |
84 | | |
85 | | #endif /* INCLUDED_O3TL_ENUMRANGE_HXX */ |
86 | | |
87 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |