/home/aconway/svn/qpid/cpp/src/qpid/framing/FieldTable.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 
00027 #ifndef _FieldTable_
00028 #define _FieldTable_
00029 
00030 namespace qpid {
00035 namespace framing {
00036 
00037 class Value;
00038 class Buffer;
00039 
00046 class FieldTable
00047 {
00048   public:
00049     typedef boost::shared_ptr<Value> ValuePtr;
00050     typedef std::map<std::string, ValuePtr> ValueMap;
00051 
00052     ~FieldTable();
00053     uint32_t size() const;
00054     int count() const;
00055     void setString(const std::string& name, const std::string& value);
00056     void setInt(const std::string& name, int value);
00057     void setTimestamp(const std::string& name, uint64_t value);
00058     void setTable(const std::string& name, const FieldTable& value);
00059     //void setDecimal(string& name, xxx& value);
00060     std::string getString(const std::string& name) const;
00061     int getInt(const std::string& name) const;
00062     uint64_t getTimestamp(const std::string& name) const;
00063     void getTable(const std::string& name, FieldTable& value) const;
00064     //void getDecimal(string& name, xxx& value);
00065     void erase(const std::string& name);
00066     
00067     void encode(Buffer& buffer) const;
00068     void decode(Buffer& buffer);
00069 
00070     bool operator==(const FieldTable& other) const;
00071 
00072     // TODO aconway 2006-09-26: Yeuch! Rework FieldTable to  have
00073     // a map-like interface.
00074     const ValueMap& getMap() const { return values; }
00075     ValueMap& getMap() { return values; }
00076     
00077   private:
00078   friend std::ostream& operator<<(std::ostream& out, const FieldTable& body);
00079     ValueMap values;
00080     template<class T> T getValue(const std::string& name) const;
00081 };
00082 
00083 class FieldNotFoundException{};
00084 class UnknownFieldName : public FieldNotFoundException{};
00085 class IncorrectFieldType : public FieldNotFoundException{};
00086 }
00087 }
00088 
00089 
00090 #endif

Generated on Tue Apr 17 14:22:03 2007 for Qpid by  doxygen 1.4.7