18 #ifndef _LOG4CXX_HELPERS_TRANSCODER_H
19 #define _LOG4CXX_HELPERS_TRANSCODER_H
46 #if LOG4CXX_ABI_VERSION <= 15
51 [[ deprecated(
"Use the encodeUTF8() without a Pool parameter" ) ]]
76 static unsigned int decode(
const std::string& str,
77 std::string::const_iterator& iter);
82 static void encode(
unsigned int ch, std::string& dst);
96 #if LOG4CXX_ABI_VERSION <= 15
105 [[ deprecated(
"Use an encode() without a Pool parameter" ) ]]
110 #if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR || defined(WIN32) || defined(_WIN32)
119 #if LOG4CXX_ABI_VERSION <= 15
131 static unsigned int decode(
const std::wstring& str,
132 std::wstring::const_iterator& iter);
137 static void encode(
unsigned int ch, std::wstring& dst);
142 #if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
160 static unsigned int decode(
const std::basic_string<UniChar>& str,
161 std::basic_string<UniChar>::const_iterator& iter);
166 static void encode(
unsigned int ch, std::basic_string<UniChar>& dst);
170 #if LOG4CXX_CFSTRING_API
179 enum { LOSSCHAR = 0x3F };
202 enum { BUFSIZE = 256 };
203 static size_t encodeUTF8(
unsigned int ch,
char* dst);
204 static size_t encodeUTF16BE(
unsigned int ch,
char* dst);
205 static size_t encodeUTF16LE(
unsigned int ch,
char* dst);
211 #if LOG4CXX_CHARSET_UTF8 && LOG4CXX_LOGCHAR_IS_UTF8
221 #define LOG4CXX_ENCODE_CHAR(var, src) \
222 const std::string& var = src
233 #define LOG4CXX_DECODE_CHAR(var, src) \
234 const LOG4CXX_NS::LogString& var = src
246 #define LOG4CXX_ENCODE_CHAR(var, src) \
248 LOG4CXX_NS::helpers::Transcoder::encode(src, var)
259 #define LOG4CXX_DECODE_CHAR(var, src) \
260 LOG4CXX_NS::LogString var; \
261 LOG4CXX_NS::helpers::Transcoder::decode(src, var)
273 #define LOG4CXX_DECODE_CFSTRING(var, src) \
274 LOG4CXX_NS::LogString var; \
275 LOG4CXX_NS::helpers::Transcoder::decode(src, var)
286 #define LOG4CXX_ENCODE_CFSTRING(var, src) \
287 CFStringRef var = LOG4CXX_NS::helpers::Transcoder::encode(src)
289 #if LOG4CXX_LOGCHAR_IS_WCHAR
299 #define LOG4CXX_ENCODE_WCHAR(var, src) \
300 const std::wstring& var = src
311 #define LOG4CXX_DECODE_WCHAR(var, src) \
312 const LOG4CXX_NS::LogString& var = src
324 #define LOG4CXX_ENCODE_WCHAR(var, src) \
326 LOG4CXX_NS::helpers::Transcoder::encode(src, var)
337 #define LOG4CXX_DECODE_WCHAR(var, src) \
338 LOG4CXX_NS::LogString var; \
339 LOG4CXX_NS::helpers::Transcoder::decode(src, var)
343 #if LOG4CXX_LOGCHAR_IS_UNICHAR
354 #define LOG4CXX_ENCODE_UNICHAR(var, src) \
355 const std::basic_string<UniChar>& var = src
366 #define LOG4CXX_DECODE_UNICHAR(var, src) \
367 const LOG4CXX_NS::LogString& var = src
380 #define LOG4CXX_ENCODE_UNICHAR(var, src) \
381 std::basic_string<UniChar> var; \
382 LOG4CXX_NS::helpers::Transcoder::encode(src, var)
393 #define LOG4CXX_DECODE_UNICHAR(var, src) \
394 LOG4CXX_NS::LogString var; \
395 LOG4CXX_NS::helpers::Transcoder::decode(src, var)
An area of memory and a cursor into that memory.
Definition: bytebuffer.h:41
Methods for converting between external and internal strings.
Definition: log4cxx/helpers/transcoder.h:34
static void decode(const std::basic_string< UniChar > &src, LogString &dst)
Append the LogString equivalent of src onto dst.
static wchar_t * wencode(const LogString &src, log4cxx::helpers::Pool &p)
A null-terminated equivalent of src.
static void encode(const LogString &src, std::basic_string< UniChar > &dst)
Append the equivalent of src onto dst.
static void encodeUTF16LE(unsigned int sv, ByteBuffer &dst)
Append the code point sv to dst as UTF-16LE.
static LogString decode(const char *str)
The LogString equivalent to the characters in the null terminated bytes at str.
static void encodeUTF16BE(unsigned int sv, ByteBuffer &dst)
Append the code point sv to dst as UTF-16BE.
static void decode(const std::wstring &src, LogString &dst)
Append the LogString equivalent of src onto dst.
static void encode(const LogString &src, std::wstring &dst)
Append the equivalent of src onto dst.
static void encode(const LogString &src, std::string &dst)
Append the UTF8 equivalent of src onto dst.
static void encodeUTF8(const LogString &src, std::string &dst)
Append \src onto dst as a UTF-8 string.
static unsigned int decode(const std::wstring &str, std::wstring::const_iterator &iter)
Increment iter past the next code point in str.
static std::string encodeCharsetName(const LogString &charsetName)
Encodes a charset name in the default encoding without using a CharsetEncoder (which could trigger re...
static unsigned int decode(const std::string &str, std::string::const_iterator &iter)
Increment iter past the next code point in str.
static CFStringRef encode(const LogString &src)
A CFStringRef equivalent of src.
static void decodeUTF8(const std::string &src, LogString &dst)
Append the UTF-8 characters in src onto dst.
static void encode(unsigned int ch, std::basic_string< UniChar > &dst)
Append the UniChar equivalent to ch onto dst.
static void encode(unsigned int ch, std::wstring &dst)
Append the wchar_t equivalent to ch onto dst.
static void encode(unsigned int ch, std::string &dst)
Append the UTF8 equivalent to ch onto dst.
static char * encodeUTF8(const LogString &src, log4cxx::helpers::Pool &p)
Converts the LogString to a UTF-8 string.
static char * encode(const LogString &src, log4cxx::helpers::Pool &p)
static unsigned int decode(const std::basic_string< UniChar > &str, std::basic_string< UniChar >::const_iterator &iter)
Increment iter past the next code point in str.
static void decode(const CFStringRef &src, LogString &dst)
Append the LogString equivalent of src onto dst.
static void decode(const std::string &src, LogString &dst)
Append the LogString equivalent of src onto dst.
static void encodeUTF8(unsigned int sv, ByteBuffer &dst)
Append the code point sv to dst as UTF-8.
static logchar decode(char ch)
The logchar equivalent to ch.
const struct __CFString * CFStringRef
Definition: logstring.h:30
std::basic_string< logchar > LogString
Definition: logstring.h:60