You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2007/11/21 14:11:36 UTC

svn commit: r597066 - in /logging/log4cxx/trunk/src: main/cpp/transcoder.cpp main/include/log4cxx/helpers/transcoder.h test/cpp/helpers/transcodertestcase.cpp

Author: carnold
Date: Wed Nov 21 05:11:32 2007
New Revision: 597066

URL: http://svn.apache.org/viewvc?rev=597066&view=rev
Log:
Simply transcoder API

Modified:
    logging/log4cxx/trunk/src/main/cpp/transcoder.cpp
    logging/log4cxx/trunk/src/main/include/log4cxx/helpers/transcoder.h
    logging/log4cxx/trunk/src/test/cpp/helpers/transcodertestcase.cpp

Modified: logging/log4cxx/trunk/src/main/cpp/transcoder.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/transcoder.cpp?rev=597066&r1=597065&r2=597066&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/transcoder.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/transcoder.cpp Wed Nov 21 05:11:32 2007
@@ -154,6 +154,38 @@
 }
 #endif
 
+void Transcoder::decode(const char* src, LogString& dst) {
+     decode(src, strlen(src), dst);
+}
+
+void Transcoder::decode(const std::string& src, LogString& dst) {
+     decode(src.data(), src.length(), dst);
+}
+
+LogString Transcoder::decode(const std::string& src) {
+     LogString dst;
+     decode(src.data(), src.length(), dst);
+     return dst;
+}
+
+#if LOG4CXX_HAS_WCHAR_T
+void Transcoder::decode(const wchar_t* src, LogString& dst) {
+     decode(src, wcslen(src), dst);
+}
+
+void Transcoder::decode(const std::wstring& src, LogString& dst) {
+     decode(src.data(), src.length(), dst);
+}
+
+LogString Transcoder::decode(const std::wstring& src) {
+     LogString dst;
+     decode(src.data(), src.length(), dst);
+     return dst;
+}
+#endif
+
+
+
 
 
 

Modified: logging/log4cxx/trunk/src/main/include/log4cxx/helpers/transcoder.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/helpers/transcoder.h?rev=597066&r1=597065&r2=597066&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/helpers/transcoder.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/helpers/transcoder.h Wed Nov 21 05:11:32 2007
@@ -40,21 +40,10 @@
       //
       //   convienience wrappers
       //
-      inline static void decode(const char* src, LogString& dst) {
-        decode(src, strlen(src), dst);
-      }
-
-      template<class SRC>
-      inline static void decode(const SRC& src, LogString& dst) {
-        decode(src.data(), src.length(), dst);
-      }
+      static void decode(const std::string& src, LogString& dst);
+      static void decode(const char* src, LogString& dst);
 
-
-      static LogString decode(const std::string& src) {
-        LogString dst;
-        decode(src, dst);
-        return dst;
-      }
+      static LogString decode(const std::string& src);
 
 
       /**
@@ -69,15 +58,11 @@
 #if LOG4CXX_HAS_WCHAR_T
       static void decode(const wchar_t* src, size_t len, LogString& dst);
 
-      inline static void decode(const wchar_t* src, LogString& dst) {
-        decode(src, wcslen(src), dst);
-      }
-
-      static LogString decode(const std::wstring& src) {
-        LogString dst;
-        decode(src, dst);
-        return dst;
-      }
+      static void decode(const wchar_t* src, LogString& dst);
+
+      static void decode(const std::wstring& src, LogString& dst);
+
+      static LogString decode(const std::wstring& src);
 
       static void encode(const LogString& src, std::wstring& dst);
 

Modified: logging/log4cxx/trunk/src/test/cpp/helpers/transcodertestcase.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/helpers/transcodertestcase.cpp?rev=597066&r1=597065&r2=597066&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/helpers/transcodertestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/helpers/transcodertestcase.cpp Wed Nov 21 05:11:32 2007
@@ -38,6 +38,7 @@
                 CPPUNIT_TEST(decode4);
 #endif
                 CPPUNIT_TEST(decode7);
+                CPPUNIT_TEST(decode8);
 #if LOG4CXX_HAS_WCHAR_T
                 CPPUNIT_TEST(encode1);
 #endif
@@ -102,6 +103,13 @@
                   decoded.substr(0, BUFSIZE - 2));
             CPPUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("Hello"),
                   decoded.substr(BUFSIZE -2 ));
+        }
+
+        void decode8() {
+            std::string msg("Hello, World.");
+            LogString actual(Transcoder::decode(msg));
+            LogString expected(LOG4CXX_STR("Hello, World."));
+            CPPUNIT_ASSERT_EQUAL(expected, actual);
         }