haiku/headers/private/shared/DataBuffer.h
ejakowatz b1055b4c2d This is all the code for the backing store for BMessage (BMessageBody &
BMessageField) for the "template madness" version.  Also included is
BDataBuffer which is a little reference counting raw data container.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2955 a95241bf-73f2-0310-859d-f6bbb57e9c96
2003-03-19 07:58:17 +00:00

77 lines
1.7 KiB
C++

//------------------------------------------------------------------------------
// DataBuffer.h
//
//------------------------------------------------------------------------------
#ifndef DATABUFFER_H
#define DATABUFFER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
namespace BPrivate {
class BDataBuffer
{
public:
BDataBuffer(size_t len);
BDataBuffer(void* data, size_t len);
BDataBuffer(const BDataBuffer& rhs);
~BDataBuffer();
BDataBuffer& operator=(const BDataBuffer& rhs);
size_t BufferSize() const;
const void* Buffer();
private:
class BDataReference
{
public:
void Acquire(BDataReference*& ref);
void Release(BDataReference*& ref);
char* Data() { return data; }
size_t Size() const { return size; }
int32 Count() { return count; }
static void Create(void* data, size_t len, BDataReference*& ref);
static void Create(size_t len, BDataReference*& ref);
private:
BDataReference(void* data, size_t len);
BDataReference(size_t len);
~BDataReference();
char* data;
size_t size;
int32 count;
};
BDataBuffer(); // No default construction allowed!
BDataReference* fDataRef;
};
} // namespace BPrivate
#endif // DATABUFFER_H
/*
* $Log $
*
* $Id $
*
*/