[opengtl-commits] [162] add a function to return wether a type is an unsigned integer or not |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 162
Author: cyrille
Date: 2008-05-02 19:03:47 +0200 (Fri, 02 May 2008)
Log Message:
-----------
add a function to return wether a type is an unsigned integer or not
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type.h
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-05-02 16:58:35 UTC (rev 161)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-05-02 17:03:47 UTC (rev 162)
@@ -236,3 +236,21 @@
}
}
+
+bool Type::isSigned() const
+{
+ return not isUnsigned();
+}
+
+bool Type::isUnsigned() const
+{
+ switch( dataType() )
+ {
+ case Type::UNSIGNED_INTEGER8:
+ case Type::UNSIGNED_INTEGER16:
+ case Type::UNSIGNED_INTEGER32:
+ return true;
+ default:
+ return false;
+ }
+}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-05-02 16:58:35 UTC (rev 161)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-05-02 17:03:47 UTC (rev 162)
@@ -143,6 +143,15 @@
* @return the size of this type in bytes (or -1 for structures and arrays)
*/
int bitsSize() const;
+ /**
+ * Convenient function that return the opposite of \ref isUnsigned()
+ * @return true if the type is signed
+ */
+ bool isSigned() const;
+ /**
+ * @return true if the type is an unsigned integer
+ */
+ bool isUnsigned() const;
private:
struct Private;
Private* const d;