From 2bb04f798f13d3120096a9fb2ee30d224fbd981a Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 31 Jul 2008 21:58:39 +0000 Subject: Added signed integer datatypes for use in management schemas git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@681512 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/framing/Buffer.cpp | 32 ++++++++++++++++++ cpp/src/qpid/framing/Buffer.h | 8 +++++ cpp/src/qpid/management/ManagementObject.h | 4 +++ python/qpid/management.py | 16 +++++++++ python/qpid/managementdata.py | 11 +++++- specs/management-schema.xml | 2 +- specs/management-types.xml | 54 ++++++++++++++++-------------- 7 files changed, 100 insertions(+), 27 deletions(-) diff --git a/cpp/src/qpid/framing/Buffer.cpp b/cpp/src/qpid/framing/Buffer.cpp index 19c94ffd58..9c089fd0f8 100644 --- a/cpp/src/qpid/framing/Buffer.cpp +++ b/cpp/src/qpid/framing/Buffer.cpp @@ -74,6 +74,22 @@ void Buffer::putLongLong(uint64_t i){ putLong(lo); } +void Buffer::putInt8(int8_t i){ + data[position++] = (uint8_t) i; +} + +void Buffer::putInt16(int16_t i){ + putShort((uint16_t) i); +} + +void Buffer::putInt32(int32_t i){ + putLong((uint32_t) i); +} + +void Buffer::putInt64(int64_t i){ + putLongLong((uint64_t) i); +} + void Buffer::putFloat(float f){ union { uint32_t i; @@ -129,6 +145,22 @@ uint64_t Buffer::getLongLong(){ return hi | lo; } +int8_t Buffer::getInt8(){ + return (int8_t) data[position++]; +} + +int16_t Buffer::getInt16(){ + return (int16_t) getShort(); +} + +int32_t Buffer::getInt32(){ + return (int32_t) getLong(); +} + +int64_t Buffer::getInt64(){ + return (int64_t) getLongLong(); +} + float Buffer::getFloat(){ union { uint32_t i; diff --git a/cpp/src/qpid/framing/Buffer.h b/cpp/src/qpid/framing/Buffer.h index 94cc2d320f..a27b15cac0 100644 --- a/cpp/src/qpid/framing/Buffer.h +++ b/cpp/src/qpid/framing/Buffer.h @@ -79,6 +79,10 @@ class Buffer void putShort(uint16_t i); void putLong(uint32_t i); void putLongLong(uint64_t i); + void putInt8(int8_t i); + void putInt16(int16_t i); + void putInt32(int32_t i); + void putInt64(int64_t i); void putFloat(float f); void putDouble(double f); void putBin128(uint8_t* b); @@ -87,6 +91,10 @@ class Buffer uint16_t getShort(); uint32_t getLong(); uint64_t getLongLong(); + int8_t getInt8(); + int16_t getInt16(); + int32_t getInt32(); + int64_t getInt64(); float getFloat(); double getDouble(); diff --git a/cpp/src/qpid/management/ManagementObject.h b/cpp/src/qpid/management/ManagementObject.h index ce3051367d..78d065aac2 100644 --- a/cpp/src/qpid/management/ManagementObject.h +++ b/cpp/src/qpid/management/ManagementObject.h @@ -62,6 +62,10 @@ class ManagementObject static const uint8_t TYPE_DOUBLE = 13; static const uint8_t TYPE_UUID = 14; static const uint8_t TYPE_FTABLE = 15; + static const uint8_t TYPE_S8 = 16; + static const uint8_t TYPE_S16 = 17; + static const uint8_t TYPE_S32 = 18; + static const uint8_t TYPE_S64 = 19; static const uint8_t ACCESS_RC = 1; static const uint8_t ACCESS_RW = 2; diff --git a/python/qpid/management.py b/python/qpid/management.py index 1059c70ada..83c29a78a5 100644 --- a/python/qpid/management.py +++ b/python/qpid/management.py @@ -397,6 +397,14 @@ class managementClient: codec.write_uuid (value) elif typecode == 15: # FTABLE codec.write_map (value) + elif typecode == 16: + codec.write_int8 (int(value)) + elif typecode == 17: + codec.write_int16 (int(value)) + elif typecode == 18: + codec.write_int32 (int(value)) + elif typecode == 19: + codec.write_int64 (int(value)) else: raise ValueError ("Invalid type code: %d" % typecode) @@ -432,6 +440,14 @@ class managementClient: data = codec.read_uuid () elif typecode == 15: # FTABLE data = codec.read_map () + elif typecode == 16: + data = codec.read_int8 () + elif typecode == 17: + data = codec.read_int16 () + elif typecode == 18: + data = codec.read_int32 () + elif typecode == 19: + data = codec.read_int64 () else: raise ValueError ("Invalid type code: %d" % typecode) return data diff --git a/python/qpid/managementdata.py b/python/qpid/managementdata.py index f6ebf4a381..e75cd8a99d 100644 --- a/python/qpid/managementdata.py +++ b/python/qpid/managementdata.py @@ -222,7 +222,8 @@ class ManagementData: if item[0] == key: typecode = item[1] unit = item[2] - if (typecode >= 1 and typecode <= 5) or typecode == 12 or typecode == 13: # numerics + if (typecode >= 1 and typecode <= 5) or typecode == 12 or typecode == 13 or \ + (typecode >= 16 and typecode <= 19): if unit == None or unit == self.lastUnit: return str (value) else: @@ -329,6 +330,14 @@ class ManagementData: return "uuid" elif typecode == 15: return "field-table" + elif typecode == 16: + return "int8" + elif typecode == 17: + return "int16" + elif typecode == 18: + return "int32" + elif typecode == 19: + return "int64" else: raise ValueError ("Invalid type code: %d" % typecode) diff --git a/specs/management-schema.xml b/specs/management-schema.xml index 75c4dffd8e..64b37a1db7 100644 --- a/specs/management-schema.xml +++ b/specs/management-schema.xml @@ -80,7 +80,7 @@ - + diff --git a/specs/management-types.xml b/specs/management-types.xml index 7ed320f6fa..309c94c98b 100644 --- a/specs/management-types.xml +++ b/specs/management-types.xml @@ -19,34 +19,38 @@ under the License. --> - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - + + + -- cgit v1.2.1