Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
charsetencoder.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_HELPERS_CHARSETENCODER_H
19#define _LOG4CXX_HELPERS_CHARSETENCODER_H
20
23
24namespace LOG4CXX_NS
25{
26
27namespace helpers
28{
29class ByteBuffer;
30class CharsetEncoder;
32
37class LOG4CXX_EXPORT CharsetEncoder : public Object
38{
39 public:
44
45 protected:
50
51 public:
55 virtual ~CharsetEncoder();
59 static CharsetEncoderPtr getDefaultEncoder();
60
69 static CharsetEncoderPtr getEncoder(const LogString& charset);
70
71
75 static CharsetEncoderPtr getUTF8Encoder();
76
85 static void encode(CharsetEncoderPtr& enc,
86 const LogString& src,
87 LogString::const_iterator& iter,
88 ByteBuffer& dst);
89
96 virtual log4cxx_status_t encode(const LogString& in,
97 LogString::const_iterator& iter,
98 ByteBuffer& out) = 0;
99
104 virtual log4cxx_status_t encode(unsigned int codePoint, ByteBuffer& out) = 0;
108 virtual void reset();
109
110
115 inline static bool isError(log4cxx_status_t stat)
116 {
117 return (stat != 0);
118 }
119
124 static bool isTriviallyCopyable(const LogString& src, const CharsetEncoderPtr& enc);
125
132 static size_t putUTF8CodePoint(unsigned int ch, char* dst);
133
140 static size_t putUTF16BECodePoint(unsigned int ch, char* dst);
141
148 static size_t putUTF16LECodePoint(unsigned int ch, char* dst);
149 private:
157 CharsetEncoder& operator=(const CharsetEncoder&);
158
159 static CharsetEncoder* createDefaultEncoder();
160};
161
162} // namespace helpers
163
164} //namespace log4cxx
165
166#endif //_LOG4CXX_HELPERS_CHARSETENCODER_H
An area of memory and a cursor into that memory.
Definition bytebuffer.h:42
An abstract base for classes that transform LogString codepoints to the byte sequence representation ...
Definition charsetencoder.h:38
virtual void reset()
Resets any internal state.
CharsetEncoder()
Protected constructor.
virtual ~CharsetEncoder()
Destructor.
static size_t putUTF16LECodePoint(unsigned int ch, char *dst)
Add UTF-16 little-endian bytes to dst corresponding to ch.
virtual log4cxx_status_t encode(const LogString &in, LogString::const_iterator &iter, ByteBuffer &out)=0
Encode into out codepoints of in until out is full or an invalid value is encountered.
static CharsetEncoderPtr getUTF8Encoder()
Get encoder for UTF-8.
static bool isError(log4cxx_status_t stat)
Determines if the return value from encode indicates an unconvertable character.
Definition charsetencoder.h:115
static size_t putUTF16BECodePoint(unsigned int ch, char *dst)
Add UTF-16 big-endian bytes to dst corresponding to ch.
static void encode(CharsetEncoderPtr &enc, const LogString &src, LogString::const_iterator &iter, ByteBuffer &dst)
Use enc to encode into out codepoints of src until out is full or an invalid value is encountered.
static size_t putUTF8CodePoint(unsigned int ch, char *dst)
Add UTF-8 bytes to dst corresponding to ch.
static CharsetEncoderPtr getEncoder(const LogString &charset)
Get encoder for specified character set.
virtual log4cxx_status_t encode(unsigned int codePoint, ByteBuffer &out)=0
Add onto out an encoded equivalent of codePoint.
static CharsetEncoderPtr getDefaultEncoder()
Get encoder for default charset.
static bool isTriviallyCopyable(const LogString &src, const CharsetEncoderPtr &enc)
Is the data of src unchanged by enc.
base class for java-like objects.
Definition object.h:102
LOG4CXX_PTR_DEF(Object)
std::basic_string< logchar > LogString
Definition logstring.h:51
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:154
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition object.h:148
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:142