Murl::Util Functions

Utility template functions (memory manipulation). More...

Collaboration diagram for Murl::Util Functions:

Modules

 Coding Functions
 Encoding / Decoding functions.
 
 Compression Functions
 Data compression functions.
 
 Sort Functions
 Sorting functions.
 
 String Functions
 String manipulation and test functions.
 

Functions

template<class DataType >
void Murl::Util::Release (DataType &p)
 Release an object. More...
 
template<class DataType >
void Murl::Util::ReleaseArray (DataType &p)
 Release an object array. More...
 
template<class DestType , class SrcType >
bool Murl::Util::ReleaseType (SrcType &p)
 Release an object of specified type. More...
 
template<class DataType >
void Murl::Util::MemClear (DataType &memory)
 Clear the memory of a concrete type. More...
 
template<class DataType >
void Murl::Util::MemSet (DataType memory, UInt8 value, UInt64 byteSize)
 Set memory bytes to a given value. More...
 
template<class DestType , class SrcType >
void Murl::Util::MemCopy (DestType destination, const SrcType source, UInt64 byteSize)
 Copy memory bytes. More...
 
template<class DataType >
void Murl::Util::MemCopyArray (DataType &destination, const DataType &source)
 Copy the memory of a concrete type. More...
 
template<class DestType , class SrcType >
void Murl::Util::MemMove (DestType destination, const SrcType source, UInt64 byteSize)
 Move overlapping memory bytes. More...
 
template<class DataType1 , class DataType2 >
SInt32 Murl::Util::MemCompare (const DataType1 source1, const DataType2 source2, UInt64 byteSize)
 Compare memory bytes. More...
 
template<class DataType >
void Murl::Util::Fill (DataType *dstPtr, const DataType *dstEnd, const DataType &value)
 Fill the memory of a concrete type. More...
 
template<class ArrayType , class DataType >
void Murl::Util::FillArray (ArrayType &array, const DataType &value)
 Set all C-array elements to a given value. More...
 
template<class DataType >
UInt32 Murl::Util::Find (const DataType *memory, const DataType &item, UInt32 maxElements)
 Find the first appearance of a concrete type in memory. More...
 
template<class ArrayType , class DataType >
UInt32 Murl::Util::FindArray (ArrayType &array, const DataType &item)
 Find the first appearance of an item in a C-array. More...
 
template<class DataType >
void Murl::Util::Swap (DataType &a, DataType &b)
 Swap two values. More...
 
template<class DataType >
DataType Murl::Util::RoundToNextPowerOfTwo (DataType value)
 Round a value to the next power of two. More...
 
template<class DataType >
Bool Murl::Util::IsPowerOfTwo (DataType value)
 Check if a given value equals a power of two. More...
 
template<class DataType >
DataType Murl::Util::RoundToNextFourByteBoundary (DataType value)
 Round a value to the next 4 byte boundary. More...
 
template<class DataType >
DataType Murl::Util::RoundToNextEightByteBoundary (DataType value)
 Round a value to the next 8 byte boundary. More...
 
template<class DataType >
DataType Murl::Util::RoundToNextSixteenByteBoundary (DataType value)
 Round a value to the next 16 byte boundary. More...
 
template<class DataType >
DataType Murl::Util::RoundToRaster (DataType value, DataType raster, DataType &diff)
 Round a value to the next raster and return the rounded value and the difference to the previous raster before rounding. More...
 
template<class DataType >
DataType Murl::Util::RoundToRaster (DataType value, DataType raster)
 Round a value to the next raster. More...
 
template<class DataType >
UInt32 Murl::Util::GetNumberOfSetBits (DataType value)
 Compute the number of set bits. More...
 
template<class DataType >
UInt32 Murl::Util::GetNumberOfClearedBits (DataType value)
 Compute the number of cleared bits. More...
 
template<class DataType >
UInt32 Murl::Util::GetNumberOfDigits (DataType value, DataType base=10)
 Compute the number of digits. More...
 
const DataMurl::Util::StaticEmptyData ()
 Get a constant static empty data object. More...
 
UInt64 Murl::Util::SwapBytes (UInt64 value)
 Swap all bytes of a 64 bit value. More...
 
UInt32 Murl::Util::SwapBytes (UInt32 value)
 Swap all bytes of a 32 bit value. More...
 
UInt16 Murl::Util::SwapBytes (UInt16 value)
 Swap all bytes of a 16 bit value. More...
 
Bool Murl::Util::IsDebugBuild ()
 Check if the engine was built using the debug configuration. More...
 
Bool Murl::Util::IsReleaseBuild ()
 Check if the engine was built using the release configuration. More...
 

Detailed Description

Utility template functions (memory manipulation).

Function Documentation

◆ Release()

template<class DataType >
void Murl::Util::Release ( DataType &  p)

Release an object.

Delete the object if the object pointer is not null. After destruction the object pointer is set to null.

