Mark3 Realtime Kernel
Mark3::MemUtil Class Reference

String and Memory manipu32ation class. More...

#include <memutil.h>

Static Public Member Functions

static void DecimalToString (uint8_t u8Data_, char *szText_)
 DecimalToString. More...
 
static void DecimalToString (uint16_t u16Data_, char *szText_)
 
static void DecimalToString (uint32_t u32Data_, char *szText_)
 
static void DecimalToString (uint64_t u64Data_, char *szText_)
 
static uint8_t Checksum8 (const void *pvSrc_, uint16_t u16Len_)
 Checksum8. More...
 
static uint16_t Checksum16 (const void *pvSrc_, uint16_t u16Len_)
 Checksum16. More...
 
static uint16_t StringLength (const char *szStr_)
 StringLength. More...
 
static bool CompareStrings (const char *szStr1_, const char *szStr2_)
 CompareStrings. More...
 
static bool CompareStrings (const char *szStr1_, const char *szStr2_, uint16_t u16Length_)
 
static void CopyMemory (void *pvDst_, const void *pvSrc_, uint16_t u16Len_)
 CopyMemory. More...
 
static void CopyString (char *szDst_, const char *szSrc_)
 CopyString. More...
 
static int16_t StringSearch (const char *szBuffer_, const char *szPattern_)
 StringSearch. More...
 
static bool CompareMemory (const void *pvMem1_, const void *pvMem2_, uint16_t u16Len_)
 CompareMemory. More...
 
static void SetMemory (void *pvDst_, uint8_t u8Val_, uint16_t u16Len_)
 SetMemory. More...
 
static uint8_t Tokenize (const char *szBuffer_, Token_t *pastTokens_, uint8_t u8MaxTokens_)
 Tokenize Function to tokenize a string based on a space delimeter. This is a non-destructive function, which popu32ates a Token_t descriptor array. More...
 

Detailed Description

String and Memory manipu32ation class.

Utility method class implementing common memory and string manipu32ation functions, without relying on an external standard library implementation which might not be available on some toolchains, may be closed source, or may not be thread-safe.

Definition at line 46 of file memutil.h.

Member Function Documentation

◆ Checksum16()

uint16_t Mark3::MemUtil::Checksum16 ( const void *  pvSrc_,
uint16_t  u16Len_ 
)
static

Checksum16.

Compute the 16-bit addative checksum of a memory buffer.

Parameters
pvSrc_Memory buffer to compute a 16-bit checksum of.
u16Len_Length of the buffer in bytes.
Returns
16-bit checksum of the memory block.

Definition at line 131 of file memutil.cpp.

◆ Checksum8()

uint8_t Mark3::MemUtil::Checksum8 ( const void *  pvSrc_,
uint16_t  u16Len_ 
)
static

Checksum8.

Compute the 8-bit addative checksum of a memory buffer.

Parameters
pvSrc_Memory buffer to compute a 8-bit checksum of.
u16Len_Length of the buffer in bytes.
Returns
8-bit checksum of the memory block.

Definition at line 118 of file memutil.cpp.

◆ CompareMemory()

bool Mark3::MemUtil::CompareMemory ( const void *  pvMem1_,
const void *  pvMem2_,
uint16_t  u16Len_ 
)
static

CompareMemory.

Compare the contents of two memory buffers to eachother

Parameters
pvMem1_First buffer to compare
pvMem2_Second buffer to compare
u16Len_Length of buffer (in bytes) to compare
Returns
true if the buffers match, false if they do not.

Definition at line 252 of file memutil.cpp.

◆ CompareStrings() [1/2]

bool Mark3::MemUtil::CompareStrings ( const char *  szStr1_,
const char *  szStr2_ 
)
static

CompareStrings.

Compare the contents of two zero-terminated string buffers to eachother.

Parameters
szStr1_First string to compare
szStr2_Second string to compare
Returns
true if strings match, false otherwise.

Definition at line 157 of file memutil.cpp.

