core
lib
Utilities
EnumIterator.hpp
Go to the documentation of this file.
1
//==============================================================================
2
//
3
// This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4
//
5
// The GNSSTk is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU Lesser General Public License as published
7
// by the Free Software Foundation; either version 3.0 of the License, or
8
// any later version.
9
//
10
// The GNSSTk is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with GNSSTk; if not, write to the Free Software Foundation,
17
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18
//
19
// This software was developed by Applied Research Laboratories at the
20
// University of Texas at Austin.
21
// Copyright 2004-2022, The Board of Regents of The University of Texas System
22
//
23
//==============================================================================
24
25
//==============================================================================
26
//
27
// This software was developed by Applied Research Laboratories at the
28
// University of Texas at Austin, under contract to an agency or agencies
29
// within the U.S. Department of Defense. The U.S. Government retains all
30
// rights to use, duplicate, distribute, disclose, or release this software.
31
//
32
// Pursuant to DoD Directive 523024
33
//
34
// DISTRIBUTION STATEMENT A: This software has been approved for public
35
// release, distribution is unlimited.
36
//
37
//==============================================================================
38
39
// Adapted from a post on stackoverflow.com
40
41
#ifndef GNSSTK_ENUMITERATOR_HPP
42
#define GNSSTK_ENUMITERATOR_HPP
43
44
#include <type_traits>
45
46
namespace
gnsstk
47
{
67
template
<
typename
C, C beginVal, C endVal>
68
class
EnumIterator
69
{
71
typedef
typename
std::underlying_type<C>::type
ValType
;
73
ValType
val
;
74
public
:
77
EnumIterator
()
78
:
val
(static_cast<
ValType
>(beginVal))
79
{}
81
EnumIterator
(
const
C& f)
82
:
val
(static_cast<
ValType
>(f))
83
{}
89
EnumIterator
&
operator++
()
90
{
91
val
++;
92
return
*
this
;
93
}
95
C
operator*
()
96
{
return
static_cast<
C
>
(
val
); }
99
EnumIterator
begin
()
100
{
return
*
this
; }
102
EnumIterator
end
()
103
{
104
static
const
EnumIterator
endIter =
EnumIterator
(endVal);
105
return
endIter;
106
}
108
bool
operator!=
(
const
EnumIterator
& i)
109
{
return
val
!= i.
val
; }
110
};
111
}
112
113
#endif // GNSSTK_ENUMITERATOR_HPP
gnsstk::EnumIterator::EnumIterator
EnumIterator(const C &f)
Initialize the iterator to a specific value.
Definition:
EnumIterator.hpp:81
gnsstk::EnumIterator::operator++
EnumIterator & operator++()
Definition:
EnumIterator.hpp:89
gnsstk::EnumIterator::val
ValType val
Current iterator value.
Definition:
EnumIterator.hpp:73
gnsstk::EnumIterator::EnumIterator
EnumIterator()
Definition:
EnumIterator.hpp:77
gnsstk
For Sinex::InputHistory.
Definition:
BasicFramework.cpp:50
gnsstk::EnumIterator::operator!=
bool operator!=(const EnumIterator &i)
Comparison to assist in iteration.
Definition:
EnumIterator.hpp:108
gnsstk::EnumIterator::begin
EnumIterator begin()
Definition:
EnumIterator.hpp:99
gnsstk::EnumIterator::operator*
C operator*()
Dereference the iterator by returning the current enum value.
Definition:
EnumIterator.hpp:95
gnsstk::EnumIterator
Definition:
EnumIterator.hpp:68
gnsstk::EnumIterator::ValType
std::underlying_type< C >::type ValType
Value type as derived from the enum typename.
Definition:
EnumIterator.hpp:71
gnsstk::EnumIterator::end
EnumIterator end()
Iterator end value.
Definition:
EnumIterator.hpp:102
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39