Next Previous Table of Contents

The LMisc Class

#include <lmisc/lmisc.hxx>

Overview

LMisc is a class containing miscellaneous constants and static inline methods. The constants give basic information about the size of unsigned ints, while the methods implement very basic operations. Most of these methods are for dealing with strings of unsigned ints or dwords.

Public Constants

bytesPerUInt

static const int bytesPerUInt=sizeof(unsigned int);

nibblesPerUInt

static const int nibblesPerUInt=bytesPerUInt*2;

bitsPerUInt

static const int bitsPerUInt=bytesPerUInt*8;

Public Methods

MemZero

static inline void LMisc::MemZero(u8* x, const int bytes);

Zeros the bytes from x to x+bytes-1.

static inline void LMisc::MemZero(unsigned int* x, const int size);

Zeros the unsigned ints from x to x+size-1.

static inline void LMisc::MemZero(u32* x, int size);

Zeros the dwords from x to x+size-1.

MemCopy

static inline void LMisc::MemCopy(unsigned int* dest, 
                                  const unsigned int* source, 
                                  int size);

Copies the unsigned ints from the memory segment starting at source and ending at source+size-1 into the memory segment starting at dest and ending at dest+size-1. This method will only work when the source and destination segments are disjoint.

static inline void LMisc::MemCopy(u32* dest, 
                                  const u32* source, 
                                  int size);

Copies the dwords from the memory segment starting at source and ending at source+size-1 into the memory segment starting at dest and ending at dest+size-1. This method will only work when the source and destination segments are disjoint.

MemMove

static inline void LMisc::MemMove(unsigned int* dest, 
                                  unsigned int* source, 
                                  int size);

Copies the unsigned ints from the memory segment starting at source and ending at source+size-1 into the memory segment starting at dest and ending at dest+size-1. This method will work even if the source and destination segments overlap.

static inline void LMisc::MemMove(u32* dest, 
                                  u32* source, 
                                  int size);

Copies the dwords from the memory segment starting at source and ending at source+size-1 into the memory segment starting at dest and ending at dest+size-1. This method will work even if the source and destination segments overlap.

MemSwap

static inline void LMisc::MemSwap(unsigned int* buffer, 
                                  int size);

Toggles the endianness of the unsigned ints in the memory segment starting at buffer and ending at buffer+size-1.

static inline void LMisc::MemSwap(u32* buffer, 
                                  int size);

Toggles the endianness of the dwords in the memory segment starting at buffer and ending at buffer+size-1.

BSwap

static inline unsigned int LMisc::BSwap(unsigned int x);

Returns an unsigned int equal to x with its endianness toggled.

static inline u32 LMisc::BSwap(u32 x);

Returns a dword equal to x with its endianness toggled.

LowBitFilter

static inline unsigned int LMisc::LowBitFilter(const int numBits);

Returns an unsigned int with its numBits least significant bits set to 1 and the remaining bits set to 0.

Ceiling

static inline unsigned int LMisc::Ceiling(unsigned int x, unsigned int y);

Returns the smallest integer greater than or equal to x divided by y.

High32of64

static inline u32 LMisc::High32of64(const u64 x);

Returns the dword given by the 32 most significant bits of x.

Low32of64

static inline u32 LMisc::Low32of64(const u64 x);

Returns the dword given by the 32 least significant bits of x.


Next Previous Table of Contents