Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
Data Structures | Macros | Typedefs | Enumerations
Types.h File Reference

Objectively base types. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  Range
 A location and length into contiguous collections. More...
 

Macros

#define clamp(val, min, max)
 
#define lengthof(array)   (sizeof(array) / sizeof((array)[0]))
 
#define max(a, b)   ({ typeof (a) _a = (a); typeof (b) _b = (b); _a > _b ? _a : _b; })
 
#define min(a, b)   ({ typeof (a) _a = (a); typeof (b) _b = (b); _a < _b ? _a : _b; })
 
#define OBJECTIVELY_EXPORT   extern
 

Typedefs

typedef void(* BiConsumer) (ident data1, ident data2)
 The BiConsumer function type. More...
 
typedef Order(* Comparator) (const ident obj1, const ident obj2)
 The Comparator function type for ordering Objects. More...
 
typedef void(* Consumer) (ident data)
 The Consumer function type. More...
 
typedef ident(* Functor) (const ident obj, ident data)
 The Functor function type for transforming Objects. More...
 
typedef void * ident
 The identity type, similar to Objective-C id. More...
 
typedef _Bool(* Predicate) (const ident obj, ident data)
 The Predicate function type for filtering Objects. More...
 
typedef ident(* Producer) (ident data)
 The Producer function type. More...
 
typedef ident(* Reducer) (const ident obj, ident accumulator, ident data)
 The Reducer function type for reducing collections. More...
 

Enumerations

enum  Order { OrderAscending = -1 , OrderSame = 0 , OrderDescending = 1 }
 Comparison constants. More...
 

Detailed Description

Objectively base types.

Definition in file Types.h.

Macro Definition Documentation

◆ clamp

#define clamp (   val,
  min,
  max 
)
Value:
({ \
typeof(val) _val = (val); typeof(min) _min = (min); typeof(max) _max = (max); \
_max < _min ? \
_val < _max ? _max : _val > _min ? _min : _val \
: \
_val < _min ? _min : _val > _max ? _max : _val; \
})
#define min(a, b)
Definition: Types.h:159
#define max(a, b)
Definition: Types.h:152
Returns
The value, clamped to the bounds.

Definition at line 132 of file Types.h.

◆ lengthof

#define lengthof (   array)    (sizeof(array) / sizeof((array)[0]))
Returns
The length of an array.

Definition at line 145 of file Types.h.

◆ max

#define max (   a,
 
)    ({ typeof (a) _a = (a); typeof (b) _b = (b); _a > _b ? _a : _b; })
Returns
The maximum of the two values.

Definition at line 152 of file Types.h.

◆ min

#define min (   a,
 
)    ({ typeof (a) _a = (a); typeof (b) _b = (b); _a < _b ? _a : _b; })
Returns
The minimum of the two values.

Definition at line 159 of file Types.h.

◆ OBJECTIVELY_EXPORT

#define OBJECTIVELY_EXPORT   extern

Definition at line 36 of file Types.h.

Typedef Documentation

◆ BiConsumer

typedef void(* BiConsumer) (ident data1, ident data2)

The BiConsumer function type.

Parameters
data1The first argument.
data2The second argument.

Definition at line 95 of file Types.h.

◆ Comparator

typedef Order(* Comparator) (const ident obj1, const ident obj2)

The Comparator function type for ordering Objects.

Parameters
obj1The first Object.
obj2The second Object.
Returns
The Order of obj1 relative to obj2.

Definition at line 82 of file Types.h.

◆ Consumer

typedef void(* Consumer) (ident data)

The Consumer function type.

Parameters
dataUser data.

Definition at line 88 of file Types.h.

◆ Functor

typedef ident(* Functor) (const ident obj, ident data)

The Functor function type for transforming Objects.

Parameters
objThe Object to transform.
dataUser data.
Returns
The transformation result.

Definition at line 103 of file Types.h.

◆ ident

typedef void* ident

The identity type, similar to Objective-C id.

Definition at line 49 of file Types.h.

◆ Predicate

typedef _Bool(* Predicate) (const ident obj, ident data)

The Predicate function type for filtering Objects.

Parameters
objThe Object to test.
dataUser data.
Returns
True if obj satisfies the predicate, false otherwise.

Definition at line 111 of file Types.h.

◆ Producer

typedef ident(* Producer) (ident data)

The Producer function type.

Parameters
dataUser data.
Returns
The product.

Definition at line 118 of file Types.h.

◆ Reducer

typedef ident(* Reducer) (const ident obj, ident accumulator, ident data)

The Reducer function type for reducing collections.

Parameters
objThe Object to reduce.
accumulatorThe accumulator.
dataUser data.
Returns
The reduction result.

Definition at line 127 of file Types.h.

Enumeration Type Documentation

◆ Order

enum Order

Comparison constants.

Enumerator
OrderAscending 
OrderSame 
OrderDescending 

Definition at line 70 of file Types.h.

70 {
71 OrderAscending = -1,
72 OrderSame = 0,
74} Order;
Order
Comparison constants.
Definition: Types.h:70
@ OrderSame
Definition: Types.h:72
@ OrderDescending
Definition: Types.h:73
@ OrderAscending
Definition: Types.h:71