diff options
author | Steve Huston <shuston@riverace.com> | 2006-02-24 17:34:00 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2006-02-24 17:34:00 +0000 |
commit | bd15f22873940ae9af4ea3450f905b4a72380fc5 (patch) | |
tree | 23e397faac48e59a7390a69bfddffb4110ef283e /ace | |
parent | 332746f647c1c4c2712ac0eba852f06ddfc08614 (diff) | |
download | ATCD-bd15f22873940ae9af4ea3450f905b4a72380fc5.tar.gz |
ChangeLogTag:Fri Feb 24 17:29:47 UTC 2006 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Makefile.am | 2 | ||||
-rw-r--r-- | ace/Truncate.cpp | 15 | ||||
-rw-r--r-- | ace/Truncate.h | 44 | ||||
-rw-r--r-- | ace/Truncate.inl | 46 | ||||
-rw-r--r-- | ace/ace.mpc | 1 |
5 files changed, 38 insertions, 70 deletions
diff --git a/ace/Makefile.am b/ace/Makefile.am index 884ef906432..125717f240b 100644 --- a/ace/Makefile.am +++ b/ace/Makefile.am @@ -322,7 +322,6 @@ libACE_la_SOURCES = \ Token_Manager.cpp \ Token_Request_Reply.cpp \ Trace.cpp \ - Truncate.cpp \ UNIX_Addr.cpp \ UPIPE_Acceptor.cpp \ UPIPE_Connector.cpp \ @@ -1044,7 +1043,6 @@ nobase_include_HEADERS += \ Token_Request_Reply.inl \ Trace.h \ Truncate.h \ - Truncate.inl \ Typed_SV_Message.cpp \ Typed_SV_Message.h \ Typed_SV_Message.inl \ diff --git a/ace/Truncate.cpp b/ace/Truncate.cpp deleted file mode 100644 index 722f34027d9..00000000000 --- a/ace/Truncate.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// $Id$ - -#ifndef ACE_TRUNCATE_CPP -#define ACE_TRUNCATE_CPP - -#include "ace/Truncate.h" - -#if !defined(__ACE_INLINE__) -# include "ace/Truncate.inl" -#endif /* __ACE_INLINE__ */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_END_VERSIONED_NAMESPACE_DECL - -#endif /*ACE_TRUNCATE_CPP*/ diff --git a/ace/Truncate.h b/ace/Truncate.h index 62e7091c31d..de347d1dc06 100644 --- a/ace/Truncate.h +++ b/ace/Truncate.h @@ -20,6 +20,19 @@ #include "ace/Global_Macros.h" +#if !defined(ACE_LACKS_NUMERIC_LIMITS) +// some platforms pollute the namespace by defining max() and min() macros +# ifdef max +# undef max +# endif +# ifdef min +# undef min +# endif +# include <limits> +#else +# include "ace/os_include/os_limits.h" +#endif /* ACE_LACKS_NUMERIC_LIMITS */ + ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_Utils @@ -28,25 +41,44 @@ namespace ACE_Utils * @class Truncate * * @brief Helper function to truncate an integral value to an int. + * * Very useful since ACE methods return int very often and the value's * source is often a different-size integral type, such as size_t. * This function hides the truncation logic and resolves compiler * diagnostics. + * + * @internal Internal use only. */ template<typename X> -ACE_INLINE_TEMPLATE_FUNCTION int Truncate (const X& val); +inline int Truncate (const X& val) +{ +#if !defined (ACE_LACKS_NUMERIC_LIMITS) + if (val > static_cast<X> (std::numeric_limits<int>::max ())) + return std::numeric_limits<int>::max (); +#else + if (val > static_cast<X> (INT_MAX)) + return INT_MAX; +#endif /* ACE_LACKS_NUMERIC_LIMITS */ + return static_cast<int> (val); +} // Specialize one for size_t to alleviate the explicit instantiation pain. template<> -ACE_INLINE_TEMPLATE_FUNCTION int Truncate<size_t> (const size_t& val); +inline int Truncate<size_t> (const size_t& val) +{ +#if !defined (ACE_LACKS_NUMERIC_LIMITS) + if (val > static_cast<size_t> (std::numeric_limits<int>::max ())) + return std::numeric_limits<int>::max (); +#else + if (val > static_cast<size_t> (INT_MAX)) + return INT_MAX; +#endif /* ACE_LACKS_NUMERIC_LIMITS */ + return static_cast<int> (val); +} } // namespace ACE_Utils ACE_END_VERSIONED_NAMESPACE_DECL -#if defined(__ACE_INLINE__) -# include "ace/Truncate.inl" -#endif /* __ACE_INLINE__ */ - #include /**/ "ace/post.h" #endif /* ACE_TRUNCATE_H*/ diff --git a/ace/Truncate.inl b/ace/Truncate.inl deleted file mode 100644 index a7811efc499..00000000000 --- a/ace/Truncate.inl +++ /dev/null @@ -1,46 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#if !defined(ACE_LACKS_NUMERIC_LIMITS) -// some platforms pollute the namespace by defining max() and min() macros -#ifdef max -#undef max -#endif -#ifdef min -#undef min -#endif -#include <limits> -#else -#include "ace/os_include/os_limits.h" -#endif /* ACE_LACKS_NUMERIC_LIMITS */ - -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - -template<typename X> ACE_INLINE_TEMPLATE_FUNCTION int -ACE_Utils::Truncate (const X &val) -{ -#if !defined (ACE_LACKS_NUMERIC_LIMITS) - if (val > static_cast<X> (std::numeric_limits<int>::max ())) - return std::numeric_limits<int>::max (); -#else - if (val > static_cast<X> (INT_MAX)) - return INT_MAX; -#endif /* ACE_LACKS_NUMERIC_LIMITS */ - return static_cast<int> (val); -} - -template<> ACE_INLINE_TEMPLATE_FUNCTION int -ACE_Utils::Truncate<size_t> (const size_t &val) -{ -#if !defined (ACE_LACKS_NUMERIC_LIMITS) - if (val > static_cast<size_t> (std::numeric_limits<int>::max ())) - return std::numeric_limits<int>::max (); -#else - if (val > static_cast<size_t> (INT_MAX)) - return INT_MAX; -#endif /* ACE_LACKS_NUMERIC_LIMITS */ - return static_cast<int> (val); -} - -ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ace/ace.mpc b/ace/ace.mpc index 63df606091b..503c7c3123b 100644 --- a/ace/ace.mpc +++ b/ace/ace.mpc @@ -270,7 +270,6 @@ project(ACE) : acedefaults, core, other, codecs, token, svcconf, uuid, filecache Token.cpp TP_Reactor.cpp Trace.cpp - Truncate.cpp TSS_Adapter.cpp TTY_IO.cpp UNIX_Addr.cpp |