The Data object holds a pointer and size information to an allocated memory data location. More...
#include "murl_data.h"
Public Member Functions | |
Data () | |
The default constructor. | |
Data (const UInt64 byteSize) | |
Constructor allocating memory. More... | |
Data (const void *data, UInt64 byteSize) | |
Constructor allocating memory and copying data. More... | |
~Data () override | |
The destructor. More... | |
void | ReleaseData () override |
Release the data. More... | |
template<class DataType > | |
DataType * | DetachData (UInt64 &byteSize) |
Return the data memory and give up ownership. More... | |
UInt8 * | DetachData (UInt64 &byteSize) |
Return the data memory and give up ownership. More... | |
void | AssignData (const void *data, UInt64 byteSize) override |
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... | |
Data & | operator= (const ConstData &data) |
Assignment operator taking a ConstData object. More... | |
Data & | operator= (const MutableData &data) |
Assignment operator taking a MutableData object. More... | |
Data & | operator= (const Data &data) |
Assignment operator. More... | |
Data & | operator= (const String &string) |
Assignment operator taking a String object. More... | |
template<class DataType > | |
Data & | operator= (const Array< DataType > &array) |
Assignment operator taking an Array object. More... | |
Data & | operator+= (const ConstData &data) |
In-place addition operator taking a ConstData object. More... | |
Data & | operator+= (const MutableData &data) |
In-place addition operator taking a MutableData object. More... | |
Data & | operator+= (const Data &data) |
In-place addition operator. More... | |
Data & | operator+= (const String &string) |
In-place addition operator taking a String object. More... | |
template<class DataType > | |
Data & | operator+= (const Array< DataType > &array) |
In-place addition operator taking an Array object. More... | |
void | CollectObjectStatistics (IObjectStatistics *stat) const override |
Implementation of IStatisticsObject::CollectObjectStatistics(). 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... | |
~MutableData () override | |
The destructor. | |
template<class DataType > | |
DataType * | GetMutableData () const |
Get the pointer to the mutable memory data location. More... | |
UInt8 * | GetMutableData () 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... | |
UInt8 * | GetMutableData (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, const UInt64 byteSize) | |
The constructor taking data and byte size. More... | |
~ConstData () override=default | |
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 UInt8 * | GetData () 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 UInt8 * | GetData (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... | |
void | CollectObjectStatistics (IObjectStatistics *stat) const override |
Implementation of IStatisticsObject::CollectObjectStatistics(). More... | |
Detailed Description
The Data object holds a pointer and size information to an allocated memory data location.
see also ConstData, BufferedData
Usage examples:
Constructor & Destructor Documentation
◆ Data() [1/7]
|
inline |
Constructor allocating memory.
The allocated memory is filled with zeros.
- Parameters
-
byteSize Byte size of the memory to allocate.
◆ Data() [2/7]
|
inline |
Constructor allocating memory and copying data.
- Parameters
-
data Pointer to the memory data location to copy. byteSize Byte size of the memory to allocate and copy.
◆ ~Data()
|
inlineoverride |
◆ Data() [3/7]
|
inline |
The copy constructor taking a ConstData object.
- Parameters
-
data The data object to copy.
◆ Data() [4/7]
|
inline |
The copy constructor taking a MutableData object.
- Parameters
-
data The data object to copy.
◆ Data() [5/7]
|
inline |
The copy constructor.
- Parameters
-
data The data object to copy.
◆ Data() [6/7]
|
inline |
The copy constructor taking an Array object.
- Parameters
-
array The array object to copy.
References Murl::Array< DataType >::GetByteSize(), and Murl::Array< DataType >::GetCount().
◆ Data() [7/7]
|
inline |
The copy constructor taking a String object.
- Parameters
-
string The string object to copy.
Member Function Documentation
◆ ReleaseData()
|
inlineoverridevirtual |
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]
|
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
-
DataType The type of the returned pointer.
- Parameters
-
byteSize The byte size of the memory data return value.
- Returns
- The pointer to the heap allocated memory data.
◆ DetachData() [2/2]
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
-
byteSize The byte size of the memory data return value.
- Returns
- The pointer to the heap allocated memory data.
◆ AssignData()
|
inlineoverridevirtual |
Assign data by allocating memory and copying the data.
- Parameters
-
data Pointer to the memory data location to copy. byteSize Byte size of the memory to allocate and copy.
Reimplemented from Murl::ConstData.
Reimplemented in Murl::BufferedData.
References Murl::Util::MemCopy(), and Murl::Util::ReleaseArray().
Referenced by operator=().
◆ ObtainData() [1/2]
|
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
-
data Pointer to the memory data location. byteSize Byte size of the memory data location.
References Murl::Util::ReleaseArray().
Referenced by ObtainData().
◆ ObtainData() [2/2]
|
inline |
Obtain the memory from a data object.
The source data object is empty after obtaining.
- Parameters
-
data The data object to obtain.
References ObtainData().
◆ ResizeData()
|
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
-
newByteSize The new byte size of the memory.
References Murl::Util::ReleaseArray().
Referenced by Murl::BufferedData::AppendData().
◆ AppendData()
|
inlinevirtual |
Append data to the current memory.
- Parameters
-
data Pointer to the memory data location to append. byteSize Byte size of the memory to append.
Reimplemented in Murl::BufferedData.
Referenced by operator+=().
◆ operator=() [1/5]
Assignment operator taking a ConstData object.
- Parameters
-
data The data object to copy.
- Returns
- The object itself.
References AssignData().
◆ operator=() [2/5]
|
inline |
Assignment operator taking a MutableData object.
- Parameters
-
data The data object to copy.
- Returns
- The object itself.
References AssignData().
◆ operator=() [3/5]
Assignment operator.
- Parameters
-
data The data object to copy.
- Returns
- The object itself.
References AssignData().
◆ operator=() [4/5]
Assignment operator taking a String object.
- Parameters
-
string The string object to copy.
- Returns
- The object itself.
References AssignData().
◆ operator=() [5/5]
Assignment operator taking an Array object.
- Parameters
-
array The array object to copy.
- Returns
- The object itself.
References AssignData(), and Murl::Array< DataType >::GetByteSize().
◆ operator+=() [1/5]
In-place addition operator taking a ConstData object.
- Parameters
-
data The data object to append.
- Returns
- The object itself.
References AppendData().
◆ operator+=() [2/5]
|
inline |
In-place addition operator taking a MutableData object.
- Parameters
-
data The data object to append.
- Returns
- The object itself.
References AppendData().
◆ operator+=() [3/5]
In-place addition operator.
- Parameters
-
data The data object to append.
- Returns
- The object itself.
References AppendData().
◆ operator+=() [4/5]
In-place addition operator taking a String object.
- Parameters
-
string The string object to append.
- Returns
- The object itself.
References AppendData().
◆ operator+=() [5/5]
In-place addition operator taking an Array object.
- Parameters
-
array The array object to append.
- Returns
- The object itself.
References AppendData(), and Murl::Array< DataType >::GetByteSize().
◆ CollectObjectStatistics()
|
inlineoverride |
Implementation of IStatisticsObject::CollectObjectStatistics().
- Parameters
-
stat The object statistics container.
References Murl::IEnums::MEMORY_TYPE_HEAP.
The documentation for this class was generated from the following file:
- murl_data.h