logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Madhu Gowda <madhu.gowd...@yahoo.com>
Subject Re: LogString conversion
Date Mon, 12 May 2008 14:15:50 GMT
<table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font: inherit;'>Hi,<br><br>I
tried the following in my sample program.<br>std::string sLogFile = "TestLog.txt";<br>LogString
sFileName;<br>log4cxx::helpers::Transcoder::decode( sLogFile, sFileName);<br><br>But,
it gives the sFileName as "".<br><br>I tried to debug and saw that in the function<br>void
Transcoder::decode(const std::string&amp; src, LogString&amp; dst) {<br><br>the
value of src is coming as &lt;Bad Ptr&gt;<br><br>Kindly advise on this.<br><br>Regards,<br>Madhu
Gowda<br><br>--- On <b>Fri, 5/9/08, Curt Arnold <i>&lt;carnold@apache.org&gt;</i></b>
wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left:
5px; padding-left: 5px;">From: Curt Arnold &lt;carnold@apache.org&gt;<br>Subject:
Re: LogString conversion<br>To: "Log4CXX User" &lt;log4cxx-user@logging.apache.org&gt;<br>Date:
Friday, May 9, 2008, 2:25 PM<br><br><pre>On May 9, 2008, at 7:46 AM, Mehta,
 Jenica wrote:<br><br>&gt; Hi All,<br>&gt;<br>&gt; Please
let me know if log4cxx 0.10.0 provides any API for converting  <br>&gt; std::string
to log4cxx::LogString and vice versa.<br>&gt;<br>&gt; Thanks &amp;
Regards,<br>&gt;<br>&gt; Jenica Mehta<br>&gt;<br>&gt;<br><br>LogString
is the internal string representation within log4cxx which  <br>is either an std::basic_string&lt;char&gt;
where the characters are UTF-8  <br>codes (default build on non-Windows platforms) or
 <br>std::basic_string&lt;wchar_t&gt; (default on Windows).  Most of the commonly
 <br>used methods are written accept many flavors of strings (std::string  <br>in
current code page, wstrings, CFString, etc), but less frequently  <br>used methods require
that the user explicitly between their desired  <br>string type and LogString.<br><br>The
simplest way to convert, is the use the LOGCXX_ENCODE_CHAR and  <br>LOG4CXX_DECODE_CHAR
macros defined in log4cxx/helpers/transcoder.h.   <br>ENCODE
 creates a std::string from a LogString and DECODE creates a  <br>LogString from a char.
 If log4cxx is build with --with-charset=utf-8  <br>and --with-logchar=utf-8, the macros
will simply be a reference  <br>definition since there is no need for conversion.  Here
is an example  <br>(don't actually run it for obvious reasons):<br><br>void
bar(LogString&amp; param) {<br>    LOG4CXX_ENCODE_CHAR(string, param);<br>
   foo(string);<br>}<br><br>void foo(std::string&amp; param) {<br>
    LOG4CXX_DECODE_CHAR(logstring, param);<br>     bar(logstring);<br>}</pre></blockquote></td></tr></table><br>

      <hr size=1>Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
"> Try it now.</a>
Mime
View raw message