make boolean type unambiguous

"char", "signed char", and "unsigned char"
are distinct types.  Define "boolean" to
be whichever is not "int8" or "uint8".
This commit is contained in:
Michael Davidsaver
2013-07-03 17:25:29 -04:00
parent 73450bdbc7
commit 6900d4bbec
3 changed files with 16 additions and 6 deletions

View File

@@ -28,7 +28,7 @@ using std::min;
namespace epics { namespace pvData {
//template<> const ScalarType PVBoolean::typeCode = pvBoolean;
template<> const ScalarType PVBoolean::typeCode = pvBoolean;
template<> const ScalarType PVByte::typeCode = pvByte;
template<> const ScalarType PVShort::typeCode = pvShort;
template<> const ScalarType PVInt::typeCode = pvInt;
@@ -41,7 +41,7 @@ template<> const ScalarType PVFloat::typeCode = pvFloat;
template<> const ScalarType PVDouble::typeCode = pvDouble;
template<> const ScalarType PVScalarValue<String>::typeCode = pvString;
//template<> const ScalarType PVBooleanArray::typeCode = pvBoolean;
template<> const ScalarType PVBooleanArray::typeCode = pvBoolean;
template<> const ScalarType PVByteArray::typeCode = pvByte;
template<> const ScalarType PVShortArray::typeCode = pvShort;
template<> const ScalarType PVIntArray::typeCode = pvInt;

View File

@@ -530,7 +530,7 @@ private:
/**
* typedefs for the various possible scalar types.
*/
typedef PVScalarValue<uint8> PVBoolean;
typedef PVScalarValue<boolean> PVBoolean;
typedef PVScalarValue<int8> PVByte;
typedef PVScalarValue<int16> PVShort;
typedef PVScalarValue<int32> PVInt;
@@ -1373,8 +1373,8 @@ private:
/**
* Definitions for the various scalarArray types.
*/
typedef PVArrayData<uint8> BooleanArrayData;
typedef PVValueArray<uint8> PVBooleanArray;
typedef PVArrayData<boolean> BooleanArrayData;
typedef PVValueArray<boolean> PVBooleanArray;
typedef std::tr1::shared_ptr<PVBooleanArray> PVBooleanArrayPtr;
typedef PVArrayData<int8> ByteArrayData;

View File

@@ -33,6 +33,14 @@ typedef unsigned int uintptr_t;
namespace epics { namespace pvData {
namespace detail {
// Pick either type If or type Else to not be Cond
template<typename Cond, typename If, typename Else>
struct pick_type { typedef If type; };
template<typename Cond, typename Else>
struct pick_type<Cond,Cond,Else> { typedef Else type; };
}
/**
* This is a set of typdefs used by pvData.
*/
@@ -40,7 +48,9 @@ namespace epics { namespace pvData {
/**
* boolean, i.e. can only have the values {@code false} or {@code true}
*/
typedef uint8_t boolean;
typedef detail::pick_type<int8_t, signed char,
detail::pick_type<uint8_t, char, unsigned char>::type
>::type boolean;
/**
* A 8 bit signed integer
*/