◆ CompareStrings() [2/2]

bool Mark3::MemUtil::CompareStrings ( const char *  szStr1_,
const char *  szStr2_,
uint16_t  u16Length_ 
)
static

Definition at line 176 of file memutil.cpp.

◆ CopyMemory()

void Mark3::MemUtil::CopyMemory ( void *  pvDst_,
const void *  pvSrc_,
uint16_t  u16Len_ 
)
static

CopyMemory.

Copy one buffer in memory into another.

Parameters
pvDst_Pointer to the destination buffer
pvSrc_Pointer to the source buffer
u16Len_Number of bytes to copy from source to destination

Definition at line 193 of file memutil.cpp.

◆ CopyString()

void Mark3::MemUtil::CopyString ( char *  szDst_,
const char *  szSrc_ 
)
static

CopyString.

Copy a string from one buffer into another.

Parameters
szDst_Pointer to the buffer to copy into
szSrc_Pointer to the buffer to copy data from

Definition at line 207 of file memutil.cpp.

◆ DecimalToString() [1/4]

void Mark3::MemUtil::DecimalToString ( uint8_t  u8Data_,
char *  szText_ 
)
static

DecimalToString.

Convert an 8-bit unsigned binary value as a decimal string.

Parameters
u8Data_Value to convert into a string
szText_Destination string buffer (4 bytes minimum)
Examples:
lab9_dynamic_threads/main.cpp.

Definition at line 30 of file memutil.cpp.

◆ DecimalToString() [2/4]

void Mark3::MemUtil::DecimalToString ( uint16_t  u16Data_,
char *  szText_ 
)
static

Definition at line 54 of file memutil.cpp.

◆ DecimalToString() [3/4]

void Mark3::MemUtil::DecimalToString ( uint32_t  u32Data_,
char *  szText_ 
)
static

Definition at line 75 of file memutil.cpp.

◆ DecimalToString() [4/4]

void Mark3::MemUtil::DecimalToString ( uint64_t  u64Data_,
char *  szText_ 
)
static

Definition at line 96 of file memutil.cpp.

◆ SetMemory()

void Mark3::MemUtil::SetMemory ( void *  pvDst_,
uint8_t  u8Val_,
uint16_t  u16Len_ 
)
static

SetMemory.

Initialize a buffer of memory to a specified 8-bit pattern

Parameters
pvDst_Destination buffer to set
u8Val_8-bit pattern to initialize each byte of destination with
u16Len_Length of the buffer (in bytes) to initialize

Definition at line 271 of file memutil.cpp.

◆ StringLength()

uint16_t Mark3::MemUtil::StringLength ( const char *  szStr_)
static

StringLength.

Compute the length of a string in bytes.

Parameters
szStr_Pointer to the zero-terminated string to calculate the length of
Returns
length of the string (in bytes), not including the 0-terminator.

Definition at line 145 of file memutil.cpp.

◆ StringSearch()

int16_t Mark3::MemUtil::StringSearch ( const char *  szBuffer_,
const char *  szPattern_ 
)
static

StringSearch.

Search for the presence of one string as a substring within another.

Parameters
szBuffer_Buffer to search for pattern within
szPattern_Pattern to search for in the buffer
Returns
Index of the first instance of the pattern in the buffer, or -1 on no match.

Definition at line 221 of file memutil.cpp.

◆ Tokenize()

uint8_t Mark3::MemUtil::Tokenize ( const char *  szBuffer_,
Token_t pastTokens_,
uint8_t  u8MaxTokens_ 
)
static

Tokenize Function to tokenize a string based on a space delimeter. This is a non-destructive function, which popu32ates a Token_t descriptor array.

Parameters
szBuffer_String to tokenize
pastTokens_Pointer to the array of token descriptors
u8MaxTokens_Maximum number of tokens to parse (i.e. size of pastTokens_)
Returns
Count of tokens parsed

Definition at line 281 of file memutil.cpp.


The documentation for this class was generated from the following files: