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(size_t count) { if (count > size - position) 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() const{ return size - position; }
55  QPID_COMMON_INLINE_EXTERN uint32_t getSize() const { return size; }
56  QPID_COMMON_INLINE_EXTERN uint32_t getPosition() const { return position; }
58  QPID_COMMON_INLINE_EXTERN const char * getPointer() const { return data; }
59  QPID_COMMON_INLINE_EXTERN char* getPointer() { return data; }
60 
61  QPID_COMMON_EXTERN void putOctet(uint8_t i);
62  QPID_COMMON_EXTERN void putShort(uint16_t i);
63  QPID_COMMON_EXTERN void putLong(uint32_t i);
64  QPID_COMMON_EXTERN void putLongLong(uint64_t i);
65  QPID_COMMON_EXTERN void putInt8(int8_t i);
66  QPID_COMMON_EXTERN void putInt16(int16_t i);
67  QPID_COMMON_EXTERN void putInt32(int32_t i);
68  QPID_COMMON_EXTERN void putInt64(int64_t i);
69  QPID_COMMON_EXTERN void putFloat(float f);
70  QPID_COMMON_EXTERN void putDouble(double f);
71  QPID_COMMON_EXTERN void putBin128(const uint8_t* b);
72 
73  QPID_COMMON_EXTERN uint8_t getOctet();
74  QPID_COMMON_EXTERN uint16_t getShort();
75  QPID_COMMON_EXTERN uint32_t getLong();
76  QPID_COMMON_EXTERN uint64_t getLongLong();
77  QPID_COMMON_EXTERN int8_t getInt8();
78  QPID_COMMON_EXTERN int16_t getInt16();
79  QPID_COMMON_EXTERN int32_t getInt32();
80  QPID_COMMON_EXTERN int64_t getInt64();
81  QPID_COMMON_EXTERN float getFloat();
82  QPID_COMMON_EXTERN double getDouble();
83 
84  template <int n>
85  QPID_COMMON_EXTERN uint64_t getUInt();
86 
87  template <int n>
88  QPID_COMMON_EXTERN void putUInt(uint64_t);
89 
90  QPID_COMMON_EXTERN void putShortString(const std::string& s);
91  QPID_COMMON_EXTERN void putMediumString(const std::string& s);
92  QPID_COMMON_EXTERN void putLongString(const std::string& s);
93  QPID_COMMON_EXTERN void getShortString(std::string& s);
94  QPID_COMMON_EXTERN void getMediumString(std::string& s);
95  QPID_COMMON_EXTERN void getLongString(std::string& s);
96  QPID_COMMON_EXTERN void getBin128(uint8_t* b);
97 
98  QPID_COMMON_EXTERN void putRawData(const std::string& s);
99  QPID_COMMON_EXTERN void getRawData(std::string& s, uint32_t size);
100 
101  QPID_COMMON_EXTERN void putRawData(const uint8_t* data, size_t size);
102  QPID_COMMON_EXTERN void getRawData(uint8_t* data, size_t size);
103 
104  template <class T> void put(const T& data) { data.encode(*this); }
105  template <class T> void get(T& data) { data.decode(*this); }
106 
107  QPID_COMMON_EXTERN void dump(std::ostream&) const;
108 };
109 
110 std::ostream& operator<<(std::ostream&, const Buffer&);
111 
112 }} // namespace qpid::framing
113 
114 
115 #endif

Qpid C++ API Reference
Generated on Thu Sep 26 2013 for Qpid C++ Client API by doxygen 1.8.3.1