diff --git a/pvDataApp/misc/typeCast.h b/pvDataApp/misc/typeCast.h index 6719dcb..7b1efb3 100644 --- a/pvDataApp/misc/typeCast.h +++ b/pvDataApp/misc/typeCast.h @@ -46,34 +46,28 @@ namespace detail { // Handle mangling of type/value when printing template struct print_convolute { - static FORCE_INLINE T op(const T& i) { return i; } + typedef T return_t; + static FORCE_INLINE return_t op(const T& i) { return i; } }; // trick std::ostream into treating char's as numbers // by promoting char to int template<> struct print_convolute { - static FORCE_INLINE signed int op(int8 i) { return i; } + typedef signed int return_t; + static FORCE_INLINE return_t op(int8 i) { return i; } }; template<> struct print_convolute { - static FORCE_INLINE unsigned int op(uint8 i) { return i; } + typedef unsigned int return_t; + static FORCE_INLINE return_t op(uint8 i) { return i; } }; // Turn boolean into a string template<> struct print_convolute { - static FORCE_INLINE String op(boolean i) { return i ? "true" : "false"; } + typedef const char* return_t; + static FORCE_INLINE return_t op(boolean i) { return i ? "true" : "false"; } }; - // trick std::ostream into treating char's as numbers - // by promoting char to int - template - struct print_cast { typedef T type; }; - template<> - struct print_cast { typedef int type; }; - template<> - struct print_cast { typedef signed int type; }; - template<> - struct print_cast { typedef unsigned int type; }; // default to C++ type casting template @@ -180,12 +174,13 @@ static FORCE_INLINE TO castUnsafe(const FROM& from) void castUnsafeV(size_t count, ScalarType to, void *dest, ScalarType from, const void *src); //! Cast value to printable type -//! A no-op except for char types, which are cast to int -//! so that they are printed as numbers std::ostream operators. +//! A no-op except for int8 and uint8, which are cast to int +//! so that they are printed as numbers std::ostream operators, +//! and boolean which is transformed into a const char* template static FORCE_INLINE -typename detail::print_cast::type -print_cast(const T& v) { return v; } +typename detail::print_convolute::return_t +print_cast(const T& v) { return detail::print_convolute::op(v); } }} // end namespace