/home/aconway/svn/qpid/cpp/src/qpid/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 uint32_t size;
00035     const bool owner;//indicates whether the data is owned by this instance
00036     char* data;
00037     uint32_t position;
00038     uint32_t limit;
00039     uint32_t r_position;
00040     uint32_t r_limit;
00041 
00042 public:
00043 
00044     Buffer(uint32_t size);
00045     Buffer(char* data, uint32_t size);
00046     ~Buffer();
00047 
00048     void flip();
00049     void clear();
00050     void compact();
00051     void record();
00052     void restore();
00053     uint32_t available();
00054     char* start();
00055     void move(uint32_t bytes);
00056     
00057     void putOctet(uint8_t i);
00058     void putShort(uint16_t i);
00059     void putLong(uint32_t i);
00060     void putLongLong(uint64_t i);
00061 
00062     uint8_t getOctet();
00063     uint16_t getShort(); 
00064     uint32_t getLong();
00065     uint64_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, uint32_t size);
00080 
00081 };
00082 
00083 }} // namespace qpid::framing
00084 
00085 
00086 #endif

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