File: CodingSystem.cxx

package info (click to toggle)
opensp 1.5.2-10
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,856 kB
  • sloc: cpp: 65,784; ansic: 17,124; sh: 13,693; xml: 2,704; makefile: 910; perl: 561; yacc: 288; sed: 16
file content (118 lines) | stat: -rw-r--r-- 1,900 bytes parent folder | download | duplicates (7)
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
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.

#ifdef __GNUG__
#pragma implementation
#endif

#include "splib.h"
#include "CodingSystem.h"

#include <string.h>

#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif

InputCodingSystem::~InputCodingSystem()
{
}

StringC InputCodingSystem::convertIn(const char *s) const
{
  Decoder *decoder = makeDecoder();
  StringC str;
  str.resize(strlen(s));
  str.resize(decoder->decode(&str[0], s, strlen(s), &s));
  delete decoder;
  return str;
}

Boolean InputCodingSystem::isIdentity() const
{
  return 0;
}

OutputCodingSystem::~OutputCodingSystem()
{
}

unsigned OutputCodingSystem::fixedBytesPerChar() const
{
  return 0;
}

String<char> OutputCodingSystem::convertOut(const StringC &str) const
{
  Encoder *encoder = makeEncoder();
  StrOutputByteStream stream;
  encoder->output(str.data(), str.size(), &stream);
  delete encoder;
  String<char> result;
  stream.extractString(result);
  result += '\0';
  return result;
}

Decoder::Decoder(unsigned minBytesPerChar)
: minBytesPerChar_(minBytesPerChar)
{
}

Decoder::~Decoder()
{
}

Boolean Decoder::convertOffset(unsigned long &) const
{
  return false;
}

Encoder::Encoder()
{
}

Encoder::~Encoder()
{
}

Encoder::Handler::~Handler()
{
}

void Encoder::output(Char *s, size_t n, OutputByteStream *sp)
{
  output((const Char *)s, n, sp);
}

void Encoder::startFile(OutputByteStream *)
{
}

void Encoder::handleUnencodable(Char, OutputByteStream *)
{
}

void Encoder::setUnencodableHandler(Handler *)
{
}

RecoveringEncoder::RecoveringEncoder()
: unencodableHandler_(0)
{
}

void RecoveringEncoder::handleUnencodable(Char c, OutputByteStream *sbufp)
{
  if (unencodableHandler_)
    unencodableHandler_->handleUnencodable(c, sbufp);
}

void RecoveringEncoder::setUnencodableHandler(Handler *handler)
{
  unencodableHandler_ = handler;
}

#ifdef SP_NAMESPACE
}
#endif