ObjFW
|
#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 | |
static OF_INLINE OFRange OF_CONST_FUNC | OFMakeRange (size_t start, size_t length) |
Creates a new OFRange. | |
static OF_INLINE bool | OFEqualRanges (OFRange range1, OFRange range2) |
Returns whether the two ranges are equal. | |
static OF_INLINE OFPoint OF_CONST_FUNC | OFMakePoint (float x, float y) |
Creates a new OFPoint. | |
static OF_INLINE bool | OFEqualPoints (OFPoint point1, OFPoint point2) |
Returns whether the two points are equal. | |
static OF_INLINE OFSize OF_CONST_FUNC | OFMakeSize (float width, float height) |
Creates a new OFSize. | |
static OF_INLINE bool | OFEqualSizes (OFSize size1, OFSize size2) |
Returns whether the two sizes are equal. | |
static OF_INLINE OFRect OF_CONST_FUNC | OFMakeRect (float x, float y, float width, float height) |
Creates a new OFRect. | |
static OF_INLINE bool | OFEqualRects (OFRect rect1, OFRect rect2) |
Returns whether the two rectangles are equal. | |
static OF_INLINE OFVector3D OF_CONST_FUNC | OFMakeVector3D (float x, float y, float z) |
Creates a new OFVector3D. | |
static OF_INLINE bool | OFEqualVectors3D (OFVector3D vector1, OFVector3D vector2) |
Returns whether the two vectors are equal. | |
static OF_INLINE OFVector4D OF_CONST_FUNC | OFMakeVector4D (float x, float y, float z, float w) |
Creates a new OFVector4D. | |
static OF_INLINE bool | OFEqualVectors4D (OFVector4D vector1, OFVector4D vector2) |
Returns whether the two vectors are equal. | |
static OF_INLINE void | OFHashAddByte (unsigned long *hash, unsigned char byte) |
Adds the specified byte to the hash. | |
static OF_INLINE void | OFHashAddHash (unsigned long *hash, unsigned long otherHash) |
Adds the specified hash to the hash. | |
static OF_INLINE void | OFHashFinalize (unsigned long *hash) |
Finalizes the specified hash. | |
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. | |
id | OFAllocObject (Class class_, size_t extraSize, size_t extraAlignment, void **extra) |
Allocates a new object. | |
void | OFMethodNotFound (id self, SEL _cmd) |
This function is called when a method is not found. | |
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 OFComparisonResult(^ OFComparator) (id left, id right) |
A comparator to compare two objects.
left | The left object |
right | The right object |
typedef OFComparisonResult(* OFCompareFunction) (id left, id right, void *context) |
A function to compare two objects.
left | The left object |
right | The right object |
context | Context passed along for comparing |
enum OFByteOrder |
enum OFComparisonResult |
|
extern |
Allocates memory for the specified number of items of the specified size.
To free the allocated memory, use OFFreeMemory.
count | The number of items to allocate |
size | The size of each item to allocate |
OFOutOfMemoryException | The allocation failed due to not enough memory |
OFOutOfRangeException | The requested count * size exceeds the address space |
|
extern |
Allocates a new object.
This is useful to override alloc (OFObject) in a subclass that can then allocate extra memory in the same memory allocation.
class_ | The class of which to allocate an object |
extraSize | Extra space after the ivars to allocate |
extraAlignment | Alignment of the extra space after the ivars |
extra | A pointer to set to a pointer to the extra space |
|
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.
size | The size of each item to allocate |
count | The number of items to allocate |
OFOutOfMemoryException | The allocation failed due to not enough memory |
OFOutOfRangeException | The requested count * size exceeds the address space |
Returns whether the two points are equal.
point1 | The first point for the comparison |
point2 | The second point for the comparison |
Returns whether the two ranges are equal.
range1 | The first range for the comparison |
range2 | The second range for the comparison |
Returns whether the two rectangles are equal.
rect1 | The first rectangle for the comparison |
rect2 | The second rectangle for the comparison |
Returns whether the two sizes are equal.
size1 | The first size for the comparison |
size2 | The second size for the comparison |
|
static |
Returns whether the two vectors are equal.
vector1 | The first vector for the comparison |
vector2 | The second vectors for the comparison |
|
static |
Returns whether the two vectors are equal.
vector1 | The first vector for the comparison |
vector2 | The second vectors for the comparison |
|
extern |
Frees memory allocated by OFAllocMemory, OFAllocZeroedMemory or OFResizeMemory.
pointer | A pointer to the memory to free or nil (passing nil does nothing) |
|
static |
Adds the specified byte to the hash.
hash | A pointer to a hash to add the byte to |
byte | The byte to add to the hash |
|
static |
Adds the specified hash to the hash.
hash | A pointer to a hash to add the hash to |
otherHash | The hash to add to the hash |
|
static |
Finalizes the specified hash.
hash | A pointer to the hash to finalize |
|
extern |
Initializes the specified hash.
hash | A pointer to the hash to initialize |
|
static |
|
static |
|
static |
|
static |
|
static |
Creates a new OFVector3D.
x | The x coordinate of the vector |
y | The x coordinate of the vector |
z | The z coordinate of the vector |
|
static |
Creates a new OFVector4D.
x | The x coordinate of the vector |
y | The x coordinate of the vector |
z | The z coordinate of the vector |
w | The w coordinate of the vector |
|
extern |
This function is called when a method is not found.
It can also be called intentionally to indicate that a method is not implemetned, for example in an abstract method. However, instead of calling OFMethodNotFound directly, it is preferred to do the following:
- (void)abstractMethod { OF_UNRECOGNIZED_SELECTOR }
However, do not use this for init methods. Instead, use the following:
- (instancetype)init { OF_INVALID_INIT_METHOD }
self | The object which does not have the method |
_cmd | The selector of the method that does not exist |
|
extern |
Returns 16 bit or non-cryptographical randomness.
|
extern |
Returns 32 bit or non-cryptographical randomness.
|
extern |
Returns 64 bit or non-cryptographical randomness.
|
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.
pointer | A pointer to the already allocated memory |
size | The size of each item to resize to |
count | The number of items to resize to |
OFOutOfMemoryException | The reallocation failed due to not enough memory |
OFOutOfRangeException | The requested count * size exceeds the address space |