Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
Array.h
Go to the documentation of this file.
1 #ifndef QPID_FRAMING_ARRAY_H
2 #define QPID_FRAMING_ARRAY_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 
26 #include "qpid/framing/TypeCode.h"
27 
28 #include <boost/shared_ptr.hpp>
29 
30 #include <iostream>
31 #include <vector>
32 
34 
35 namespace qpid {
36 namespace framing {
37 
38 class Buffer;
39 class FieldValue;
40 
42 {
43  public:
44  typedef boost::shared_ptr<FieldValue> ValuePtr;
45  typedef std::vector<ValuePtr> ValueVector;
46  typedef ValueVector::const_iterator const_iterator;
47  typedef ValueVector::iterator iterator;
48 
49  QPID_COMMON_EXTERN uint32_t encodedSize() const;
50  QPID_COMMON_EXTERN void encode(Buffer& buffer) const;
51  QPID_COMMON_EXTERN void decode(Buffer& buffer);
52 
53  QPID_COMMON_EXTERN int count() const;
54  QPID_COMMON_EXTERN bool operator==(const Array& other) const;
55 
59  //creates a longstr array
60  QPID_COMMON_EXTERN Array(const std::vector<std::string>& in);
61 
62  QPID_COMMON_INLINE_EXTERN TypeCode getType() const { return type; }
63 
64  // std collection interface.
65  QPID_COMMON_INLINE_EXTERN const_iterator begin() const { return values.begin(); }
66  QPID_COMMON_INLINE_EXTERN const_iterator end() const { return values.end(); }
67  QPID_COMMON_INLINE_EXTERN iterator begin() { return values.begin(); }
68  QPID_COMMON_INLINE_EXTERN iterator end(){ return values.end(); }
69 
70  QPID_COMMON_INLINE_EXTERN ValuePtr front() const { return values.front(); }
71  QPID_COMMON_INLINE_EXTERN ValuePtr back() const { return values.back(); }
72  QPID_COMMON_INLINE_EXTERN size_t size() const { return values.size(); }
73 
74  QPID_COMMON_EXTERN void insert(iterator i, ValuePtr value);
75  QPID_COMMON_INLINE_EXTERN void erase(iterator i) { values.erase(i); }
76  QPID_COMMON_INLINE_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); }
77  QPID_COMMON_INLINE_EXTERN void pop_back() { values.pop_back(); }
78 
79  // Non-std interface
80  QPID_COMMON_INLINE_EXTERN void add(ValuePtr value) { push_back(value); }
81 
82  // For use in standard algorithms
83  template <typename R, typename V>
84  static R get(const V& v) {
85  return v->template get<R>();
86  }
87 
88  private:
89  TypeCode type;
90  ValueVector values;
91 
92  friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Array& body);
93 };
94 
95 }
96 }
97 
98 
99 #endif

Qpid C++ API Reference
Generated on Tue Sep 25 2012 for Qpid C++ Client API by doxygen 1.8.1.1