diff options
| author | Carl C. Trieloff <cctrieloff@apache.org> | 2008-02-28 18:55:21 +0000 |
|---|---|---|
| committer | Carl C. Trieloff <cctrieloff@apache.org> | 2008-02-28 18:55:21 +0000 |
| commit | ac3f850123c903f00c163d6d2dbad22d98aec7a2 (patch) | |
| tree | 2e622a3e9349a9062454d16bf4bca83a5a3e9d90 /cpp/src/qpid/framing/Buffer.cpp | |
| parent | 1820dd421a096ed184a08deee9512e809312fed2 (diff) | |
| download | qpid-python-ac3f850123c903f00c163d6d2dbad22d98aec7a2.tar.gz | |
QPID-820 from tross
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@632087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/Buffer.cpp')
| -rw-r--r-- | cpp/src/qpid/framing/Buffer.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cpp/src/qpid/framing/Buffer.cpp b/cpp/src/qpid/framing/Buffer.cpp index 7eadf377b9..c0cd210042 100644 --- a/cpp/src/qpid/framing/Buffer.cpp +++ b/cpp/src/qpid/framing/Buffer.cpp @@ -74,6 +74,31 @@ void Buffer::putLongLong(uint64_t i){ putLong(lo); } +void Buffer::putFloat(float f){ + union { + uint32_t i; + float f; + } val; + + val.f = f; + putLong (val.i); +} + +void Buffer::putDouble(double f){ + union { + uint64_t i; + double f; + } val; + + val.f = f; + putLongLong (val.i); +} + +void Buffer::putBin128(uint8_t* b){ + memcpy (data + position, b, 16); + position += 16; +} + uint8_t Buffer::getOctet(){ return (uint8_t) data[position++]; } @@ -104,6 +129,24 @@ uint64_t Buffer::getLongLong(){ return hi | lo; } +float Buffer::getFloat(){ + union { + uint32_t i; + float f; + } val; + val.i = getLong(); + return val.f; +} + +double Buffer::getDouble(){ + union { + uint64_t i; + double f; + } val; + val.i = getLongLong(); + return val.f; +} + template <> uint64_t Buffer::getUInt<1>() { return getOctet(); @@ -172,6 +215,11 @@ void Buffer::getLongString(string& s){ position += len; } +void Buffer::getBin128(uint8_t* b){ + memcpy (b, data + position, 16); + position += 16; +} + void Buffer::putRawData(const string& s){ uint32_t len = s.length(); s.copy(data + position, len); |
