ObjFW  Check-in [8c45d72a13]

Overview
Comment:Add -[OFDataArray readDataArrayWithNItems:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8c45d72a1360e66c9c15867a9871a7ab0ecf7cceca981aba415509d5ed21eaf3
User & Date: js on 2011-04-25 11:39:16
Other Links: manifest | tags
Context
2011-04-25
14:14
Fix a warning when sizeof(size_t) < sizeof(long long). check-in: e14961f94d user: js tags: trunk
11:39
Add -[OFDataArray readDataArrayWithNItems:]. check-in: 8c45d72a13 user: js tags: trunk
11:35
Add +[OFDataArray dataArray] with a default item size of 1. check-in: 12617ef944 user: js tags: trunk
Changes

Modified src/OFStream.h from [0372616946] to [576cb8fb89].

144
145
146
147
148
149
150












151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
 *	    Otherwise you will get an exception!
 *
 * \return A uint64_t from the stream in the native endianess
 */
- (uint64_t)readLittleEndianInt64;

/**












 * Reads nitems items with the specified item size from the stream and returns
 * them in an OFDataArray.
 *
 * WARNING: Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * \param itemSize The size of each item
 * \param nItems The number of iteams to read
 * \return An OFDataArray with at nitems items.
 */
- (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize
				andNItems: (size_t)nItems;

/**
 * \return An OFDataArray with an item size of 1 with all the data of the
 *	   stream until the end of the stream is reached.







>
>
>
>
>
>
>
>
>
>
>
>
|






|
|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 *	    Otherwise you will get an exception!
 *
 * \return A uint64_t from the stream in the native endianess
 */
- (uint64_t)readLittleEndianInt64;

/**
 * Reads nItems items with an item size of 1 from the stream and returns them
 * in an OFDataArray.
 *
 * WARNING: Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * \param nItems The number of items to read
 * \return An OFDataArray with at nItems items.
 */
- (OFDataArray*)readDataArrayWithNItems: (size_t)nItems;

/**
 * Reads nItems items with the specified item size from the stream and returns
 * them in an OFDataArray.
 *
 * WARNING: Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * \param itemSize The size of each item
 * \param nItems The number of items to read
 * \return An OFDataArray with at nItems items.
 */
- (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize
				andNItems: (size_t)nItems;

/**
 * \return An OFDataArray with an item size of 1 with all the data of the
 *	   stream until the end of the stream is reached.

Modified src/OFStream.m from [7a29dd6a1c] to [17a9e9e523].

200
201
202
203
204
205
206






207
208
209
210
211
212
213
	uint64_t ret;

	[self readExactlyNBytes: 8
		     intoBuffer: (char*)&ret];

	return of_bswap64_if_be(ret);
}







- (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize
				andNItems: (size_t)nItems
{
	OFDataArray *da;
	char *tmp;








>
>
>
>
>
>







200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
	uint64_t ret;

	[self readExactlyNBytes: 8
		     intoBuffer: (char*)&ret];

	return of_bswap64_if_be(ret);
}

- (OFDataArray*)readDataArrayWithNItems: (size_t)nItems
{
	return [self readDataArrayWithItemSize: 1
				     andNItems: nItems];
}

- (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize
				andNItems: (size_t)nItems
{
	OFDataArray *da;
	char *tmp;