Parameters
pThe reference to the object to delete.

Referenced by Murl::AutoPointer< Worker >::AutoPointer(), Murl::AutoPointer< Worker >::operator AutoPointer< Type2 >(), and Murl::AutoPointer< Worker >::operator=().

◆ ReleaseArray()

template<class DataType >
void Murl::Util::ReleaseArray ( DataType &  p)

Release an object array.

Array delete the object array if the object pointer is not null. After destruction the object pointer is set to null.

Parameters
pThe reference to the object array to delete.

Referenced by Murl::Data::AssignData(), Murl::Data::ObtainData(), Murl::Data::ReleaseData(), Murl::Data::ResizeData(), Murl::Hash::Swap(), and Murl::Data::~Data().

◆ ReleaseType()

template<class DestType , class SrcType >
bool Murl::Util::ReleaseType ( SrcType &  p)

Release an object of specified type.

The object is dynamic_cast'ed to the specified type and deleted if the casted pointer is not null. After destruction the object pointer is set to null.

Template Parameters
DestTypeThe type to dynamic_cast the object pointer to.
Parameters
pThe reference to the object to delete.
Returns
true if the pointer was deleted successfully.

◆ MemClear()

template<class DataType >
void Murl::Util::MemClear ( DataType &  memory)

Clear the memory of a concrete type.

Parameters
memoryA reference to the memory to clear.

References Murl::System::CLib::MemSet().

◆ MemSet()

template<class DataType >
void Murl::Util::MemSet ( DataType  memory,
UInt8  value,
UInt64  byteSize 
)

Set memory bytes to a given value.

Parameters
memoryThe memory to set.
valueThe byte value to write into the memory.
byteSizeThe byte size of the memory location.

References Murl::System::CLib::MemSet().

Referenced by Murl::Math::Matrix< Real >::Clear().

◆ MemCopy()

template<class DestType , class SrcType >
void Murl::Util::MemCopy ( DestType  destination,
const SrcType  source,
UInt64  byteSize 
)

Copy memory bytes.

Parameters
destinationThe destination memory.
sourceThe source memory.
byteSizeThe number of bytes to copy.

References Murl::System::CLib::MemCopy().

Referenced by Murl::Data::AssignData(), Murl::MutableData::CopyFrom(), and Murl::ConstData::CopyTo().

◆ MemCopyArray()

template<class DataType >
void Murl::Util::MemCopyArray ( DataType &  destination,
const DataType &  source 
)

Copy the memory of a concrete type.

The source and destination memory must be the same type.

Parameters
destinationA reference to the destination memory.
sourceA reference to the source memory.

References Murl::System::CLib::MemCopy().

◆ MemMove()

template<class DestType , class SrcType >
void Murl::Util::MemMove ( DestType  destination,
const SrcType  source,
UInt64  byteSize 
)

Move overlapping memory bytes.

Parameters
destinationThe destination memory.
sourceThe source memory.
byteSizeThe number of bytes to move.

References Murl::System::CLib::MemMove().

◆ MemCompare()

template<class DataType1 , class DataType2 >
SInt32 Murl::Util::MemCompare ( const DataType1  source1,
const DataType2  source2,
UInt64  byteSize 
)

Compare memory bytes.

Parameters
source1The 1st source memory.
source2The 2nd source memory.
byteSizeThe number of bytes to compare.
Returns
Zero if source1 is equal to source2, negativ if source1 is lesser than source2, positive if source1 is greater than source2.

References Murl::System::CLib::MemCompare().

Referenced by Murl::ConstData::operator==().

◆ Fill()

template<class DataType >
void Murl::Util::Fill ( DataType *  dstPtr,
const DataType *  dstEnd,
const DataType &  value 
)

Fill the memory of a concrete type.

Parameters
dstPtrThe destination memory start pointer.
dstEndThe destination memory end pointer.
valueThe value to fill.

Referenced by Murl::Hash::Reindex().

◆ FillArray()

template<class ArrayType , class DataType >
void Murl::Util::FillArray ( ArrayType &  array,
const DataType &  value 
)

Set all C-array elements to a given value.

Parameters
arrayA reference to the C-array to set.
valueThe value to set for each array item.

◆ Find()

template<class DataType >
UInt32 Murl::Util::Find ( const DataType *  memory,
const DataType &  item,
UInt32  maxElements 
)

Find the first appearance of a concrete type in memory.

Parameters
memoryThe source memory pointer.
itemThe item to find.
maxElementsThe maximum number of items to scan.
Returns
The zero-based index of the item or maxElements if the item was not found.

Referenced by Murl::String::Find(), and Murl::String::Replace().

◆ FindArray()

template<class ArrayType , class DataType >
UInt32 Murl::Util::FindArray ( ArrayType &  array,
const DataType &  item 
)

Find the first appearance of an item in a C-array.

Parameters
arrayA reference to the C-array.
itemThe item to find.
Returns
The zero-based index of the item or (sizeof(array) / sizeof(array[0])) if the item was not found.

◆ Swap()

template<class DataType >
void Murl::Util::Swap ( DataType &  a,
DataType &  b 
)

◆ RoundToNextPowerOfTwo()

template<class DataType >
DataType Murl::Util::RoundToNextPowerOfTwo ( DataType  value)

Round a value to the next power of two.

Parameters
valueThe value to round.
Returns
The value rounded to the next power of two.

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

◆ IsPowerOfTwo()

template<class DataType >
Bool Murl::Util::IsPowerOfTwo ( DataType  value)

Check if a given value equals a power of two.

Parameters
valueThe value to check.
Returns
true if the value is a power of two.

◆ RoundToNextFourByteBoundary()

template<class DataType >
DataType Murl::Util::RoundToNextFourByteBoundary ( DataType  value)

Round a value to the next 4 byte boundary.

Parameters
valueThe value to round.
Returns
The value rounded to the next 4 byte boundary.

◆ RoundToNextEightByteBoundary()

template<class DataType >
DataType Murl::Util::RoundToNextEightByteBoundary ( DataType  value)

Round a value to the next 8 byte boundary.

Parameters
valueThe value to round.
Returns
The value rounded to the next 8 byte boundary.

◆ RoundToNextSixteenByteBoundary()

template<class DataType >
DataType Murl::Util::RoundToNextSixteenByteBoundary ( DataType  value)

Round a value to the next 16 byte boundary.

Parameters
valueThe value to round.
Returns
The value rounded to the next 16 byte boundary.

◆ RoundToRaster() [1/2]

template<class DataType >
DataType Murl::Util::RoundToRaster ( DataType  value,
DataType  raster,
DataType &  diff 
)

Round a value to the next raster and return the rounded value and the difference to the previous raster before rounding.

Parameters
valueThe value to round.
rasterThe raster to round to.
diffThe difference return value.
Returns
The value rounded to the next raster.

Referenced by Murl::BufferedData::AppendData(), and Murl::Util::RoundToRaster().

◆ RoundToRaster() [2/2]

template<class DataType >
DataType Murl::Util::RoundToRaster ( DataType  value,
DataType  raster 
)

Round a value to the next raster.

Parameters
valueThe value to round.
rasterThe raster to round to.
Returns
The value rounded to the next raster.

References Murl::Util::RoundToRaster().

◆ GetNumberOfSetBits()

template<class DataType >
UInt32 Murl::Util::GetNumberOfSetBits ( DataType  value)

Compute the number of set bits.

Parameters
valueThe value to count the set bits.
Returns
The number of set bits.

Referenced by Murl::Util::GetNumberOfClearedBits().

◆ GetNumberOfClearedBits()

template<class DataType >
UInt32 Murl::Util::GetNumberOfClearedBits ( DataType  value)

Compute the number of cleared bits.

Parameters
valueThe value to count the cleared bits.
Returns
The number of cleared bits.

References Murl::Util::GetNumberOfSetBits().

◆ GetNumberOfDigits()

template<class DataType >
UInt32 Murl::Util::GetNumberOfDigits ( DataType  value,
DataType  base = 10 
)

Compute the number of digits.

Parameters
valueThe value to compute the number of digits.
baseThe base of the digits.
Returns
The number of digits.

References Murl::Util::StaticEmptyData(), and Murl::Util::SwapBytes().

◆ StaticEmptyData()

const Data& Murl::Util::StaticEmptyData ( )

Get a constant static empty data object.

Returns
The constant static empty data object.

Referenced by Murl::Util::GetNumberOfDigits().

◆ SwapBytes() [1/3]

UInt64 Murl::Util::SwapBytes ( UInt64  value)

Swap all bytes of a 64 bit value.

Parameters
valueThe value to swap the bytes.
Returns
The value in reverse byte ordering.

Referenced by Murl::Util::GetNumberOfDigits().

◆ SwapBytes() [2/3]

UInt32 Murl::Util::SwapBytes ( UInt32  value)

Swap all bytes of a 32 bit value.

Parameters
valueThe value to swap the bytes.
Returns
The value in reverse byte ordering.

◆ SwapBytes() [3/3]

UInt16 Murl::Util::SwapBytes ( UInt16  value)

Swap all bytes of a 16 bit value.

Parameters
valueThe value to swap the bytes.
Returns
The value in reverse byte ordering.

◆ IsDebugBuild()

Bool Murl::Util::IsDebugBuild ( )
inline

Check if the engine was built using the debug configuration.

Returns
true if the engine was built using the debug configuration.

◆ IsReleaseBuild()

Bool Murl::Util::IsReleaseBuild ( )
inline

Check if the engine was built using the release configuration.

Returns
true if the engine was built using the release configuration.


Copyright © 2011-2018 Spraylight GmbH.