summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/management/Buffer.cpp
blob: 7556b2a2433532db1d87ff4583bd6c2a123e63f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

#include "qpid/management/Buffer.h"
#include "qpid/framing/Buffer.h"
#include "qpid/amqp_0_10/Codecs.h"

using namespace std;

namespace qpid {
namespace management {

Buffer::Buffer(char* data, uint32_t size) : impl(new framing::Buffer(data, size)) {}
Buffer::~Buffer() { delete impl; }
void Buffer::record() { impl->record(); }
void Buffer::restore(bool reRecord) { impl->restore(reRecord); }
void Buffer::reset() { impl->reset(); }
uint32_t Buffer::available() { return impl->available(); }
uint32_t Buffer::getSize() { return impl->getSize(); }
uint32_t Buffer::getPosition() { return impl->getPosition(); }
char* Buffer::getPointer() { return impl->getPointer(); }
void Buffer::putOctet(uint8_t i) { impl->putOctet(i); }
void Buffer::putShort(uint16_t i) { impl->putShort(i); }
void Buffer::putLong(uint32_t i) { impl->putLong(i); }
void Buffer::putLongLong(uint64_t i) { impl->putLongLong(i); }
void Buffer::putInt8(int8_t i) { impl->putInt8(i); }
void Buffer::putInt16(int16_t i) { impl->putInt16(i); }
void Buffer::putInt32(int32_t i) { impl->putInt32(i); }
void Buffer::putInt64(int64_t i) { impl->putInt64(i); }
void Buffer::putFloat(float i) { impl->putFloat(i); }
void Buffer::putDouble(double i) { impl->putDouble(i); }
void Buffer::putBin128(const uint8_t* i) { impl->putBin128(i); }
uint8_t Buffer::getOctet() { return impl->getOctet(); }
uint16_t Buffer::getShort() { return impl->getShort(); }
uint32_t Buffer::getLong() { return impl->getLong(); }
uint64_t Buffer::getLongLong() { return impl->getLongLong(); }
int8_t Buffer:: getInt8() { return impl-> getInt8(); }
int16_t Buffer::getInt16() { return impl->getInt16(); }
int32_t Buffer::getInt32() { return impl->getInt32(); }
int64_t Buffer::getInt64() { return impl->getInt64(); }
float Buffer::getFloat() { return impl->getFloat(); }
double Buffer::getDouble() { return impl->getDouble(); }
void Buffer::putShortString(const string& i) { impl->putShortString(i); }
void Buffer::putMediumString(const string& i) { impl->putMediumString(i); }
void Buffer::putLongString(const string& i) { impl->putLongString(i); }
void Buffer::getShortString(string& i) { impl->getShortString(i); }
void Buffer::getMediumString(string& i) { impl->getMediumString(i); }
void Buffer::getLongString(string& i) { impl->getLongString(i); }
void Buffer::getBin128(uint8_t* i) { impl->getBin128(i); }
void Buffer::putRawData(const string& i) { impl->putRawData(i); }
void Buffer::getRawData(string& s, uint32_t size) { impl->getRawData(s, size); }
void Buffer::putRawData(const uint8_t* data, size_t size) { impl->putRawData(data, size); }
void Buffer::getRawData(uint8_t* data, size_t size) { impl->getRawData(data, size); }

void Buffer::putMap(const types::Variant::Map& i)
{
    string encoded;
    amqp_0_10::MapCodec::encode(i, encoded);
    impl->putRawData(encoded);
}

void Buffer::putList(const types::Variant::List& i)
{
    string encoded;
    amqp_0_10::ListCodec::encode(i, encoded);
    impl->putRawData(encoded);
}

void Buffer::getMap(types::Variant::Map& map)
{
    string encoded;
    uint32_t saved = impl->getPosition();
    uint32_t length = impl->getLong();
    impl->setPosition(saved);
    impl->getRawData(encoded, length + sizeof(uint32_t));
    amqp_0_10::MapCodec::decode(encoded, map);
}

void Buffer::getList(types::Variant::List& list)
{
    string encoded;
    uint32_t saved = impl->getPosition();
    uint32_t length = impl->getLong();
    impl->setPosition(saved);
    impl->getRawData(encoded, length + sizeof(uint32_t));
    amqp_0_10::ListCodec::decode(encoded, list);
}

}}