Link with C++ linker
[oweals/cde.git] / cde / programs / nsgmls / CodingSystem.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: CodingSystem.C /main/2 1996/08/08 12:10:51 mgreess $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifdef __GNUG__
28 #pragma implementation
29 #endif
30
31 #include "splib.h"
32 #include "CodingSystem.h"
33 #ifdef SP_SHORT_HEADERS
34 #include <strstrea.h>
35 #else
36 #include <strstream.h>
37 #endif
38 #include <string.h>
39 #include <sys/param.h>
40
41 #ifdef SP_NAMESPACE
42 namespace SP_NAMESPACE {
43 #endif
44
45 InputCodingSystem::~InputCodingSystem()
46 {
47 }
48
49 StringC InputCodingSystem::convertIn(const char *s) const
50 {
51   Decoder *decoder = makeDecoder();
52   StringC str;
53   str.resize(strlen(s));
54   str.resize(decoder->decode(&str[0], s, strlen(s), &s));
55   delete decoder;
56   return str;
57 }
58
59 Boolean InputCodingSystem::isIdentity() const
60 {
61   return 0;
62 }
63
64 OutputCodingSystem::~OutputCodingSystem()
65 {
66 }
67
68 unsigned OutputCodingSystem::fixedBytesPerChar() const
69 {
70   return 0;
71 }
72
73 String<char> OutputCodingSystem::convertOut(const StringC &str) const
74 {
75   Encoder *encoder = makeEncoder();
76   strstreambuf stream(MAXPATHLEN);
77   StringC copy(str);
78   encoder->output(copy.data(), copy.size(), &stream);
79   delete encoder;
80   char *s = stream.str();
81   String<char> result(s, stream.out_waiting());
82   result += '\0';
83   stream.freeze(0);
84 #ifdef __lucid
85   // Workaround lcc bug (3.1p2 with -O -XF).
86   String<char> temp(result);
87   return temp;
88 #else
89   return result;
90 #endif
91 }
92
93 Decoder::Decoder(unsigned minBytesPerChar)
94 : minBytesPerChar_(minBytesPerChar)
95 {
96 }
97
98 Decoder::~Decoder()
99 {
100 }
101
102 Boolean Decoder::convertOffset(unsigned long &) const
103 {
104   return false;
105 }
106
107 Encoder::Encoder()
108 : unencodableHandler_(0)
109 {
110 }
111
112 Encoder::~Encoder()
113 {
114 }
115
116 void Encoder::output(Char *s, size_t n, streambuf *sp)
117 {
118   output((const Char *)s, n, sp);
119 }
120
121 void Encoder::startFile(streambuf *)
122 {
123 }
124
125 #ifdef SP_NAMESPACE
126 }
127 #endif