/usr/include/wvstreams/wvtypedencoder.h is in libwvstreams-dev 4.6.1-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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | /* -*- Mode: C++ -*-
* Worldvisions Weaver Software:
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
*
* An abstraction for encoders that manipulate typed buffers.
*/
#ifndef __WVTYPEDENCODER_H
#define __WVTYPEDENCODER_H
#include "wvencoder.h"
#include "wvbufbase.h"
/**
* This template facilitates the creation and use of encoders
* that manipulate typed buffers.
*
* A typed encoder accepts both typed and untyped buffers, but
* is implementated in terms of typed buffers. Untyped buffers
* are automatically wrapped into the required form before being
* passed on to the implementation.
*
* This type is designed to function as a statically bound mixin
* to make it easier to incorporate typed encoders into untyped
* encoder hierarchies. This is somewhat ugly, but necessary.
*
*
* "IT" is the input buffer datatype
* "OT" is the output buffer datatype
* "S" is the WvEncoder supertype
* @see WvEncoder
*/
template<class IT, class OT, class S = WvEncoder>
class WvTypedEncoder : public S
{
public:
typedef IT IType;
typedef OT OType;
typedef WvBufBase<IType> IBuffer;
typedef WvBufBase<OType> OBuffer;
typedef WvBufViewBase<IType> IBufferView;
typedef WvBufViewBase<OType> OBufferView;
/**
* Typed variant of encode().
* @see encode(WvBuf&, WvBuf&, bool, bool)
*/
bool encode(IBuffer &inbuf, OBuffer &outbuf, bool flush = false,
bool finish = false)
{
WvBufView inview(inbuf);
WvBufView outview(outbuf);
return S::encode(inview, outview, flush, finish);
}
/**
* Typed variant of flush().
* @see flush(WvBuf, WvBuf, bool)
*/
bool flush(IBuffer &inbuf, OBuffer &outbuf, bool finish = false)
{
WvBufView inview(inbuf);
WvBufView outview(outbuf);
return S::flush(inview, outview, finish);
}
/**
* Typed variant of finish().
* @see finish(WvBuf)
*/
bool finish(OBuffer &outbuf)
{
WvBufView outview(outbuf);
return S::finish(outview);
}
bool encode(WvBuf &inbuf, WvBuf &outbuf,
bool flush = false, bool finish = false)
{
return S::encode(inbuf, outbuf, flush, finish);
}
bool flush(WvBuf &inbuf, WvBuf &outbuf,
bool finish = false)
{
return S::flush(inbuf, outbuf, finish);
}
bool finish(WvBuf &outbuf)
{
return S::finish(outbuf);
}
protected:
/**
* Typed variant of _encode().
* @see _encode(WvBuf&, WvBuf&, bool)
*/
virtual bool _typedencode(IBuffer &inbuf, OBuffer &outbuf,
bool flush) = 0;
/**
* Typed variant of _finish().
* @see _finish(WvBuf&)
*/
virtual bool _typedfinish(OBuffer &outbuf)
{ return true; }
/** Wrapper implementation of _encode(). */
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf,
bool flush)
{
IBufferView inview(inbuf);
OBufferView outview(outbuf);
return _typedencode(inview, outview, flush);
}
/** Wrapper implementation of _finish(). */
virtual bool _finish(WvBuf &outbuf)
{
OBufferView outview(outbuf);
return _typedfinish(outview);
}
};
/**
* Partial template specialization for unsigned char output
* buffer type to avoid compilation errors.
*
* "IType" is the input buffer datatype
*/
template<class IT, class S>
class WvTypedEncoder<IT, unsigned char, S> : public S
{
public:
typedef IT IType;
typedef unsigned char OType;
typedef WvBufBase<IType> IBuffer;
typedef WvBufBase<OType> OBuffer;
typedef WvBufViewBase<IType> IBufferView;
typedef WvBufViewBase<OType> OBufferView;
/**
* Typed variant of encode().
* @see encode(WvBuf&, WvBuf&, bool, bool)
*/
bool encode(IBuffer &inbuf, OBuffer &outbuf, bool flush = false,
bool finish = false)
{
WvBufView inview(inbuf);
return S::encode(inview, outbuf, flush, finish);
}
/**
* Typed variant of flush().
* @see flush(WvBuf, WvBuf, bool)
*/
bool flush(IBuffer &inbuf, OBuffer &outbuf, bool finish = false)
{
WvBufView inview(inbuf);
return S::flush(inview, outbuf, finish);
}
bool encode(WvBuf &inbuf, WvBuf &outbuf,
bool flush = false, bool finish = false)
{
return S::encode(inbuf, outbuf, flush, finish);
}
bool flush(WvBuf &inbuf, WvBuf &outbuf,
bool finish = false)
{
return S::flush(inbuf, outbuf, finish);
}
protected:
/**
* Typed variant of _encode().
* @see _encode(WvBuf&, WvBuf&, bool)
*/
virtual bool _typedencode(IBuffer &inbuf, OBuffer &outbuf,
bool flush) = 0;
/**
* Typed variant of _finish().
* @see _finish(WvBuf&)
*/
virtual bool _typedfinish(OBuffer &outbuf)
{ return true; }
/** Wrapper implementation of _encode(). */
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf,
bool flush)
{
IBufferView inview(inbuf);
return _typedencode(inview, outbuf, flush);
}
/** Wrapper implementation of _finish(). */
virtual bool _finish(WvBuf &outbuf)
{
return _typedfinish(outbuf);
}
};
/**
* Partial template specialization for unsigned char input
* and output buffer types to avoid compilation errors.
*/
template<class S>
class WvTypedEncoder<unsigned char, unsigned char, S> : public S
{
public:
typedef unsigned char IType;
typedef unsigned char OType;
typedef WvBufBase<IType> IBuffer;
typedef WvBufBase<OType> OBuffer;
typedef WvBufViewBase<IType> IBufferView;
typedef WvBufViewBase<OType> OBufferView;
protected:
/**
* Typed variant of _encode().
* @see _encode(WvBuf&, WvBuf&, bool)
*/
virtual bool _typedencode(IBuffer &inbuf, OBuffer &outbuf,
bool flush) = 0;
/**
* Typed variant of _finish().
* @see _finish(WvBuf&)
*/
virtual bool _typedfinish(OBuffer &outbuf)
{ return true; }
/** Wrapper implementation of _encode(). */
virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf,
bool flush)
{
return _typedencode(inbuf, outbuf, flush);
}
/** Wrapper implementation of _finish(). */
virtual bool _finish(WvBuf &outbuf)
{
return _typedfinish(outbuf);
}
};
#endif // __WVTYPEDENCODER
|