mcatan      2004/04/10 14:42:46

  Modified:    include/log4cxx/helpers tchar.h
               msvc     config.h.msvc.in
               src      boundedfifo.cpp
               tests/src/helpers boundedfifotestcase.cpp
  Added:       include/log4cxx/helpers strictmath.h
  Log:
  added StrictMath class and removed _min and _max macros
  
  Revision  Changes    Path
  1.24      +4 -1      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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- tchar.h   2 Apr 2004 08:58:40 -0000       1.23
  +++ tchar.h   10 Apr 2004 21:42:46 -0000      1.24
  @@ -24,6 +24,7 @@
   #include <algorithm> // min & max
   #include <stdio.h> // sprintf
   #include <streambuf> // basic_streambuf
  +#include <log4cxx/helpers/strictmath.h>
   
   class Convert
   {
  @@ -226,7 +227,9 @@
                        {
                                size_t os = epptr() - b; // taille allou�e
                                size_t is =
  -                                     _max(_min((os * 2), _MaxInc), _MinInc)
  +                                     helpers::StrictMath::max(
  +                                     helpers::StrictMath::min(
  +                                     (os * 2), _MaxInc),_MinInc)
                                        + 1; // incr�ment d'allocation
                                char_type *p = al.allocate(os + is, 0);
                                traits_type::copy(p, b, os);
  
  
  
  1.1                  logging-log4cxx/include/log4cxx/helpers/strictmath.h
  
  Index: strictmath.h
  ===================================================================
  /***************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.      *
   *                                                                         *
   * This software is published under the terms of the Apache Software       *
   * License version 1.1, a copy of which has been included with this        *
   * distribution in the license.apl file.                                   *
   ***************************************************************************/
   
  #ifndef _LOG4CXX_HELPERS_STRICTMATH_H
  #define _LOG4CXX_HELPERS_STRICTMATH_H
   
  #include <log4cxx/config.h>
   
  namespace log4cxx
  {
        namespace helpers
        {
                /**
                The class StrictMath contains methods for performing basic 
numeric
                operations
                */
                class StrictMath
                {
                public:
                        template<typename _type> static inline const _type& 
                                min(const _type& a, const _type& b)
                        {
                                return (a < b) ? a : b;
                        }
                        
                        template<typename _type> static inline const _type& 
                                max(const _type& a, const _type& b)
                        {
                                return (a > b) ? a : b;
                        }
                }; // class StrictMath
        }; // namespace helpers
  }; // namespace log4cx
  
  #endif //_LOG4CXX_HELPERS_STRICTMATH_H
  
  
  
  1.6       +0 -3      logging-log4cxx/msvc/config.h.msvc.in
  
  Index: config.h.msvc.in
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/msvc/config.h.msvc.in,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- config.h.msvc.in  4 Feb 2004 01:03:28 -0000       1.5
  +++ config.h.msvc.in  10 Apr 2004 21:42:46 -0000      1.6
  @@ -31,9 +31,6 @@
   #pragma warning(disable : 4250 4251 4786 4290)
   #endif
   
  -#define _min(a,b) (((a) < (b)) ? (a) : (b))
  -#define _max(a,b) (((a) > (b)) ? (a) : (b))
  -
   #ifdef LOG4CXX
        #define LOG4CXX_EXPORT __declspec(dllexport)
   #else
  
  
  
  1.8       +4 -3      logging-log4cxx/src/boundedfifo.cpp
  
  Index: boundedfifo.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/boundedfifo.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- boundedfifo.cpp   18 Jan 2004 09:50:00 -0000      1.7
  +++ boundedfifo.cpp   10 Apr 2004 21:42:46 -0000      1.8
  @@ -18,6 +18,7 @@
   #include <log4cxx/spi/loggingevent.h>
   #include <log4cxx/helpers/exception.h>
   #include <algorithm>
  +#include <log4cxx/helpers/strictmath.h>
   
   using namespace log4cxx::helpers;
   using namespace log4cxx::spi;
  @@ -83,11 +84,11 @@
        int len1 = maxSize - first;
   
        // we should not copy beyond the tmp array
  -     len1 = _min(len1, newSize);
  +     len1 = StrictMath::min(len1, newSize);
   
        // er.. how much do we actually need to copy?
        // We should not copy more than the actual number of elements.
  -     len1 = _min(len1, numElements);
  +     len1 = StrictMath::min(len1, numElements);
   
        // Copy from buf starting a first, to tmp, starting at position 0, len1
        std::copy(buf.begin() + first, buf.begin() + (first + len1), 
tmp.begin());
  @@ -98,7 +99,7 @@
        if((len1 < numElements) && (len1 < newSize))
        {
                len2 = numElements - len1;
  -             len2 = _min(len2, newSize - len1);
  +             len2 = StrictMath::min(len2, newSize - len1);
                std::copy(buf.begin(), buf.begin() + (len2), tmp.begin() + 
len1);
        }
   
  
  
  
  1.3       +5 -4      logging-log4cxx/tests/src/helpers/boundedfifotestcase.cpp
  
  Index: boundedfifotestcase.cpp
  ===================================================================
  RCS file: 
/home/cvs/logging-log4cxx/tests/src/helpers/boundedfifotestcase.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- boundedfifotestcase.cpp   4 Feb 2004 00:56:33 -0000       1.2
  +++ boundedfifotestcase.cpp   10 Apr 2004 21:42:46 -0000      1.3
  @@ -19,6 +19,7 @@
   #include <log4cxx/logger.h>
   #include <log4cxx/helpers/boundedfifo.h>
   #include <log4cxx/spi/loggingevent.h>
  +#include <log4cxx/helpers/strictmath.h>
   
   using namespace log4cxx;
   using namespace log4cxx::helpers;
  @@ -147,7 +148,7 @@
   
                                bf.resize(n);
   
  -                             int expectedSize = _min(n, _min(i, size));
  +                             int expectedSize = StrictMath::min(n, 
StrictMath::min(i, size));
                                CPPUNIT_ASSERT_EQUAL(expectedSize, bf.length());
   
                                for (int c = 0; c < expectedSize; c++)
  @@ -166,7 +167,7 @@
                {
                        for (int i = 0; i < (size * 2); i++)
                        {
  -                             for (int d = 0; d < _min(i, size); d++)
  +                             for (int d = 0; d < StrictMath::min(i, size); 
d++)
                                {
                                        BoundedFIFO bf(size);
   
  @@ -185,7 +186,7 @@
   
                                        bf.resize(n);
   
  -                                     int expectedSize = _min(n, x);
  +                                     int expectedSize = StrictMath::min(n, 
x);
                                        CPPUNIT_ASSERT_EQUAL(expectedSize, 
bf.length());
   
                                        for (int c = 0; c < expectedSize; c++)
  @@ -226,7 +227,7 @@
   
                                                bf.resize(n);
   
  -                                             int expectedSize = _min(n, x);
  +                                             int expectedSize = 
StrictMath::min(n, x);
                                                
CPPUNIT_ASSERT_EQUAL(expectedSize, bf.length());
   
                                                for (int c = 0; c < 
expectedSize; c++)
  
  
  

Reply via email to