ObjFW
OFPair.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
25 @interface OFPair OF_GENERIC(FirstType, SecondType): OFObject <OFCopying,
27 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
28 # define FirstType id
29 # define SecondType id
30 #endif
31 {
32  FirstType _Nullable _firstObject;
33  SecondType _Nullable _secondObject;
34  OF_RESERVE_IVARS(OFPair, 4)
35 }
36 
40 @property OF_NULLABLE_PROPERTY (readonly, nonatomic, retain)
41  FirstType firstObject;
42 
46 @property OF_NULLABLE_PROPERTY (readonly, nonatomic, retain)
47  SecondType secondObject;
48 
56 + (instancetype)pairWithFirstObject: (nullable FirstType)firstObject
57  secondObject: (nullable SecondType)secondObject;
58 
66 - (instancetype)initWithFirstObject: (nullable FirstType)firstObject
67  secondObject: (nullable SecondType)secondObject
68  OF_DESIGNATED_INITIALIZER;
69 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
70 # undef FirstType
71 # undef SecondType
72 #endif
73 @end
74 
75 OF_ASSUME_NONNULL_END
76 
77 #import "OFMutablePair.h"
The root class for all other classes inside ObjFW.
Definition: OFObject.h:688
A class for storing a pair of two objects.
Definition: OFPair.h:36
A protocol for the creation of copies.
Definition: OFObject.h:1346
A protocol for the creation of mutable copies.
Definition: OFObject.h:1367