/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/framing/Array.h

00001 /*
00002  *
00003  * Licensed to the Apache Software Foundation (ASF) under one
00004  * or more contributor license agreements.  See the NOTICE file
00005  * distributed with this work for additional information
00006  * regarding copyright ownership.  The ASF licenses this file
00007  * to you under the Apache License, Version 2.0 (the
00008  * "License"); you may not use this file except in compliance
00009  * with the License.  You may obtain a copy of the License at
00010  * 
00011  *   http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing,
00014  * software distributed under the License is distributed on an
00015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00016  * KIND, either express or implied.  See the License for the
00017  * specific language governing permissions and limitations
00018  * under the License.
00019  *
00020  */
00021 #include <iostream>
00022 #include <vector>
00023 #include <boost/shared_ptr.hpp>
00024 #include <map>
00025 #include "amqp_types.h"
00026 #include "FieldValue.h"
00027 
00028 #ifndef _Array_
00029 #define _Array_
00030 
00031 namespace qpid {
00032 namespace framing {
00033 
00034 class Buffer;
00035 
00036 class Array
00037 {
00038   public:
00039     typedef boost::shared_ptr<FieldValue> ValuePtr;
00040     typedef std::vector<ValuePtr> ValueVector;
00041 
00042     uint32_t size() const;
00043     void encode(Buffer& buffer) const;
00044     void decode(Buffer& buffer);
00045 
00046     int count() const;
00047     bool operator==(const Array& other) const;
00048 
00049     Array();
00050     Array(uint8_t type);
00051     //creates a longstr array
00052     Array(const std::vector<std::string>& in);
00053 
00054     void add(ValuePtr value);
00055 
00056     template <class T>
00057     void collect(std::vector<T>& out)
00058     {
00059         for (ValueVector::const_iterator i = values.begin(); i != values.end(); ++i) {
00060             out.push_back((*i)->get<T>());
00061         }
00062     }
00063     
00064   private:
00065     uint8_t typeOctet;
00066     ValueVector values;
00067 
00068     ValueVector::const_iterator begin() const { return values.begin(); }
00069     ValueVector::const_iterator end() const { return values.end(); }
00070 
00071     friend std::ostream& operator<<(std::ostream& out, const Array& body);
00072 };
00073 
00074 }
00075 }
00076 
00077 
00078 #endif

Generated on Thu Apr 10 11:08:17 2008 for Qpid by  doxygen 1.4.7