/usr/include/mimetic/codec/other_codecs.h is in libmimetic-dev 0.9.7-1.
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 | /***************************************************************************
copyright : (C) 2002-2008 by Stefano Barbato
email : stefano@codesink.org
$Id: other_codecs.h,v 1.13 2008-10-07 11:06:26 tat Exp $
***************************************************************************/
#ifndef _MIMETIC_CODEC_OTHER_CODECS_H_
#define _MIMETIC_CODEC_OTHER_CODECS_H_
#include <mimetic/codec/codec_base.h>
namespace mimetic
{
/// Pass through codec. Copies input to output
/*!
\sa encode decode
*/
struct NullCodec: public unbuffered_codec, public chainable_codec<NullCodec>
{
template<typename OutIt>
void process(char c, OutIt& out)
{
*out = c; ++out;
}
const char* name() const
{
return "NullCodec";
}
};
/// Converts input chars to upper case
/*!
\sa encode decode
*/
struct ToUpperCase: public unbuffered_codec, public chainable_codec<ToUpperCase>
{
template<typename OutIt>
void process(char c, OutIt& out)
{
enum { offset = 'A' - 'a' };
if(c >= 'a' && c <= 'z')
c += offset;
*out = c;
++out;
}
const char* name() const
{
return "ToUpperCase";
}
};
/// Converts input chars to lower case
/*!
\sa encode decode
*/
struct ToLowerCase: public unbuffered_codec, public chainable_codec<ToLowerCase>
{
template<typename OutIt>
void process(char c, OutIt& out)
{
enum { offset = 'a' - 'A' };
if(c >= 'A' && c <= 'Z')
c += offset;
*out = c;
++out;
}
const char* name() const
{
return "ToLowerCase";
}
};
/// Converts any LF (\\n) to CRLF (\\r\\n)
/*!
\sa encode decode
*/
struct Lf2CrLf: public unbuffered_codec, public chainable_codec<Lf2CrLf>
{
template<typename OutIt>
void process(char c, OutIt& out)
{
enum { LF = 0xA, CR = 0xD };
if(c == LF)
{
*out = CR; ++out;
*out = LF; ++out;
} else
*out = c; ++out;
}
const char* name() const
{
return "Lf2CrLf";
}
};
/// Inserts a new line if the input line is too long
/*!
\sa encode decode
*/
struct MaxLineLen: public unbuffered_codec, public chainable_codec<MaxLineLen>
{
MaxLineLen()
: m_max(0), m_written(0)
{
}
MaxLineLen(uint m)
: m_max(m), m_written(0)
{
}
template<typename OutIt>
void process(char c, OutIt& out)
{
enum { cr = 0xD, lf = 0xA };
if(m_max && m_written++ == m_max)
{
*out = cr; ++out;
*out = lf; ++out;
m_written = 1;
}
*out = c;
++out;
}
const char* name() const
{
return "MaxLineLen";
}
private:
unsigned int m_max, m_written;
};
// internal
template<typename OutIt>
struct oiterator_wrapper:
public unbuffered_codec,
public chainable_codec<oiterator_wrapper<OutIt> >
{
oiterator_wrapper(): m_pOut(0)
{
}
oiterator_wrapper(OutIt& out): m_pOut(&out)
{
}
template<typename OutIt2>
void process(char c, OutIt2& out)
{
**m_pOut = c; ++(*m_pOut);
*out = c; ++out;
}
const char* name() const
{
return "oiterator_wrapper";
}
private:
OutIt* m_pOut;
};
}
#endif
|