Apache Qpid C++ API
Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation

qpid/framing/FieldTable.h

Go to the documentation of this file.
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 
00027 #ifndef _FieldTable_
00028 #define _FieldTable_
00029 
00030 namespace qpid {
00035 namespace framing {
00036 
00037 class Array;
00038 class FieldValue;
00039 class Buffer;
00040 
00047 class FieldTable
00048 {
00049   public:
00050     typedef boost::shared_ptr<FieldValue> ValuePtr;
00051     typedef std::map<std::string, ValuePtr> ValueMap;
00052     typedef ValueMap::iterator iterator;
00053 
00054     FieldTable() {};
00055     FieldTable(const FieldTable& ft);
00056     ~FieldTable();
00057     FieldTable& operator=(const FieldTable& ft);
00058     uint32_t encodedSize() const;
00059     void encode(Buffer& buffer) const;
00060     void decode(Buffer& buffer);
00061 
00062     int count() const;
00063     void set(const std::string& name, const ValuePtr& value);
00064     ValuePtr get(const std::string& name) const;
00065     bool isSet(const std::string& name) const { return get(name).get() != 0; }
00066 
00067     void setString(const std::string& name, const std::string& value);
00068     void setInt(const std::string& name, const int value);
00069     void setInt64(const std::string& name, const int64_t value);
00070     void setTimestamp(const std::string& name, const uint64_t value);
00071     void setUInt64(const std::string& name, const uint64_t value);
00072     void setTable(const std::string& name, const FieldTable& value);
00073     void setArray(const std::string& name, const Array& value);
00074     void setFloat(const std::string& name, const float value);
00075     void setDouble(const std::string& name, const double value);
00076     //void setDecimal(string& name, xxx& value);
00077 
00078     int getAsInt(const std::string& name) const;
00079     uint64_t getAsUInt64(const std::string& name) const;
00080     int64_t getAsInt64(const std::string& name) const;
00081     std::string getAsString(const std::string& name) const;
00082 
00083     bool getTable(const std::string& name, FieldTable& value) const;
00084     bool getArray(const std::string& name, Array& value) const;
00085     bool getFloat(const std::string& name, float& value) const;
00086     bool getDouble(const std::string& name, double& value) const;
00087     //bool getTimestamp(const std::string& name, uint64_t& value) const;
00088     //bool getDecimal(string& name, xxx& value);
00089     void erase(const std::string& name);
00090     
00091 
00092     bool operator==(const FieldTable& other) const;
00093 
00094     // Map-like interface.
00095     // TODO: may need to duplicate into versions that return mutable iterator
00096     ValueMap::const_iterator begin() const { return values.begin(); }
00097     ValueMap::const_iterator end() const { return values.end(); }
00098     ValueMap::const_iterator find(const std::string& s) const { return values.find(s); }
00099 
00100     std::pair <ValueMap::iterator, bool> insert(const ValueMap::value_type&);
00101     void clear() { values.clear(); }
00102 
00103     // ### Hack Alert
00104 
00105     ValueMap::iterator getValues() { return values.begin(); }
00106     
00107   private:
00108     ValueMap values;
00109 
00110     friend std::ostream& operator<<(std::ostream& out, const FieldTable& body);
00111 };
00112 
00113 //class FieldNotFoundException{};
00114 //class UnknownFieldName : public FieldNotFoundException{};
00115 //class IncorrectFieldType : public FieldNotFoundException{};
00116 }
00117 }
00118 
00119 
00120 #endif

Qpid C++ API Reference
Generated on Tue Dec 8 15:39:36 2009 for Qpid C++ Client API by doxygen 1.4.7