ObjFW
Public Member Functions | Static Public Member Functions | Public Attributes
OFObject Class Reference

The root class for all other classes inside ObjFW. More...

#import <OFObject.h>

Inheritance diagram for OFObject:
<OFObject> OFAllocFailedException OFApplication OFArray OFAutoreleasePool OFBlock OFDataArray OFDate OFDictionary OFEnumerator OFException OFHash OFHTTPRequest OFHTTPRequestResult OFInstanceVariable OFIntrospection OFList OFMethod OFMutex OFNull OFNumber OFPlugin OFProperty OFSet OFStream OFStreamObserver OFString OFThread OFTLSKey OFURL OFXMLElementBuilder OFXMLNode OFXMLParser

List of all members.

Public Member Functions

(id) - init
 Initializes an already allocated object.
(OFString *) - className
 Returns the name of the object's class.
(OFString *) - description
 Returns a description for the object.
(void) - addMemoryToPool:
 Adds a pointer to the object's memory pool.
(void *) - allocMemoryWithSize:
 Allocates memory and stores it in the object's memory pool.
(void *) - allocMemoryForNItems:ofSize:
 Allocates memory for the specified number of items and stores it in the object's memory pool.
(void *) - resizeMemory:toSize:
 Resizes memory in the object's memory pool to the specified size.
(void *) - resizeMemory:toNItems:ofSize:
 Resizes memory in the object's memory pool to the specific number of items of the specified size.
(void) - freeMemory:
 Frees allocated memory and removes it from the object's memory pool.
(void) - dealloc
 Deallocates the object.
(OFString *) - stringBySerializing
 Creates a string by serializing the receiver.

Static Public Member Functions

(void) + load
 A method which is called once when the class is loaded into the runtime.
(void) + initialize
 A method which is called the moment before the first call to the class is being made.
(id) + alloc
 Allocates memory for an instance of the class and sets up the memory pool for the object.
(id) + new
 Allocates memory for a new instance and calls -[init] on it.
(Class) + class
 Returns the class.
(OFString *) + className
 Returns the name of the class as a string.
(BOOL) + isSubclassOfClass:
 Returns a boolean whether the class is a subclass of the specified class.
(Class) + superclass
 Returns the superclass of the class.
(BOOL) + instancesRespondToSelector:
 Checks whether instances of the class respond to a given selector.
(BOOL) + conformsToProtocol:
 Checks whether the class conforms to a given protocol.
(IMP) + instanceMethodForSelector:
 Returns the implementation of the instance method for the specified selector.
(const char *) + typeEncodingForInstanceSelector:
 Returns the type encoding of the instance method for the specified selector.
(OFString *) + description
 Returns a description for the class, which is usually the class name.
(IMP) + setImplementation:forClassMethod:
 Replaces a class method implementation with another implementation.
(IMP) + replaceClassMethod:withMethodFromClass:
 Replaces a class method with a class method from another class.
(IMP) + setImplementation:forInstanceMethod:
 Replaces an instance method implementation with another implementation.
(IMP) + replaceInstanceMethod:withMethodFromClass:
 Replaces an instance method with an instance method from another class.
(BOOL) + addClassMethod:withTypeEncoding:implementation:
 Adds a class method to the class.
(BOOL) + addInstanceMethod:withTypeEncoding:implementation:
 Adds an instance method to the class.
(void) + inheritMethodsFromClass:
 Adds all methods from the specified class to the class that is the receiver.

Public Attributes

Class isa
 The class of the object.

Detailed Description

The root class for all other classes inside ObjFW.


Member Function Documentation

+ (BOOL) addClassMethod: (SEL)  selector
withTypeEncoding: (const char*)  typeEncoding
implementation: (IMP)  implementation 

Adds a class method to the class.

If the method already exists, nothing is done and NO is returned. If you want to change the implementation of a method, use setImplementation:forClassMethod:.

Parameters:
selectorThe selector for the new method
typeEncodingThe type encoding for the new method
implementationThe implementation for the new method
Returns:
Whether the method has been added
+ (BOOL) addInstanceMethod: (SEL)  selector
withTypeEncoding: (const char*)  typeEncoding
implementation: (IMP)  implementation 

Adds an instance method to the class.

If the method already exists, nothing is done and NO is returned. If you want to change the implementation of a method, use setImplementation:forInstanceMethod:.

Parameters:
selectorThe selector for the new method
typeEncodingThe type encoding for the new method
implementationThe implementation for the new method
Returns:
Whether the method has been added
- (void) addMemoryToPool: (void*)  pointer

Adds a pointer to the object's memory pool.

This is useful to add memory allocated by functions such as asprintf to the pool so it gets free'd automatically when the object is deallocated.

Parameters:
pointerA pointer to add to the memory pool
+ (id) alloc

Allocates memory for an instance of the class and sets up the memory pool for the object.

This method will never return nil, instead, it will throw an OFAllocFailedException.

Returns:
The allocated object
- (void *) allocMemoryForNItems: (size_t)  nItems
ofSize: (size_t)  size 

Allocates memory for the specified number of items and stores it in the object's memory pool.

It will be free'd automatically when the object is deallocated.

Parameters:
nItemsThe number of items to allocate
sizeThe size of each item to allocate
Returns:
A pointer to the allocated memory
- (void *) allocMemoryWithSize: (size_t)  size

Allocates memory and stores it in the object's memory pool.

It will be free'd automatically when the object is deallocated.

Parameters:
sizeThe size of the memory to allocate
Returns:
A pointer to the allocated memory
+ (Class) class

