Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
/* $XConsortium: TranslateInputCodingSystem.C /main/1 1996/07/29 17:06:28 cde-hp $ */
// Copyright (c) 1995 James Clark
// See the file COPYING for copying permission.
#include "splib.h"
#include "TranslateInputCodingSystem.h"
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
class TranslateDecoder : public Decoder {
public:
TranslateDecoder(const Char *table);
size_t decode(Char *to, const char *from, size_t fromLen,
const char **rest);
Boolean convertOffset(unsigned long &offset) const;
private:
const Char *table_;
};
TranslateInputCodingSystem::TranslateInputCodingSystem(const Char *table)
: table_(table)
{
}
Decoder *TranslateInputCodingSystem::makeDecoder() const
{
return new TranslateDecoder(table_);
}
TranslateDecoder::TranslateDecoder(const Char *table)
: table_(table)
{
}
size_t TranslateDecoder::decode(Char *to, const char *from, size_t fromLen,
const char **rest)
{
for (size_t n = fromLen; n > 0; n--)
*to++ = table_[(unsigned char)*from++]; // zero extend
*rest = from;
return fromLen;
}
Boolean TranslateDecoder::convertOffset(unsigned long &) const
{
return true;
}
#ifdef SP_NAMESPACE
}
#endif