/usr/include/sp/CharMap.h is in libsp1-dev 1.3.4-1.2.1-47.3ubuntu1.
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 | // Copyright (c) 1997 James Clark
// See the file COPYING for copying permission.
#ifndef CharMap_INCLUDED
#define CharMap_INCLUDED 1
#include "types.h"
#include "Resource.h"
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
#ifdef SP_MULTI_BYTE
class CharMapBits {
public:
enum { level1 = 8, level2 = 4, level3 = 4 };
};
template<class T>
class CharMapColumn {
public:
CharMapColumn();
CharMapColumn(const CharMapColumn<T> &);
void operator=(const CharMapColumn<T> &);
~CharMapColumn();
T *values;
T value;
};
template<class T>
class CharMapPage {
public:
CharMapPage();
CharMapPage(const CharMapPage<T> &);
void operator=(const CharMapPage<T> &);
~CharMapPage();
void swap(CharMapPage<T> &);
CharMapColumn<T> *values;
T value;
};
#endif /* SP_MULTI_BYTE */
template<class T>
class CharMap {
public:
CharMap();
CharMap(T);
T operator[](Char) const;
T getRange(Char from, Char &to) const;
void swap(CharMap<T> &);
void setChar(Char, T);
void setRange(Char from, Char to, T val);
void setAll(T);
private:
#ifdef SP_MULTI_BYTE
CharMapPage<T> pages_[1 << CharMapBits::level1];
#else
T values_[256];
#endif
};
template<class T>
class CharMapResource : public CharMap<T>, public Resource {
public:
CharMapResource() { }
CharMapResource(T t) : CharMap<T>(t) { }
};
#ifdef SP_MULTI_BYTE
template<class T>
inline
T CharMap<T>::operator[](Char c) const
{
const CharMapPage<T> &pg = pages_[c >> (CharMapBits::level2 + CharMapBits::level3)];
if (pg.values) {
const CharMapColumn<T> &column = pg.values[(c >> CharMapBits::level3) & ((1 << CharMapBits::level2) - 1)];
if (column.values)
return column.values[c & ((1 << CharMapBits::level3) - 1)];
else
return column.value;
}
else
return pg.value;
}
template<class T>
inline
T CharMap<T>::getRange(Char c, Char &max) const
{
const CharMapPage<T> &pg = pages_[c >> (CharMapBits::level2 + CharMapBits::level3)];
if (pg.values) {
const CharMapColumn<T> &column = pg.values[(c >> CharMapBits::level3) & ((1 << CharMapBits::level2) - 1)];
if (column.values) {
max = c;
return column.values[c & ((1 << CharMapBits::level3) - 1)];
}
else {
max = (c & ~((1 << CharMapBits::level3) - 1)) + ((1 << CharMapBits::level3) - 1);
return column.value;
}
}
else {
max = (c & ~((1 << (CharMapBits::level2 + CharMapBits::level3)) - 1)) + ((1 << (CharMapBits::level2 + CharMapBits::level2)) - 1);
return pg.value;
}
}
#else
template<class T>
inline
T CharMap<T>::operator[](Char c) const
{
return values_[c];
}
template<class T>
inline
T CharMap<T>::getRange(Char c, Char &max) const
{
max = c;
return values_[c];
}
template<class T>
inline
void CharMap<T>::setChar(Char c, T val)
{
values_[c] = val;
}
#endif
#ifdef SP_NAMESPACE
}
#endif
#endif /* not CharMap_INCLUDED */
#ifdef SP_DEFINE_TEMPLATES
#include "CharMap.cxx"
#endif
|