1241b0480SAxel Dörfler /* 2*d254c83cSBruno G. Albuquerque * Copyright 2009, Haiku, Inc. All Rights Reserved. 3241b0480SAxel Dörfler * Distributed under the terms of the MIT License. 4*d254c83cSBruno G. Albuquerque * 5*d254c83cSBruno G. Albuquerque * Authors: 6*d254c83cSBruno G. Albuquerque * Bruno Albuquerque, bga@bug-br.org.br 72ae4404aSPhilippe Houdoin */ 8*d254c83cSBruno G. Albuquerque 94c44e39aSPhilippe Houdoin #ifndef _NETBUFFER_H 104c44e39aSPhilippe Houdoin #define _NETBUFFER_H 114c44e39aSPhilippe Houdoin 124c44e39aSPhilippe Houdoin #include <Archivable.h> 13*d254c83cSBruno G. Albuquerque #include <SupportDefs.h> 144c44e39aSPhilippe Houdoin 15*d254c83cSBruno G. Albuquerque 16*d254c83cSBruno G. Albuquerque class BMessage; 17*d254c83cSBruno G. Albuquerque class DynamicBuffer; 184c44e39aSPhilippe Houdoin 19241b0480SAxel Dörfler 20241b0480SAxel Dörfler class BNetBuffer : public BArchivable { 214c44e39aSPhilippe Houdoin public: 224c44e39aSPhilippe Houdoin BNetBuffer(size_t size = 0); 23*d254c83cSBruno G. Albuquerque 2440e492bcSPhilippe Houdoin virtual ~BNetBuffer(); 254c44e39aSPhilippe Houdoin 26*d254c83cSBruno G. Albuquerque BNetBuffer(const BNetBuffer& buffer); 2740e492bcSPhilippe Houdoin BNetBuffer(BMessage* archive); 28*d254c83cSBruno G. Albuquerque 29*d254c83cSBruno G. Albuquerque BNetBuffer& operator=(const BNetBuffer& buffer); 30*d254c83cSBruno G. Albuquerque 314c44e39aSPhilippe Houdoin virtual status_t Archive(BMessage* into, bool deep = true) const; 324c44e39aSPhilippe Houdoin static BArchivable* Instantiate(BMessage* archive); 334c44e39aSPhilippe Houdoin 34*d254c83cSBruno G. Albuquerque status_t InitCheck(); 354c44e39aSPhilippe Houdoin 36*d254c83cSBruno G. Albuquerque status_t AppendInt8(int8 data); 37*d254c83cSBruno G. Albuquerque status_t AppendUint8(uint8 data); 38*d254c83cSBruno G. Albuquerque status_t AppendInt16(int16 data); 39*d254c83cSBruno G. Albuquerque status_t AppendUint16(uint16 data); 40*d254c83cSBruno G. Albuquerque status_t AppendInt32(int32 data); 41*d254c83cSBruno G. Albuquerque status_t AppendUint32(uint32 data); 42*d254c83cSBruno G. Albuquerque status_t AppendFloat(float data); 43*d254c83cSBruno G. Albuquerque status_t AppendDouble(double data); 44*d254c83cSBruno G. Albuquerque status_t AppendString(const char* data); 45*d254c83cSBruno G. Albuquerque status_t AppendData(const void* data, size_t size); 46*d254c83cSBruno G. Albuquerque status_t AppendMessage(const BMessage& data); 47*d254c83cSBruno G. Albuquerque status_t AppendInt64(int64 data); 48*d254c83cSBruno G. Albuquerque status_t AppendUint64(uint64 data); 494c44e39aSPhilippe Houdoin 50*d254c83cSBruno G. Albuquerque status_t RemoveInt8(int8& data); 51*d254c83cSBruno G. Albuquerque status_t RemoveUint8(uint8& data); 52*d254c83cSBruno G. Albuquerque status_t RemoveInt16(int16& data); 53*d254c83cSBruno G. Albuquerque status_t RemoveUint16(uint16& data); 54*d254c83cSBruno G. Albuquerque status_t RemoveInt32(int32& data); 55*d254c83cSBruno G. Albuquerque status_t RemoveUint32(uint32& data); 56*d254c83cSBruno G. Albuquerque status_t RemoveFloat(float& data); 57*d254c83cSBruno G. Albuquerque status_t RemoveDouble(double& data); 58*d254c83cSBruno G. Albuquerque status_t RemoveString(char* data, size_t size); 59*d254c83cSBruno G. Albuquerque status_t RemoveData(void* data, size_t size); 60*d254c83cSBruno G. Albuquerque status_t RemoveMessage(BMessage& data); 61*d254c83cSBruno G. Albuquerque status_t RemoveInt64(int64& data); 62*d254c83cSBruno G. Albuquerque status_t RemoveUint64(uint64& data); 634c44e39aSPhilippe Houdoin 6440e492bcSPhilippe Houdoin unsigned char* Data() const; 6540e492bcSPhilippe Houdoin size_t Size() const; 6640e492bcSPhilippe Houdoin size_t BytesRemaining() const; 674c44e39aSPhilippe Houdoin 68*d254c83cSBruno G. Albuquerque inline DynamicBuffer* GetImpl() const; 69*d254c83cSBruno G. Albuquerque 70*d254c83cSBruno G. Albuquerque protected: 71*d254c83cSBruno G. Albuquerque status_t fInit; 72*d254c83cSBruno G. Albuquerque 73082059d4SPhilippe Houdoin private: 74082059d4SPhilippe Houdoin virtual void _ReservedBNetBufferFBCCruft1(); 75082059d4SPhilippe Houdoin virtual void _ReservedBNetBufferFBCCruft2(); 76082059d4SPhilippe Houdoin virtual void _ReservedBNetBufferFBCCruft3(); 77082059d4SPhilippe Houdoin virtual void _ReservedBNetBufferFBCCruft4(); 78082059d4SPhilippe Houdoin virtual void _ReservedBNetBufferFBCCruft5(); 79082059d4SPhilippe Houdoin virtual void _ReservedBNetBufferFBCCruft6(); 80082059d4SPhilippe Houdoin 81*d254c83cSBruno G. Albuquerque DynamicBuffer* fImpl; 82*d254c83cSBruno G. Albuquerque int32 __ReservedBNetBufferFBCCruftData[8]; 83241b0480SAxel Dörfler 844c44e39aSPhilippe Houdoin }; 854c44e39aSPhilippe Houdoin 86*d254c83cSBruno G. Albuquerque 87*d254c83cSBruno G. Albuquerque inline DynamicBuffer* GetImpl()88*d254c83cSBruno G. AlbuquerqueBNetBuffer::GetImpl() const 89*d254c83cSBruno G. Albuquerque { 90*d254c83cSBruno G. Albuquerque return fImpl; 91*d254c83cSBruno G. Albuquerque } 92*d254c83cSBruno G. Albuquerque 93*d254c83cSBruno G. Albuquerque #endif // _NET_BUFFER_H 94