Back to index

nordugrid-arc-nox  1.1.0~rc6
PayloadRaw.h
Go to the documentation of this file.
00001 #ifndef __ARC_PAYLOADRAW_H__
00002 #define __ARC_PAYLOADRAW_H__
00003 
00004 #include <vector>
00005 
00006 #include "Message.h"
00007 
00008 namespace Arc {
00009 
00011 
00016 class PayloadRawInterface: virtual public MessagePayload {
00017  public:
00018   // Avoid defining size of int - just use biggest possible
00019   typedef signed long long int Size_t;
00020   PayloadRawInterface(void) { };
00021   virtual ~PayloadRawInterface(void) { };
00025   virtual char operator[](Size_t pos) const = 0;
00028   virtual char* Content(Size_t pos = -1) = 0;
00030   virtual Size_t Size(void) const = 0;
00032   virtual char* Insert(Size_t pos = 0,Size_t size = 0) = 0;
00036   virtual char* Insert(const char* s,Size_t pos = 0,Size_t size = -1) = 0;
00038   virtual char* Buffer(unsigned int num) = 0;
00040   virtual Size_t BufferSize(unsigned int num) const = 0;
00042   virtual Size_t BufferPos(unsigned int num) const = 0;
00047   virtual bool Truncate(Size_t size) = 0;
00048 };
00049 
00050 /* Buffer type for PayloadRaw */
00051 typedef struct {
00052     char* data;     
00053     int size;       
00054     int length;     
00055     bool allocated; 
00056 } PayloadRawBuf;
00057 
00059 
00061 class PayloadRaw: virtual public PayloadRawInterface {
00062  protected:
00063   Size_t offset_;
00064   Size_t size_;
00065   std::vector<PayloadRawBuf> buf_; 
00066  public:
00068   PayloadRaw(void):offset_(0),size_(0) { };
00070   virtual ~PayloadRaw(void);
00071   virtual char operator[](Size_t pos) const;
00072   virtual char* Content(Size_t pos = -1);
00073   virtual Size_t Size(void) const;
00074   virtual char* Insert(Size_t pos = 0,Size_t size = 0);
00075   virtual char* Insert(const char* s,Size_t pos = 0,Size_t size = -1);
00076   virtual char* Buffer(unsigned int num = 0);
00077   virtual Size_t BufferSize(unsigned int num = 0) const;
00078   virtual Size_t BufferPos(unsigned int num = 0) const;
00079   virtual bool Truncate(Size_t size);
00080 };
00081 
00083 
00084 const char* ContentFromPayload(const MessagePayload& payload);
00085 
00086 } // namespace Arc
00087 
00088 #endif /* __ARC_PAYLOADRAW_H__ */