Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
qpid/framing/Array.h
Go to the documentation of this file.
00001 #ifndef QPID_FRAMING_ARRAY_H
00002 #define QPID_FRAMING_ARRAY_H
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  *
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include "qpid/framing/amqp_types.h"
00026 #include "qpid/framing/TypeCode.h"
00027 
00028 #include <boost/shared_ptr.hpp>
00029 
00030 #include <iostream>
00031 #include <vector>
00032 
00033 #include "qpid/CommonImportExport.h"
00034 
00035 namespace qpid {
00036 namespace framing {
00037 
00038 class Buffer;
00039 class FieldValue;
00040 
00041 class QPID_COMMON_CLASS_EXTERN Array
00042 {
00043   public:
00044     typedef boost::shared_ptr<FieldValue> ValuePtr;
00045     typedef std::vector<ValuePtr> ValueVector;
00046     typedef ValueVector::const_iterator const_iterator;
00047     typedef ValueVector::iterator iterator;
00048 
00049     QPID_COMMON_EXTERN uint32_t encodedSize() const;
00050     QPID_COMMON_EXTERN void encode(Buffer& buffer) const;
00051     QPID_COMMON_EXTERN void decode(Buffer& buffer);
00052 
00053     QPID_COMMON_EXTERN int count() const;
00054     QPID_COMMON_EXTERN bool operator==(const Array& other) const;
00055 
00056     QPID_COMMON_EXTERN Array();
00057     QPID_COMMON_EXTERN Array(TypeCode type);
00058     QPID_COMMON_EXTERN Array(uint8_t type);
00059     //creates a longstr array
00060     QPID_COMMON_EXTERN Array(const std::vector<std::string>& in);
00061 
00062     QPID_COMMON_INLINE_EXTERN TypeCode getType() const { return type; }
00063 
00064     // std collection interface.
00065     QPID_COMMON_INLINE_EXTERN const_iterator begin() const { return values.begin(); }
00066     QPID_COMMON_INLINE_EXTERN const_iterator end() const { return values.end(); }
00067     QPID_COMMON_INLINE_EXTERN iterator begin() { return values.begin(); }
00068     QPID_COMMON_INLINE_EXTERN iterator end(){ return values.end(); }
00069 
00070     QPID_COMMON_INLINE_EXTERN ValuePtr front() const { return values.front(); }
00071     QPID_COMMON_INLINE_EXTERN ValuePtr back() const { return values.back(); }
00072     QPID_COMMON_INLINE_EXTERN size_t size() const { return values.size(); }
00073 
00074     QPID_COMMON_EXTERN void insert(iterator i, ValuePtr value);
00075     QPID_COMMON_INLINE_EXTERN void erase(iterator i) { values.erase(i); }
00076     QPID_COMMON_INLINE_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); }
00077     QPID_COMMON_INLINE_EXTERN void pop_back() { values.pop_back(); }
00078 
00079     // Non-std interface
00080     QPID_COMMON_INLINE_EXTERN void add(ValuePtr value) { push_back(value); }
00081 
00082     // For use in standard algorithms
00083     template <typename R, typename V>
00084     static R get(const V& v) {
00085         return v->template get<R>();
00086     }
00087 
00088   private:
00089     TypeCode type;
00090     ValueVector values;
00091 
00092     friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const Array& body);
00093 };
00094 
00095 }
00096 }
00097 
00098 
00099 #endif

Qpid C++ API Reference
Generated on Mon Dec 10 2012 for Qpid C++ Client API by doxygen 1.7.5