ObjFW
Loading...
Searching...
No Matches
OFSecureData.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFData.h"
21
22OF_ASSUME_NONNULL_BEGIN
23
36OF_SUBCLASSING_RESTRICTED
38{
39 unsigned char *_Nullable _items;
40 size_t _count, _itemSize;
41 bool _freeWhenDone, _allowsSwappableMemory;
42 void *_page;
43}
44
48@property (readonly, nonatomic) bool allowsSwappableMemory;
49
56@property (readonly, nonatomic) void *mutableItems OF_RETURNS_INNER_POINTER;
57
70+ (void)preallocateUnswappableMemoryWithSize: (size_t)size;
71
81+ (instancetype)dataWithCount: (size_t)count
82 allowsSwappableMemory: (bool)allowsSwappableMemory;
83
94+ (instancetype)dataWithCount: (size_t)count
95 itemSize: (size_t)itemSize
96 allowsSwappableMemory: (bool)allowsSwappableMemory;
97
98+ (instancetype)dataWithItems: (const void *)items
99 count: (size_t)count OF_UNAVAILABLE;
100+ (instancetype)dataWithItems: (const void *)items
101 count: (size_t)count
102 itemSize: (size_t)itemSize OF_UNAVAILABLE;
103+ (instancetype)dataWithItemsNoCopy: (void *)items
104 count: (size_t)count
105 freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE;
106+ (instancetype)dataWithItemsNoCopy: (void *)items
107 count: (size_t)count
108 itemSize: (size_t)itemSize
109 freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE;
110#ifdef OF_HAVE_FILES
111+ (instancetype)dataWithContentsOfFile: (OFString *)path OF_UNAVAILABLE;
112#endif
113+ (instancetype)dataWithContentsOfIRI: (OFIRI *)IRI OF_UNAVAILABLE;
114+ (instancetype)dataWithStringRepresentation: (OFString *)string OF_UNAVAILABLE;
115+ (instancetype)dataWithBase64EncodedString: (OFString *)string OF_UNAVAILABLE;
116
126- (instancetype)initWithCount: (size_t)count
127 allowsSwappableMemory: (bool)allowsSwappableMemory;
128
139- (instancetype)initWithCount: (size_t)count
140 itemSize: (size_t)itemSize
141 allowsSwappableMemory: (bool)allowsSwappableMemory
142 OF_DESIGNATED_INITIALIZER;
143
144- (instancetype)init OF_UNAVAILABLE;
145- (instancetype)initWithItemSize: (size_t)itemSize OF_UNAVAILABLE;
146- (instancetype)initWithItems: (const void *)items
147 count: (size_t)count OF_UNAVAILABLE;
148- (instancetype)initWithItems: (const void *)items
149 count: (size_t)count
150 itemSize: (size_t)itemSize OF_UNAVAILABLE;
151- (instancetype)initWithItemsNoCopy: (void *)items
152 count: (size_t)count
153 freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE;
154- (instancetype)initWithItemsNoCopy: (void *)items
155 count: (size_t)count
156 itemSize: (size_t)itemSize
157 freeWhenDone: (bool)freeWhenDone OF_UNAVAILABLE;
158#ifdef OF_HAVE_FILES
159- (instancetype)initWithContentsOfFile: (OFString *)path OF_UNAVAILABLE;
160#endif
161- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI OF_UNAVAILABLE;
162- (instancetype)initWithStringRepresentation: (OFString *)string OF_UNAVAILABLE;
163- (instancetype)initWithBase64EncodedString: (OFString *)string OF_UNAVAILABLE;
164
174- (void *)mutableItemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER;
175
185- (bool)isEqual: (nullable id)object;
186
190- (void)zero;
191
192- (OFString *)stringRepresentation OF_UNAVAILABLE;
193- (OFString *)stringByBase64Encoding OF_UNAVAILABLE;
194#ifdef OF_HAVE_FILES
195- (void)writeToFile: (OFString *)path OF_UNAVAILABLE;
196#endif
197- (void)writeToIRI: (OFIRI *)IRI OF_UNAVAILABLE;
198- (OFData *)messagePackRepresentation OF_UNAVAILABLE;
199@end
200
201OF_ASSUME_NONNULL_END
A class for storing arbitrary data in an array.
Definition OFData.h:46
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition OFIRI.h:41
A class for storing arbitrary data in secure (non-swappable) memory, securely wiping it when it gets ...
Definition OFSecureData.h:38
A class for handling strings.
Definition OFString.h:143