/usr/include/CCfits/FITSUtilT.h is in libccfits-dev 2.4+dfsg-5.
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 | // Astrophysics Science Division,
// NASA/ Goddard Space Flight Center
// HEASARC
// http://heasarc.gsfc.nasa.gov
// e-mail: ccfits@legacy.gsfc.nasa.gov
//
// Original author: Ben Dorman
#ifndef FITSUTILT_H
#define FITSUTILT_H
#ifdef _MSC_VER
#include "MSconfig.h" // for truncation warning
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "FITSUtil.h"
#include<typeinfo>
#include<iostream>
#ifdef SSTREAM_DEFECT
#include <strstream>
#else
#include<sstream>
#endif
namespace CCfits
{
namespace FITSUtil
{
// vector to vector conversion.
template <typename S, typename T>
void
fill(std::vector<S>& outArray, const std::vector<T>& inArray, size_t first, size_t last)
{
// vector to vector assign. stdlib takes care of deletion.
int range = last - first + 1;
if (outArray.size() != static_cast<size_t>(range)) outArray.resize(range);
for (size_t j = first - 1; j < last; ++j)
{
outArray[j - first + 1] = static_cast<S>(inArray[j]);
}
}
// vector to valarray conversion.
template <typename S, typename T>
void fill(std::valarray<S>& outArray, const std::vector<T>& inArray, size_t first, size_t last)
{
// vector to valarray assign
int range = last - first + 1;
if (outArray.size() != static_cast<size_t>(range)) outArray.resize(range);
for (size_t j = first - 1; j < last; ++j)
{
outArray[j - first + 1] = static_cast<S>(inArray[j]);
}
}
// valarray to valarray conversion.
template <typename S, typename T>
void fill(std::valarray<S>& outArray, const std::valarray<T>& inArray)
{
size_t n = inArray.size();
if (outArray.size() != n) outArray.resize(n);
for (size_t j = 0;j < n; ++j) outArray[j]
= static_cast<S>(inArray[j]);
}
#ifdef TEMPLATE_AMBIG7_DEFECT
template <typename S, typename T>
void fillMSva(std::vector<S>& outArray, const std::valarray<T>& inArray)
{
size_t n = inArray.size();
if (outArray.size() != n) outArray.resize(n);
for (size_t j = 0;j < n; ++j) outArray[j]
= static_cast<S>(inArray[j]);
}
#else
template <typename S, typename T>
void fill(std::vector<S>& outArray, const std::valarray<T>& inArray)
{
size_t n = inArray.size();
if (outArray.size() != n) outArray.resize(n);
for (size_t j = 0;j < n; ++j) outArray[j]
= static_cast<S>(inArray[j]);
}
#endif
// throw exceptions for string conversions to anything other than string.
template <typename T>
void
fill(std::vector<string>& outArray, const std::vector<T>& inArray, size_t first, size_t last)
{
first = 0;
last = 0;
throw InvalidConversion(errorMessage(outArray,inArray),false);
}
template <typename T>
void fill(std::vector<T>& outArray, const std::vector<string>& inArray, size_t first, size_t last)
{
first = 0;
last = 0;
throw InvalidConversion(errorMessage(outArray,inArray),false);
}
template<typename S, typename T>
string errorMessage( const S& out, const T& in)
{
#ifdef SSTREAM_DEFECT
std::ostrstream errMsg;
#else
std::ostringstream errMsg;
#endif
errMsg << " Error: no conversion from " << typeid(in).name() << " to "
<< typeid(out).name() << std::endl;
return errMsg.str();
}
}
} // namespace CCfits
#endif
|