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
22
23namespace LOG4CXX_NS
24{
25
26namespace helpers
27{
28class ByteBuffer;
29class CharsetEncoder;
31
36class LOG4CXX_EXPORT CharsetEncoder : public Object
37{
38 public:
43
44 protected:
49
50 public:
54 virtual ~CharsetEncoder();
58 static CharsetEncoderPtr getDefaultEncoder();
59
68 static CharsetEncoderPtr getEncoder(const LogString& charset);
69
70
74 static CharsetEncoderPtr getUTF8Encoder();
75
84 static void encode(CharsetEncoderPtr& enc,
85 const LogString& src,
86 LogString::const_iterator& iter,
87 ByteBuffer& dst);
88
95 virtual log4cxx_status_t encode(const LogString& in,
96 LogString::const_iterator& iter,
97 ByteBuffer& out) = 0;
98
103 virtual log4cxx_status_t encode(unsigned int codePoint, ByteBuffer& out) = 0;
107 virtual void reset();
108
109
114 inline static bool isError(log4cxx_status_t stat)
115 {
116 return (stat != 0);
117 }
118
123 static bool isTriviallyCopyable(const LogString& src, const CharsetEncoderPtr& enc);
124
131 static size_t putUTF8CodePoint(unsigned int ch, char* dst);
132
139 static size_t putUTF16BECodePoint(unsigned int ch, char* dst);
140
147 static size_t putUTF16LECodePoint(unsigned int ch, char* dst);
148 private:
156 CharsetEncoder& operator=(const CharsetEncoder&);
157
158 static CharsetEncoder* createDefaultEncoder();
159};
160
161} // namespace helpers
162
163} //namespace log4cxx
164
165#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:37
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:114
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:101
LOG4CXX_PTR_DEF(Object)
std::basic_string< logchar > LogString
Definition logstring.h:51
#define LOG4CXX_CAST_ENTRY(Interface)
Definition object.h:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:141