Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
Buffer.h
Go to the documentation of this file.
1 #ifndef QPID_FRAMING_BUFFER_H
2 #define QPID_FRAMING_BUFFER_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "qpid/Exception.h"
27 #include "qpid/sys/IntegerTypes.h"
28 
29 #include <string>
30 
31 namespace qpid {
32 namespace framing {
33 
35  OutOfBounds() : qpid::Exception(std::string("Out of Bounds")) {}
36 };
37 
38 class Content;
39 class FieldTable;
40 
42 {
43  uint32_t size;
44  char* data;
45  uint32_t position;
46 
47  public:
48  void checkAvailable(uint32_t count) { if (position + count > size) throw OutOfBounds(); }
49 
50  QPID_COMMON_EXTERN Buffer(char* data=0, uint32_t size=0);
51 
52  QPID_COMMON_EXTERN void reset();
53 
54  QPID_COMMON_INLINE_EXTERN uint32_t available() { return size - position; }
58  QPID_COMMON_INLINE_EXTERN char* getPointer() { return data; }
59 
60  QPID_COMMON_EXTERN void putOctet(uint8_t i);
61  QPID_COMMON_EXTERN void putShort(uint16_t i);
62  QPID_COMMON_EXTERN void putLong(uint32_t i);
63  QPID_COMMON_EXTERN void putLongLong(uint64_t i);
64  QPID_COMMON_EXTERN void putInt8(int8_t i);
65  QPID_COMMON_EXTERN void putInt16(int16_t i);
66  QPID_COMMON_EXTERN void putInt32(int32_t i);
67  QPID_COMMON_EXTERN void putInt64(int64_t i);
68  QPID_COMMON_EXTERN void putFloat(float f);
69  QPID_COMMON_EXTERN void putDouble(double f);
70  QPID_COMMON_EXTERN void putBin128(const uint8_t* b);
71 
72  QPID_COMMON_EXTERN uint8_t getOctet();
73  QPID_COMMON_EXTERN uint16_t getShort();
74  QPID_COMMON_EXTERN uint32_t getLong();
75  QPID_COMMON_EXTERN uint64_t getLongLong();
76  QPID_COMMON_EXTERN int8_t getInt8();
77  QPID_COMMON_EXTERN int16_t getInt16();
78  QPID_COMMON_EXTERN int32_t getInt32();
79  QPID_COMMON_EXTERN int64_t getInt64();
80  QPID_COMMON_EXTERN float getFloat();
81  QPID_COMMON_EXTERN double getDouble();
82 
83  template <int n>
84  QPID_COMMON_EXTERN uint64_t getUInt();
85 
86  template <int n>
87  QPID_COMMON_EXTERN void putUInt(uint64_t);
88 
89  QPID_COMMON_EXTERN void putShortString(const std::string& s);
90  QPID_COMMON_EXTERN void putMediumString(const std::string& s);
91  QPID_COMMON_EXTERN void putLongString(const std::string& s);
92  QPID_COMMON_EXTERN void getShortString(std::string& s);
93  QPID_COMMON_EXTERN void getMediumString(std::string& s);
94  QPID_COMMON_EXTERN void getLongString(std::string& s);
95  QPID_COMMON_EXTERN void getBin128(uint8_t* b);
96 
97  QPID_COMMON_EXTERN void putRawData(const std::string& s);
98  QPID_COMMON_EXTERN void getRawData(std::string& s, uint32_t size);
99 
100  QPID_COMMON_EXTERN void putRawData(const uint8_t* data, size_t size);
101  QPID_COMMON_EXTERN void getRawData(uint8_t* data, size_t size);
102 
103  template <class T> void put(const T& data) { data.encode(*this); }
104  template <class T> void get(T& data) { data.decode(*this); }
105 
106  QPID_COMMON_EXTERN void dump(std::ostream&) const;
107 };
108 
109 std::ostream& operator<<(std::ostream&, const Buffer&);
110 
111 }} // namespace qpid::framing
112 
113 
114 #endif

Qpid C++ API Reference
Generated on Wed Nov 7 2012 for Qpid C++ Client API by doxygen 1.8.1.1