Returns the class.

Returns:
The class

Reimplemented from <OFObject>.

+ (OFString *) className

Returns the name of the class as a string.

Returns:
The name of the class as a string
- (OFString*) className

Returns the name of the object's class.

Returns:
The name of the object's class
+ (BOOL) conformsToProtocol: (Protocol*)  protocol

Checks whether the class conforms to a given protocol.

Parameters:
protocolThe protocol which should be checked for conformance
Returns:
A boolean whether the class conforms to the specified protocol

Reimplemented from <OFObject>.

- (void) dealloc

Deallocates the object.

It is automatically called when the retain count reaches zero.

This also frees all memory in its memory pool.

+ (OFString *) description

Returns a description for the class, which is usually the class name.

This is mostly for debugging purposes.

Returns:
A description for the class, which is usually the class name

Reimplemented in OFException, and OFAllocFailedException.

- (OFString*) description

Returns a description for the object.

This is mostly for debugging purposes.

Returns:
A description for the object

Reimplemented in OFException, and OFAllocFailedException.

- (void) freeMemory: (void*)  pointer

Frees allocated memory and removes it from the object's memory pool.

Does nothing if the pointer is NULL.

Parameters:
pointerA pointer to the allocated memory
+ (void) inheritMethodsFromClass: (Class)  class_

Adds all methods from the specified class to the class that is the receiver.

Methods implemented by the receiving class itself will not be overridden, however methods implemented by its superclass will. Therefore it behaves similar as if the specified class is the superclass of the receiver.

All methods from the superclasses of the specified class will also be added.

If the specified class is a superclass of the receiving class, nothing is done.

The methods which will be added from the specified class are not allowed to use super or access instance variables, instead they have to use accessors.

Parameters:
classThe class from which the instance methods should be inherited
- (id) init

Initializes an already allocated object.

Derived classes may override this, but need to do self = [super init] before they do any initialization themselves. init may never return nil, instead an exception (for example OFInitializationFailed) should be thrown.

Returns:
An initialized object

Reimplemented in OFDictionary, and OFDataArray.

+ (void) initialize

A method which is called the moment before the first call to the class is being made.

Derived classes can override this to execute their own code on initialization. They should make sure to not execute any code if self is not the class itself, as it might happen that the method was called for a subclass which did not override this method.

+ (IMP) instanceMethodForSelector: (SEL)  selector

Returns the implementation of the instance method for the specified selector.

Parameters:
selectorThe selector for which the method should be returned
Returns:
The implementation of the instance method for the specified selector or nil if it isn't implemented
+ (BOOL) instancesRespondToSelector: (SEL)  selector

Checks whether instances of the class respond to a given selector.

Parameters:
selectorThe selector which should be checked for respondance
Returns:
A boolean whether instances of the class respond to the specified selector
+ (BOOL) isSubclassOfClass: (Class)  class_

Returns a boolean whether the class is a subclass of the specified class.

Parameters:
class_The class which is checked for being a superclass
Returns:
A boolean whether the class is a subclass of the specified class
+ (void) load

A method which is called once when the class is loaded into the runtime.

Derived classes can overide this to execute their own code when the class is loaded.

+ (id) new

Allocates memory for a new instance and calls -[init] on it.

Returns:
An allocated and initialized object
+ (IMP) replaceClassMethod: (SEL)  selector
withMethodFromClass: (Class)  class_ 

Replaces a class method with a class method from another class.

Parameters:
selectorThe selector of the class method to replace
class_The class from which the new class method should be taken
Returns:
The old implementation
+ (IMP) replaceInstanceMethod: (SEL)  selector
withMethodFromClass: (Class)  class_ 

Replaces an instance method with an instance method from another class.

Parameters:
selectorThe selector of the instance method to replace
class_The class from which the new instance method should be taken
Returns:
The old implementation
- (void *) resizeMemory: (void*)  pointer
toNItems: (size_t)  nItems
ofSize: (size_t)  size 

Resizes memory in the object's memory pool to the specific number of items of the specified size.

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
nItemsThe number of items to resize to
sizeThe size of each item to resize to
Returns:
A pointer to the resized memory chunk
- (void *) resizeMemory: (void*)  pointer
toSize: (size_t)  size 

Resizes memory in the object's memory pool to the specified size.

If the pointer is NULL, this is equivalent to allocating memory. If the size is 0, this is equivalent to freeing memory.

Parameters:
pointerA pointer to the already allocated memory
sizeThe new size for the memory chunk
Returns:
A pointer to the resized memory chunk
+ (IMP) setImplementation: (IMP)  newImp
forClassMethod: (SEL)  selector 

Replaces a class method implementation with another implementation.

Parameters:
newImpThe new implementation for the class method
selectorThe selector of the class method to replace
Returns:
The old implementation
+ (IMP) setImplementation: (IMP)  newImp
forInstanceMethod: (SEL)  selector 

Replaces an instance method implementation with another implementation.

Parameters:
newImpThe new implementation for the instance method
selectorThe selector of the instance method to replace
Returns:
The old implementation
- (OFString*) stringBySerializing

Creates a string by serializing the receiver.

Returns:
The object serialized as a string
+ (Class) superclass

Returns the superclass of the class.

Returns:
The superclass of the class
+ (const char *) typeEncodingForInstanceSelector: (SEL)  selector

Returns the type encoding of the instance method for the specified selector.

Parameters:
selectorThe selector for which the type encoding should be returned
Returns:
The type encoding of the instance method for the specified selector

The documentation for this class was generated from the following files:
 All Classes Functions Variables Properties