/usr/include/hfst/parsers/VariableValueIterator.h is in libhfst-dev 3.13.0~r3461-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | //! @file VariableValueIterator.h
//!
//! @author Miikka Silfverberg
//!
//! @brief Iterator for container of type @a VariableValue.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the Licence.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef VARIABLE_VALUE_ITERATOR_H_
#define VARIABLE_VALUE_ITERATOR_H_
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
class VariableValues;
//! @brief Iterator for container of type @a VariableValues.
template <class IT> class VariableValueIterator
{
protected:
std::string variable;
IT it;
static VariableValueIterator begin(const std::string &variable,
const std::vector<std::string> &v)
{ return VariableValueIterator<IT>(variable,v.begin()); }
static VariableValueIterator end(const std::string &variable,
const std::vector<std::string> &v)
{ return VariableValueIterator<IT>(variable,v.end()); }
VariableValueIterator(const std::string &variable,const IT &it):
variable(variable), it(it)
{};
public:
//! @brief Initialize empty instance.
VariableValueIterator(void) {}
//! @brief Copy construct from @a another.
VariableValueIterator(const VariableValueIterator<IT> &another):
variable(another.variable), it(another.it)
{}
//! @brief Assign @a another.
VariableValueIterator &operator=(const VariableValueIterator<IT> &another)
{
if (! (this == &another))
{
variable = another.variable;
it = another.it;
}
return *this;
}
//! @brief Test equality with another.
bool operator==(const VariableValueIterator<IT> &another) const
{ return variable == another.variable && it == another.it; }
//! @brief Test unequality with another.
bool operator!=(const VariableValueIterator<IT> &another) const
{ return ! (*this == another); }
//! Increment.
void operator++(void)
{ ++it; }
//! Return an iterator which points @a i steps further than @a this.
VariableValueIterator<IT> operator+(size_t i) const
{
VariableValueIterator<IT> vvit(*this);
for (size_t n = 0; n < i; ++n) { ++vvit; }
return vvit;
}
//! @brief Return the number of incrementations needed to make @a this point
//! to the same position as @a another.
int operator-(const VariableValueIterator<IT> &another)
{ return it - another.it; }
//! @brief Set the value of the variable of the underlying container to the
//! its value.
void set_values(VariableValueMap * vvm) const
{ vvm->operator[](variable) = *it; }
friend class VariableValues;
};
//! @brief Const version of @a VariableValueIterator.
typedef VariableValueIterator<std::vector<std::string>::const_iterator>
ConstVariableValueIterator;
#endif // VARIABLE_VALUE_ITERATOR_H_
|