/home/aconway/svn/qpid/cpp/lib/common/framing/Buffer.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 <amqp_types.h>
00022 
00023 #ifndef _Buffer_
00024 #define _Buffer_
00025 
00026 namespace qpid {
00027 namespace framing {
00028 
00029 class Content;
00030 class FieldTable;
00031 
00032 class Buffer
00033 {
00034     const u_int32_t size;
00035     const bool owner;//indicates whether the data is owned by this instance
00036     char* data;
00037     u_int32_t position;
00038     u_int32_t limit;
00039     u_int32_t r_position;
00040     u_int32_t r_limit;
00041 
00042 public:
00043 
00044     Buffer(u_int32_t size);
00045     Buffer(char* data, u_int32_t size);
00046     ~Buffer();
00047 
00048     void flip();
00049     void clear();
00050     void compact();
00051     void record();
00052     void restore();
00053     u_int32_t available();
00054     char* start();
00055     void move(u_int32_t bytes);
00056     
00057     void putOctet(u_int8_t i);
00058     void putShort(u_int16_t i);
00059     void putLong(u_int32_t i);
00060     void putLongLong(u_int64_t i);
00061 
00062     u_int8_t getOctet();
00063     u_int16_t getShort(); 
00064     u_int32_t getLong();
00065     u_int64_t getLongLong();
00066 
00067     void putShortString(const string& s);
00068     void putLongString(const string& s);
00069     void getShortString(string& s);
00070     void getLongString(string& s);
00071 
00072     void putFieldTable(const FieldTable& t);
00073     void getFieldTable(FieldTable& t);
00074 
00075     void putContent(const Content& c);
00076     void getContent(Content& c);
00077 
00078     void putRawData(const string& s);
00079     void getRawData(string& s, u_int32_t size);
00080 
00081 };
00082 
00083 }
00084 }
00085 
00086 
00087 #endif

Generated on Thu Jan 25 11:48:13 2007 for Qpid by  doxygen 1.5.1