diff options
| author | Gordon Sim <gsim@apache.org> | 2007-11-06 17:27:27 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2007-11-06 17:27:27 +0000 |
| commit | a2ded139f371d273afa858f49a5b7f6e0efc2394 (patch) | |
| tree | 8fc04da8ffe3aa819843a101a75d98429f27eaa5 /cpp/src/qpid/framing/Array.h | |
| parent | a1a0ecfbf02293cf917db5e56d65d367be5ad5a7 (diff) | |
| download | qpid-python-a2ded139f371d273afa858f49a5b7f6e0efc2394.tar.gz | |
Add support for array type to c++ (and python, decode only for now)
Change the type of the in-doubt field in dtx-coordination.recover to an array (to bring in line with amqp spec)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@592494 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/Array.h')
| -rw-r--r-- | cpp/src/qpid/framing/Array.h | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/cpp/src/qpid/framing/Array.h b/cpp/src/qpid/framing/Array.h new file mode 100644 index 0000000000..6a13c63672 --- /dev/null +++ b/cpp/src/qpid/framing/Array.h @@ -0,0 +1,75 @@ +/* + * + * 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 <iostream> +#include <vector> +#include <boost/shared_ptr.hpp> +#include <map> +#include "amqp_types.h" +#include "FieldValue.h" + +#ifndef _Array_ +#define _Array_ + +namespace qpid { +namespace framing { + +class Buffer; + +class Array +{ + public: + typedef boost::shared_ptr<FieldValue> ValuePtr; + typedef std::vector<ValuePtr> ValueVector; + + uint32_t size() const; + void encode(Buffer& buffer) const; + void decode(Buffer& buffer); + + int count() const; + bool operator==(const Array& other) const; + + Array(); + //only long string arrays can currently be created (any type can be decoded) + Array(const std::vector<std::string>& in); + + template <class T> + void collect(std::vector<T>& out) + { + for (ValueVector::const_iterator i = values.begin(); i != values.end(); ++i) { + out.push_back((*i)->get<T>()); + } + } + + private: + uint8_t typeOctet; + ValueVector values; + + ValueVector::const_iterator begin() const { return values.begin(); } + ValueVector::const_iterator end() const { return values.end(); } + + friend std::ostream& operator<<(std::ostream& out, const Array& body); +}; + +} +} + + +#endif |
