Fixed2CodingSystem.cxx revision 7c478bd95313f5f23a4c958a745db2134aa03244
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#pragma ident "%Z%%M% %I% %E% SMI"
// This uses a big endian byte order irrespective of host byte order.
#include "splib.h"
#ifdef SP_MULTI_BYTE
#include "Fixed2CodingSystem.h"
#include "macros.h"
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
class Fixed2Decoder : public Decoder {
public:
const char **rest);
};
class Fixed2Encoder : public Encoder {
public:
~Fixed2Encoder();
private:
char *buf_;
};
{
return new Fixed2Decoder;
}
{
return new Fixed2Encoder;
}
unsigned Fixed2CodingSystem::fixedBytesPerChar() const
{
return 2;
}
: Decoder(2)
{
}
const char **rest)
{
#ifdef SP_BIG_ENDIAN
return fromLen/2;
}
#endif
fromLen &= ~1;
from += 2;
}
return fromLen/2;
}
{
n *= 2;
return true;
}
{
}
{
delete [] buf_;
}
{
if (bufSize_ < n) {
delete [] buf_;
}
}
{
#ifdef SP_BIG_ENDIAN
if (sizeof(Char) == 2) {
return;
}
#endif
char *p = (char *)s;
for (size_t i = 0; i < n; i++) {
Char c = s[i];
*p++ = (c >> 8) & 0xff;
*p++ = c & 0xff;
}
}
{
#ifdef SP_BIG_ENDIAN
if (sizeof(Char) == 2) {
return;
}
#endif
allocBuf(n*2);
for (size_t i = 0; i < n; i++) {
}
}
#ifdef SP_NAMESPACE
}
#endif
#else /* not SP_MULTI_BYTE */
#ifndef __GNUG__
static char non_empty_translation_unit; // sigh
#endif
#endif /* not SP_MULTI_BYTE */