This file is indexed.

/usr/include/dune/common/misc.hh is in libdune-common-dev 2.2.1-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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set ts=8 sw=2 et sts=2:
#ifndef MISC_HH
#define MISC_HH

/** \file
    \brief Miscellaneous helper stuff
*/

#include <algorithm>
#include <cstddef>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <sstream>
#include <complex>

#include <dune/common/deprecated.hh>
#include "exceptions.hh"
#include <dune/common/typetraits.hh>

namespace Dune {


/** @addtogroup Common

        @{
 */

//! compute conjugate complex of x
// conjugate complex does nothing for non-complex types
template<class K>
inline K conjugateComplex (const K& x)
{
    return x;
}

#ifndef DOXYGEN
// specialization for complex
template<class K>
inline std::complex<K> conjugateComplex (const std::complex<K>& c)
{
    return std::complex<K>(c.real(),-c.imag());
}
#endif

//! Return the sign of the value
template <class T>
int sign(const T& val) 
{
  return (val < 0 ? -1 : 1);
}

/** \brief Compute the square of T */
/**
 * \code
#include <dune/common/misc.hh>
 * \endcode
 */
template<class T>
T SQR (T t)
{
  return t*t;
}

//! Calculates m^p at compile time
template <int m, int p> 
struct Power_m_p
{
  // power stores m^p
  enum { power = (m * Power_m_p<m,p-1>::power ) };
};

//! end of recursion via specialization
template <int m> 
struct Power_m_p< m , 0>
{
  // m^0 = 1
  enum { power = 1 };
};

//! Calculates the factorial of m at compile time
template <int m> 
struct Factorial
{
  //! factorial stores m! 
  enum { factorial = m * Factorial<m-1>::factorial };
};

//! end of recursion of factorial via specialization
template <> 
struct Factorial<0>
{
  // 0! = 1
  enum { factorial = 1 };
};

//********************************************************************
//
// generate filenames with timestep number in it 
//
//********************************************************************

    /** \brief Generate filenames with timestep number in it */
inline std::string genFilename(const std::string& path, 
                               const std::string& fn, 
                               int ntime, 
                               int precision = 6)
{
  std::ostringstream name;

  if(path.size() > 0)
  {
    name << path; 
    name << "/"; 
  }
  name << fn << std::setw(precision) << std::setfill('0') << ntime;
 
  // Return the string corresponding to the stringstream
  return name.str();
}
    

//********************************************************************
//
//  check whether a given container has a prefix/suffix
//
//********************************************************************

//! check whether a character container has a given prefix
/**
 * The container must support the the begin() and size() methods.
 */
template<typename C>
bool hasPrefix(const C& c, const char* prefix) {
  std::size_t len = std::strlen(prefix);
  return c.size() >= len &&
    std::equal(prefix, prefix+len, c.begin());
}

//! check whether a character container has a given suffix
/**
 * The container must support the the begin() and size() methods and the
 * const_iterator member type.
 *
 * \note This is slow for containers which don't have random access iterators.
 *       In the case of containers with bidirectional iterators, this
 *       slow-ness is unnecessary.
 */
template<typename C>
bool hasSuffix(const C& c, const char* suffix) {
  std::size_t len = std::strlen(suffix);
  if(c.size() < len) return false;
  typename C::const_iterator it = c.begin();
  std::advance(it, c.size() - len);
  return std::equal(suffix, suffix+len, it);
}
/** @} */

}


#endif