mcatan      2004/04/24 14:34:42

  Modified:    include/log4cxx/helpers tchar.h
  Log:
  changed operator << (fix for Solaris)
  
  Revision  Changes    Path
  1.30      +25 -41    logging-log4cxx/include/log4cxx/helpers/tchar.h
  
  Index: tchar.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/tchar.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- tchar.h   24 Apr 2004 07:56:44 -0000      1.29
  +++ tchar.h   24 Apr 2004 21:34:42 -0000      1.30
  @@ -41,54 +41,38 @@
                ::wcstombs(dst, src, 512);
                return dst;
        }
  -};
  -
  -#ifndef UNICODE
  -#if _MSC_VER == 1200 // MSDEV 6
  -inline std::ostream& operator<<(std::ostream& os, const int64_t& ll)
  -{
  -     char buff[21];
  -     sprintf(buff, "%I64d", ll);
  -     os << buff;
  -     return os;
  -}
  -#else
  -inline std::ostream& operator<<(const int64_t& ll, std::ostream& os)
  -{
  -     char buff[21];
  +     
  +     static void int64ToString(wchar_t * dst, size_t maxlen, const int64_t& 
ll)
  +     {
   #ifdef WIN32
  -     sprintf(buff, "%I64d", ll);
  +             _snwprintf(dst, maxlen, L"%I64d", ll);
   #else
  -     sprintf(buff, "%lld", ll);
  +             swprintf(dst, maxlen, L"%lld", ll);
   #endif
  -     os << buff;
  -     return os;
  -}
  -#endif // _MSC_VER == 1200
  -#else
  -#if _MSC_VER == 1200 // MSDEV 6
  -inline std::wostream& operator<<(std::wostream& os, const int64_t& ll)
  -{
  -     wchar_t buff[21];
  -     _snwprintf(buff, 20, L"%I64d", ll);
  -     os << buff;
  -     return os;
  -}
  -#else
  -inline std::wostream& operator<<(const int64_t& ll, std::wostream& os)
  -{
  -     wchar_t buff[21];
  +     }
  +     
  +     static void int64ToString(char * dst, size_t maxlen, const int64_t& ll)
  +     {
   #ifdef WIN32
  -     _snwprintf(buff, 20, L"%I64d", ll);
  +             snprintf(dst, maxlen, "%I64d", ll);
   #else
  -     swprintf(buff, 20, L"%lld", ll);
  +             snprintf(dst, maxlen, "%lld", ll);
   #endif
  -     os << buff;
  -     return os;
  -}
  -#endif // _MSC_VER == 1200
  -#endif // UNICODE
  +     }
  +};
   
  +namespace std 
  +{
  +     template<typename _CharT, typename _Traits>
  +             basic_ostream<_CharT, _Traits>&
  +             operator<<(basic_ostream<_CharT, _Traits>& os, const int64_t& 
ll)
  +     {
  +             _CharT buff[21];
  +             Convert::int64ToString(buff, ll);
  +             os << buff;
  +             return os;
  +     }
  +}
   
   #ifdef WIN32
   #ifndef USES_CONVERSION
  
  
  

Reply via email to