From: Christian P. <cp...@us...> - 2005-01-24 01:21:12
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8148 Modified Files: IntTypes.h IntTypeLimits.h Log Message: Fixed IntTypeLimits. Use static const instead of enum. Index: IntTypeLimits.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IntTypeLimits.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- IntTypeLimits.h 22 Dec 2004 17:54:39 -0000 1.1.1.1 +++ IntTypeLimits.h 24 Jan 2005 01:21:03 -0000 1.2 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_IntTypeLimits_h_ -#define _P_IntTypeLimits_h_ +#ifndef P_IntTypeLimits_h +#define P_IntTypeLimits_h #include <pclasses/BasicTypes.h> @@ -33,74 +33,58 @@ template <> struct IntLimits<uint8_t> { - enum { - Max = (uint8_t)-1, - Min = 0 - }; + static const uint8_t Max = (uint8_t)-1; + static const uint8_t Min = 0; }; template <> struct IntLimits<int8_t> { - enum { - Max = 127, - Min = -Max - 1 - }; + static const int8_t Max = 127; + static const int8_t Min = -Max - 1; }; template <> struct IntLimits<uint16_t> { - enum { - Max = (uint16_t)-1, - Min = 0 - }; + static const uint16_t Max = (uint16_t)-1; + static const uint16_t Min = 0; }; template <> struct IntLimits<int16_t> { - enum { - Max = 32767, - Min = -Max - 1 - }; + static const int16_t Max = 32767; + static const int16_t Min = -Max - 1; }; template <> struct IntLimits<uint32_t> { - enum { - Max = (uint32_t)-1, - Min = 0 - }; + static const uint32_t Max = (uint32_t)-1; + static const uint32_t Min = 0; }; template <> struct IntLimits<int32_t> { - enum { - Max = 2147483647, - Min = -Max - 1 - }; + static const int32_t Max = 2147483647; + static const int32_t Min = -Max - 1; }; #ifdef PCLASSES_HAVE_64BIT_INT template <> struct IntLimits<uint64_t> { - enum { - Max = (uint64_t)-1, - Min = 0 - }; + static const uint64_t Max = (uint64_t)-1; + static const uint64_t Min = 0; }; template <> struct IntLimits<int64_t> { - enum { - Max = PCLASSES_S64(9223372036854775807), - Min = -Max - 1 - }; + static const int64_t Max = PCLASSES_S64(9223372036854775807); + static const int64_t Min = -Max - 1; }; #endif Index: IntTypes.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IntTypes.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IntTypes.h 24 Dec 2004 17:15:50 -0000 1.2 +++ IntTypes.h 24 Jan 2005 01:21:03 -0000 1.3 @@ -34,11 +34,6 @@ public: typedef Traits::ByteOrderTraits<Type> TraitsType; - enum { - Min = Traits::IntLimits<Type>::Min, - Max = Traits::IntLimits<Type>::Max - }; - //! Default constructor IntType(const Type& val = Type()) : ValueType<Type>(val) @@ -48,6 +43,12 @@ ~IntType() throw() { } + static Type min() + { return Traits::IntLimits<Type>::Min; } + + static Type max() + { return Traits::IntLimits<Type>::Max; } + //! Set the value from little-endian value void setLittleEndian(const IntType& val) throw() { TraitsType::setLittleEndian(this->_value, val._value); } |