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 mc...@apache.org on 2004/04/02 10:58:40 UTC

cvs commit: logging-log4cxx/include/log4cxx/helpers tchar.h

mcatan      2004/04/02 00:58:40

  Modified:    include/log4cxx/helpers tchar.h
  Log:
  optimizations and compilation fix
  
  Revision  Changes    Path
  1.23      +23 -5     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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- tchar.h	28 Feb 2004 15:10:23 -0000	1.22
  +++ tchar.h	2 Apr 2004 08:58:40 -0000	1.23
  @@ -23,6 +23,7 @@
   #include <cwchar>
   #include <algorithm> // min & max
   #include <stdio.h> // sprintf
  +#include <streambuf> // basic_streambuf
   
   class Convert
   {
  @@ -187,11 +188,12 @@
   
   namespace log4cxx
   {
  -	class stringbuf : public std::basic_streambuf<TCHAR, std::char_traits<TCHAR> >
  +	class stringbuf : public std::basic_streambuf<TCHAR>
   	{
   	public:
  -		typedef TCHAR char_type;
  -		typedef std::char_traits<char_type> traits_type;
  +		typedef std::basic_streambuf<TCHAR> base;
  +		typedef base::char_type char_type;
  +		typedef base::traits_type traits_type;
   		typedef std::allocator<char_type> allocator_type;
   		typedef traits_type::int_type int_type;
   
  @@ -205,7 +207,7 @@
   		}
   
   		virtual int_type overflow(
  -		int_type c = stringbuf::traits_type::eof())
  +			int_type c = stringbuf::traits_type::eof())
   		{
   			using namespace std;
   
  @@ -222,7 +224,7 @@
   			}
   			else
   			{
  -				size_t os = pptr() - b; // taille allou�e
  +				size_t os = epptr() - b; // taille allou�e
   				size_t is =
   					_max(_min((os * 2), _MaxInc), _MinInc)
   					+ 1; // incr�ment d'allocation
  @@ -276,6 +278,22 @@
   			}
   
   			return ret;
  +		}
  +
  +		virtual pos_type seekpos(pos_type pos,
  +			std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
  +		{
  +			std::streamoff off = (std::streamoff)pos;
  +			if (pbase() + off > epptr())
  +			{
  +				return pos_type(-1);
  +			}
  +			else
  +			{
  +				setp(pbase(), epptr());
  +				pbump(off);
  +				return pos;
  +			}
   		}
   
   	protected: