The Data object holds a pointer and size information to an allocated memory data location. More...

#include "murl_data.h"

Inheritance diagram for Murl::Data:

Public Member Functions

 Data ()
 The default constructor.
 
 Data (UInt64 byteSize)
 Constructor allocating memory. More...
 
 Data (const void *data, UInt64 byteSize)
 Constructor allocating memory and copying data. More...
 
virtual ~Data ()
 The destructor. More...
 
virtual void ReleaseData ()
 Release the data. More...
 
template<class DataType >
DataType * DetachData (UInt64 &byteSize)
 Return the data memory and give up ownership. More...
 
UInt8DetachData (UInt64 &byteSize)
 Return the data memory and give up ownership. More...
 
virtual void AssignData (const void *data, UInt64 byteSize)
 Assign data by allocating memory and copying the data. More...
 
void ObtainData (void *data, UInt64 byteSize)
 Obtain a memory data location. More...
 
void ObtainData (Data &data)
 Obtain the memory from a data object. More...
 
void ResizeData (UInt64 newByteSize)
 Resize the memory. More...
 
virtual void AppendData (const void *data, UInt64 byteSize)
 Append data to the current memory. More...
 
 Data (const ConstData &data)
 The copy constructor taking a ConstData object. More...
 
 Data (const MutableData &data)
 The copy constructor taking a MutableData object. More...
 
 Data (const Data &data)
 The copy constructor. More...
 
template<class DataType >
 Data (const Array< DataType > &array)
 The copy constructor taking an Array object. More...
 
 Data (const String &string)
 The copy constructor taking a String object. More...
 
Dataoperator= (const ConstData &data)
 Assignment operator taking a ConstData object. More...
 
Dataoperator= (const MutableData &data)
 Assignment operator taking a MutableData object. More...
 
Dataoperator= (const Data &data)
 Assignment operator. More...
 
Dataoperator= (const String &string)
 Assignment operator taking a String object. More...
 
template<class DataType >
Dataoperator= (const Array< DataType > &array)
 Assignment operator taking an Array object. More...
 
Dataoperator+= (const ConstData &data)
 In-place addition operator taking a ConstData object. More...
 
Dataoperator+= (const MutableData &data)
 In-place addition operator taking a MutableData object. More...
 
Dataoperator+= (const Data &data)
 In-place addition operator. More...
 
Dataoperator+= (const String &string)
 In-place addition operator taking a String object. More...
 
template<class DataType >
Dataoperator+= (const Array< DataType > &array)
 In-place addition operator taking an Array object. More...
 
- Public Member Functions inherited from Murl::MutableData
 MutableData ()
 The default constructor.
 
 MutableData (void *data, UInt64 byteSize)
 The constructor taking data and byte size. More...
 
virtual ~MutableData ()
 The destructor.
 
template<class DataType >
DataType * GetMutableData () const
 Get the pointer to the mutable memory data location. More...
 
UInt8GetMutableData () const
 Get the pointer to the mutable memory data location. More...
 
template<class DataType >
DataType * GetMutableData (UInt64 byteOffset) const
 Get the pointer to the mutable memory data location including a byte offset. More...
 
UInt8GetMutableData (UInt64 byteOffset) const
 Get the pointer to the mutable memory data location including a byte offset. More...
 
UInt64 CopyDataTo (MutableData &destination, UInt64 byteOffset) const
 Copy the memory data to a destination data object. More...
 
UInt64 CopyFrom (const void *source, UInt64 byteSize, UInt64 byteOffset) const
 Copy the memory data from a source memory location. More...
 
UInt64 CopyDataFrom (const ConstData &source, UInt64 byteOffset) const
 Copy the memory data from a source data object. More...
 
- Public Member Functions inherited from Murl::ConstData
 ConstData ()
 The default constructor.
 
 ConstData (const void *data, UInt64 byteSize)
 The constructor taking data and byte size. More...
 
virtual ~ConstData ()
 The destructor.
 
Bool IsEmpty () const
 Check if the data object is empty. More...
 
UInt32 GetByteSize32 () const
 Get the 32 bit byte size of the memory data location. More...
 
UInt64 GetByteSize () const
 Get the byte size of the memory data location. More...
 
template<class DataType >
const DataType * GetData () const
 Get the pointer to the memory data location. More...
 
const UInt8GetData () const
 Get the pointer to the memory data location. More...
 
template<class DataType >
const DataType * GetData (UInt64 byteOffset) const
 Get the pointer to the memory data location including a byte offset. More...
 
const UInt8GetData (UInt64 byteOffset) const
 Get the pointer to the memory data location including a byte offset. More...
 
UInt64 CopyTo (void *destination, UInt64 byteSize, UInt64 byteOffset) const
 Copy the memory data to a destination. More...
 
String GetString () const
 Get a string from the memory data. More...
 
String GetString (UInt64 length) const
 Get a string from the memory data with length. More...
 
UInt64 GetHashValue () const
 Calculate the data hash value. More...
 
bool operator== (const ConstData &rhs) const
 Equal to comparison operator. More...
 
bool operator!= (const ConstData &rhs) const
 Not equal to comparison operator. More...
 
bool operator== (const String &rhs) const
 Equal to comparison operator with string. More...
 
bool operator!= (const String &rhs) const
 Not equal to comparison operator with string. More...
 

Detailed Description

The Data object holds a pointer and size information to an allocated memory data location.

see also ConstData, BufferedData

Usage examples:

#include "murl_data.h"
// convert to / from String
String s("abc");
Data data(s);
String s = data.GetString();
// convert to / from Hex String
Data key = Util::DecodeHex("0123456789ABCDEF");
String hexString = Util::EncodeHex(key.GetString());
// convert to / from UInt8Array
UInt8Array byteArray;
for (UInt32 i = 0; i < 100; i++)
{
byteArray.Add(i);
}
Data data;
data.ResizeData(byteArray.GetByteSize());
data.CopyFrom(byteArray.Begin(), byteArray.GetCount(), 0);
byteArray.Clear();
byteArray.SetCount(data.GetByteSize());
data.CopyTo(byteArray.Begin(), byteArray.GetCount(), 0);

Constructor & Destructor Documentation

◆ Data() [1/7]

Murl::Data::Data ( UInt64  byteSize)
inline

Constructor allocating memory.

The allocated memory is filled with zeros.

Parameters
byteSizeByte size of the memory to allocate.

◆ Data() [2/7]

Murl::Data::Data ( const void *  data,
UInt64  byteSize 
)
inline

Constructor allocating memory and copying data.

Parameters
dataPointer to the memory data location to copy.
byteSizeByte size of the memory to allocate and copy.

◆ ~Data()

virtual Murl::Data::~Data ( )
inlinevirtual

The destructor.

Free (delete) the memory.

References Murl::Util::ReleaseArray().

◆ Data() [3/7]

Murl::Data::Data ( const ConstData data)
inline

The copy constructor taking a ConstData object.

Parameters
dataThe data object to copy.

References Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ Data() [4/7]

Murl::Data::Data ( const MutableData data)
inline

The copy constructor taking a MutableData object.

Parameters
dataThe data object to copy.

References Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ Data() [5/7]

Murl::Data::Data ( const Data data)
inline

The copy constructor.

Parameters
dataThe data object to copy.

References Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ Data() [6/7]

template<class DataType >
Murl::Data::Data ( const Array< DataType > &  array)
inline

The copy constructor taking an Array object.

Parameters
arrayThe array object to copy.

References Murl::Array< DataType >::GetByteSize(), and Murl::Array< DataType >::GetCount().

◆ Data() [7/7]

Murl::Data::Data ( const String string)
inline

The copy constructor taking a String object.

Parameters
stringThe string object to copy.

Member Function Documentation

◆ ReleaseData()

virtual void Murl::Data::ReleaseData ( )
inlinevirtual

Release the data.

Free (delete) the memory.

Reimplemented from Murl::ConstData.

Reimplemented in Murl::BufferedData.

References Murl::Util::ReleaseArray().

Referenced by Murl::BufferedData::ReleaseData().

◆ DetachData() [1/2]

template<class DataType >
DataType* Murl::Data::DetachData ( UInt64 byteSize)
inline

Return the data memory and give up ownership.

After detaching the object's data and byte size is null. (!) The client is responsible for deletion of the returned memory data.

Template Parameters
DataTypeThe type of the returned pointer.
Parameters
byteSizeThe byte size of the memory data return value.
Returns
The pointer to the heap allocated memory data.

◆ DetachData() [2/2]

UInt8* Murl::Data::DetachData ( UInt64 byteSize)
inline

Return the data memory and give up ownership.

After detaching the object's data and byte size is null. (!) The client is responsible for deletion of the returned memory data.

Parameters
byteSizeThe byte size of the memory data return value.
Returns
The pointer to the heap allocated memory data.

◆ AssignData()

virtual void Murl::Data::AssignData ( const void *  data,
UInt64  byteSize 
)
inlinevirtual

Assign data by allocating memory and copying the data.

Parameters
dataPointer to the memory data location to copy.
byteSizeByte size of the memory to allocate and copy.

Reimplemented from Murl::ConstData.

Reimplemented in Murl::BufferedData.

References Murl::Util::MemCopy(), and Murl::Util::ReleaseArray().

◆ ObtainData() [1/2]

void Murl::Data::ObtainData ( void *  data,
UInt64  byteSize 
)
inline

Obtain a memory data location.

(!) Obtaining memory requires an allocated memory location, the data object takes the ownership of the memory and free (delete) the memory if necessary.

Parameters
dataPointer to the memory data location.
byteSizeByte size of the memory data location.

References Murl::Util::ReleaseArray().

◆ ObtainData() [2/2]

void Murl::Data::ObtainData ( Data data)
inline

Obtain the memory from a data object.

The source data object is empty after obtaining.

Parameters
dataThe data object to obtain.

◆ ResizeData()

void Murl::Data::ResizeData ( UInt64  newByteSize)
inline

Resize the memory.

The content of the current memory is copied into the resized memory. The current memory is truncated if the new size is smaller, the remaining new memory is filled with zeros if the new size is larger.

Parameters
newByteSizeThe new byte size of the memory.

References Murl::Util::ReleaseArray().

◆ AppendData()

virtual void Murl::Data::AppendData ( const void *  data,
UInt64  byteSize 
)
inlinevirtual

Append data to the current memory.

Parameters
dataPointer to the memory data location to append.
byteSizeByte size of the memory to append.

Reimplemented in Murl::BufferedData.

◆ operator=() [1/5]

Data& Murl::Data::operator= ( const ConstData data)
inline

Assignment operator taking a ConstData object.

Parameters
dataThe data object to copy.
Returns
The object itself.

References Murl::ConstData::AssignData(), Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ operator=() [2/5]

Data& Murl::Data::operator= ( const MutableData data)
inline

Assignment operator taking a MutableData object.

Parameters
dataThe data object to copy.
Returns
The object itself.

References Murl::ConstData::AssignData(), Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ operator=() [3/5]

Data& Murl::Data::operator= ( const Data data)
inline

Assignment operator.

Parameters
dataThe data object to copy.
Returns
The object itself.

References Murl::ConstData::AssignData(), Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ operator=() [4/5]

Data& Murl::Data::operator= ( const String string)
inline

Assignment operator taking a String object.

Parameters
stringThe string object to copy.
Returns
The object itself.

References Murl::ConstData::AssignData().

◆ operator=() [5/5]

template<class DataType >
Data& Murl::Data::operator= ( const Array< DataType > &  array)
inline

Assignment operator taking an Array object.

Parameters
arrayThe array object to copy.
Returns
The object itself.

References Murl::ConstData::AssignData(), and Murl::Array< DataType >::GetByteSize().

◆ operator+=() [1/5]

Data& Murl::Data::operator+= ( const ConstData data)
inline

In-place addition operator taking a ConstData object.

Parameters
dataThe data object to append.
Returns
The object itself.

References Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ operator+=() [2/5]

Data& Murl::Data::operator+= ( const MutableData data)
inline

In-place addition operator taking a MutableData object.

Parameters
dataThe data object to append.
Returns
The object itself.

References Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ operator+=() [3/5]

Data& Murl::Data::operator+= ( const Data data)
inline

In-place addition operator.

Parameters
dataThe data object to append.
Returns
The object itself.

References Murl::ConstData::GetByteSize(), and Murl::ConstData::GetData().

◆ operator+=() [4/5]

Data& Murl::Data::operator+= ( const String string)
inline

In-place addition operator taking a String object.

Parameters
stringThe string object to append.
Returns
The object itself.

◆ operator+=() [5/5]

template<class DataType >
Data& Murl::Data::operator+= ( const Array< DataType > &  array)
inline

In-place addition operator taking an Array object.

Parameters
arrayThe array object to append.
Returns
The object itself.

References Murl::Array< DataType >::GetByteSize().


The documentation for this class was generated from the following file:
  • murl_data.h


Copyright © 2011-2018 Spraylight GmbH.