ObjFW
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
OFObject.h File Reference
#include "objfw-defs.h"
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include "macros.h"
import "OFOnce.h"
import "OFBlock.h"
import "OFObject+KeyValueCoding.h"

Go to the source code of this file.

Classes

struct  OFRange
 A range. More...
 
struct  OFPoint
 A point in 2D space. More...
 
struct  OFSize
 A size. More...
 
struct  OFRect
 A rectangle. More...
 
struct  OFVector3D
 A vector in 3D space. More...
 
struct  OFVector4D
 A vector in 4D space. More...
 
protocol  <OFObject>
 The protocol which all root classes implement. More...
 
class  OFObject
 The root class for all other classes inside ObjFW. More...
 
protocol  <OFCopying>
 A protocol for the creation of copies. More...
 
protocol  <OFMutableCopying>
 A protocol for the creation of mutable copies. More...
 
protocol  <OFComparing>
 A protocol for comparing objects. More...
 

Typedefs

typedef OFComparisonResult(* OFCompareFunction) (id left, id right, void *context)
 A function to compare two objects.
 
typedef OFComparisonResult(^ OFComparator) (id left, id right)
 A comparator to compare two objects.
 
typedef double OFTimeInterval
 A time interval in seconds.
 

Enumerations

enum  OFComparisonResult { OFOrderedAscending = -1 , OFOrderedSame = 0 , OFOrderedDescending = 1 }
 A result of a comparison. More...
 
enum  OFByteOrder { OFByteOrderBigEndian , OFByteOrderLittleEndian , OFByteOrderNative = OFByteOrderLittleEndian }
 An enum for representing endianness. More...
 

Functions

void * OFAllocMemory (size_t count, size_t size)
 Allocates memory for the specified number of items of the specified size.
 
void * OFAllocZeroedMemory (size_t count, size_t size)
 Allocates memory for the specified number of items of the specified size and initializes it with zeros.
 
void * OFResizeMemory (void *pointer, size_t count, size_t size)
 Resizes memory to the specified number of items of the specified size.
 
void OFFreeMemory (void *pointer)
 Frees memory allocated by OFAllocMemory, OFAllocZeroedMemory or OFResizeMemory.
 
void OFHashInit (unsigned long *hash)
 Initializes the specified hash.
 
uint16_t OFRandom16 (void)
 Returns 16 bit or non-cryptographical randomness.
 
uint32_t OFRandom32 (void)
 Returns 32 bit or non-cryptographical randomness.
 
uint64_t OFRandom64 (void)
 Returns 64 bit or non-cryptographical randomness.
 

Typedef Documentation

◆ OFComparator

typedef OFComparisonResult(^ OFComparator) (id left, id right)

A comparator to compare two objects.

Parameters
leftThe left object
rightThe right object
Returns
The order of the objects

◆ OFCompareFunction

typedef OFComparisonResult(* OFCompareFunction) (id left, id right, void *context)

A function to compare two objects.

Parameters
leftThe left object
rightThe right object
contextContext passed along for comparing
Returns
The order of the objects

Enumeration Type Documentation

◆ OFByteOrder

An enum for representing endianness.

Enumerator
OFByteOrderBigEndian 

Most significant byte first (big endian)

OFByteOrderLittleEndian 

Least significant byte first (little endian)

OFByteOrderNative 

Native byte order of the system

◆ OFComparisonResult

A result of a comparison.

Enumerator
OFOrderedAscending 

The left object is smaller than the right

OFOrderedSame 

Both objects are equal

OFOrderedDescending 

The left object is bigger than the right

Function Documentation

◆ OFAllocMemory()

void * OFAllocMemory ( size_t count,
size_t size )
extern

Allocates memory for the specified number of items of the specified size.

To free the allocated memory, use OFFreeMemory.

Parameters
countThe number of items to allocate
sizeThe size of each item to allocate
Returns
A pointer to the allocated memory. May return NULL if the specified size or count is 0.
Exceptions
OFOutOfMemoryExceptionThe allocation failed due to not enough memory
OFOutOfRangeExceptionThe requested count * size exceeds the address space

◆ OFAllocZeroedMemory()

void * OFAllocZeroedMemory ( size_t count,
size_t size )
extern

Allocates memory for the specified number of items of the specified size and initializes it with zeros.

To free the allocated memory, use OFFreeMemory.

Parameters
sizeThe size of each item to allocate
countThe number of items to allocate
Returns
A pointer to the allocated memory. May return NULL if the specified size or count is 0.
Exceptions
OFOutOfMemoryExceptionThe allocation failed due to not enough memory
OFOutOfRangeExceptionThe requested count * size exceeds the address space

◆ OFFreeMemory()

void OFFreeMemory ( void * pointer)
extern

Frees memory allocated by OFAllocMemory, OFAllocZeroedMemory or OFResizeMemory.

Parameters
pointerA pointer to the memory to free or nil (passing nil does nothing)

◆ OFHashInit()

void OFHashInit ( unsigned long * hash)
extern

Initializes the specified hash.

Parameters
hashA pointer to the hash to initialize

◆ OFRandom16()

uint16_t OFRandom16 ( void )
extern

Returns 16 bit or non-cryptographical randomness.

Returns
16 bit or non-cryptographical randomness

◆ OFRandom32()

uint32_t OFRandom32 ( void )
extern

Returns 32 bit or non-cryptographical randomness.

Returns
32 bit or non-cryptographical randomness

◆ OFRandom64()

uint64_t OFRandom64 ( void )
extern

Returns 64 bit or non-cryptographical randomness.

Returns
64 bit or non-cryptographical randomness

◆ OFResizeMemory()

void * OFResizeMemory ( void * pointer,
size_t count,
size_t size )
extern

Resizes memory to the specified number of items of the specified size.

To free the allocated memory, use OFFreeMemory.

If the pointer is NULL, this is equivalent to allocating memory. If the size or number of items is 0, this is equivalent to freeing memory.

Parameters
pointerA pointer to the already allocated memory
sizeThe size of each item to resize to
countThe number of items to resize to
Returns
A pointer to the resized memory chunk
Exceptions
OFOutOfMemoryExceptionThe reallocation failed due to not enough memory
OFOutOfRangeExceptionThe requested count * size exceeds the address space