Rudiments
Static Public Member Functions | List of all members
bytestring Class Reference

#include <bytestring.h>

Static Public Member Functions

static voidduplicate (const void *src, size_t size)
 
static voidcopy (void *dest, const void *src, size_t size)
 
static voidcopyWithOverlap (void *dest, const void *src, size_t size)
 
static voidcopyUntil (void *dest, const void *src, byte_t character, size_t size)
 
static voidcopySwapBytes (void *dest, const void *src, size_t size)
 
static voidset (void *dest, byte_t character, size_t size)
 
static voidzero (void *dest, size_t size)
 
static int32_t compare (const void *s1, const void *s2, size_t size)
 
static voidfindFirst (void *haystack, byte_t needle, size_t size)
 
static voidfindLast (void *haystack, byte_t needle, size_t size)
 
static voidfindFirst (void *haystack, size_t haystacksize, const void *needle, size_t needleize)
 
static voidfindLast (void *haystack, size_t haystacksize, const void *needle, size_t needleize)
 
static const voidfindFirst (const void *haystack, byte_t needle, size_t size)
 
static const voidfindLast (const void *haystack, byte_t needle, size_t size)
 
static const voidfindFirst (const void *haystack, size_t haystacksize, const void *needle, size_t needlesize)
 
static const voidfindLast (const void *haystack, size_t haystacksize, const void *needle, size_t needlesize)
 

Detailed Description

The bytestring class provides methods for manipulating byte strings.

In addition to some unique methods, analogs for the standard C "memory" functions are provided. However, unlike the standard C functions, the bytestring methods are NULL safe. Your application will not crash if a NULL is passed in, and instead, will give intuitive results.

Member Function Documentation

◆ compare()

static int32_t bytestring::compare ( const void * s1,
const void * s2,
size_t size )
static

Returns an integer less than, equal to or greater than 0 if "size" bytes of "s1" are less than, equal to or greater than "size" bytes of "s2".

◆ copy()

static void * bytestring::copy ( void * dest,
const void * src,
size_t size )
static

Copies "size" bytes from "src" into "dest". "src" and "dest" may NOT overlap. Returns a pointer to "dest".

◆ copySwapBytes()

static void * bytestring::copySwapBytes ( void * dest,
const void * src,
size_t size )
static

Copies "size" bytes from "src" into "dest" while swapping byte order. Useful for exchanging data between big and little endian machines. "src" and "dest" may NOT overlap. Returns a pointer to "dest".

◆ copyUntil()

static void * bytestring::copyUntil ( void * dest,
const void * src,
byte_t character,
size_t size )
static

Copies bytes from "src" into "dest" until "character" is encountered in "src" or "size" bytes have been copied. "src" and "dest" may NOT overlap. Returns a pointer to "dest".

◆ copyWithOverlap()

static void * bytestring::copyWithOverlap ( void * dest,
const void * src,
size_t size )
static

Copies "size" bytes from "src" to "dest". "src" and "dest" may overlap. Returns a pointer to "dest".

◆ duplicate()

static void * bytestring::duplicate ( const void * src,
size_t size )
static

Allocates a buffer of "size" bytes, copies "size" bytes of "src" into it and returns the buffer.

◆ findFirst() [1/4]

static const void * bytestring::findFirst ( const void * haystack,
byte_t needle,
size_t size )
static

Returns a pointer to the first occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ findFirst() [2/4]

static const void * bytestring::findFirst ( const void * haystack,
size_t haystacksize,
const void * needle,
size_t needlesize )
static

Returns a pointer to the first occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ findFirst() [3/4]

static void * bytestring::findFirst ( void * haystack,
byte_t needle,
size_t size )
static

Returns a pointer to the first occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ findFirst() [4/4]

static void * bytestring::findFirst ( void * haystack,
size_t haystacksize,
const void * needle,
size_t needleize )
static

Returns a pointer to the first occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ findLast() [1/4]

static const void * bytestring::findLast ( const void * haystack,
byte_t needle,
size_t size )
static

Returns a pointer to the last occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ findLast() [2/4]

static const void * bytestring::findLast ( const void * haystack,
size_t haystacksize,
const void * needle,
size_t needlesize )
static

Returns a pointer to the last occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ findLast() [3/4]

static void * bytestring::findLast ( void * haystack,
byte_t needle,
size_t size )
static

Returns a pointer to the last occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ findLast() [4/4]

static void * bytestring::findLast ( void * haystack,
size_t haystacksize,
const void * needle,
size_t needleize )
static

Returns a pointer to the last occurrance of "needle" in the first "size" bytes of "haystack". Returns NULL if no match is found.

◆ set()

static void * bytestring::set ( void * dest,
byte_t character,
size_t size )
static

Sets "size" bytes of "dest" to "character". Returns a pointer to "dest".

◆ zero()

static void * bytestring::zero ( void * dest,
size_t size )
static

Sets "size" bytes of "dest" to NULL. Returns a pointer to "dest".