ObjFW  Check-in [5168142abe]

Overview
Comment:Allow initialization without NItems for OFReadOrWriteFailedException.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5168142abeb2dacda8dcc9e844c61a9c62680e4e6a2b81622554da5ace5a6d1a
User & Date: js on 2008-12-11 13:53:31
Other Links: manifest | tags
Context
2008-12-11
13:56
Fix two FIXMEs in OFTCPSocket. check-in: 6d765d0301 user: js tags: trunk
13:53
Allow initialization without NItems for OFReadOrWriteFailedException. check-in: 5168142abe user: js tags: trunk
13:43
Remove - close from OFStream protocol.
The reason is that closing a file isn't too useful, because an OFFile
object can't be reused, whereas an OFTCPSocket can. So only the
OFTCPSocket should have closed. Plus, we don't need to handle the case
that someone tried to read from / write to a closed OFFile.
check-in: c83137e7cd user: js tags: trunk
Changes

Modified src/OFExceptions.h from [7dd17fb763] to [bd5ad34ccf].

201
202
203
204
205
206
207

208
209
210
211
212
213
214
215
216
217
218
219
220
221










222
223
224
225
226
227
228
229
230
231
232
233










234
235
236
237
238
239
240
/**
 * An OFException indicating a read or write to the file failed.
 */
@interface OFReadOrWriteFailedException: OFException
{
	size_t req_size;
	size_t req_items;

}

/**
 * Creates a new read or write failed exception.
 *
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \param nitems The requested number of items that couldn't be read / written
 * \return A new open file failed exception
 */
+ newWithObject: (id)obj
	andSize: (size_t)size
      andNItems: (size_t)nitems;











/**
 * Initializes an already allocated read or write failed exception.
 *
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \param nitems The requested number of items that couldn't be read / written
 * \return A new open file failed exception
 */
- initWithObject: (id)obj
	 andSize: (size_t)size
       andNItems: (size_t)nitems;











/**
 * \return The requested size of the data that couldn't be read / written
 */
- (size_t)requestedSize;

/**
 * \return The requested number of items that coudln't be read / written







>














>
>
>
>
>
>
>
>
>
>












>
>
>
>
>
>
>
>
>
>







201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/**
 * An OFException indicating a read or write to the file failed.
 */
@interface OFReadOrWriteFailedException: OFException
{
	size_t req_size;
	size_t req_items;
	BOOL has_items;
}

/**
 * Creates a new read or write failed exception.
 *
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \param nitems The requested number of items that couldn't be read / written
 * \return A new open file failed exception
 */
+ newWithObject: (id)obj
	andSize: (size_t)size
      andNItems: (size_t)nitems;

/**
 * Creates a new read or write failed exception.
 *
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \return A new open file failed exception
 */
+ newWithObject: (id)obj
	andSize: (size_t)size;

/**
 * Initializes an already allocated read or write failed exception.
 *
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \param nitems The requested number of items that couldn't be read / written
 * \return A new open file failed exception
 */
- initWithObject: (id)obj
	 andSize: (size_t)size
       andNItems: (size_t)nitems;

/**
 * Initializes an already allocated read or write failed exception.
 *
 * \param obj The object which caused the exception
 * \param size The requested size of the data that couldn't be read / written
 * \return A new open file failed exception
 */
- initWithObject: (id)obj
	 andSize: (size_t)size;

/**
 * \return The requested size of the data that couldn't be read / written
 */
- (size_t)requestedSize;

/**
 * \return The requested number of items that coudln't be read / written

Modified src/OFExceptions.m from [5e428f851d] to [2779dde916].

218
219
220
221
222
223
224







225
226
227
228
229
230
231
232













233
234
235
236
237
238
239
	andSize: (size_t)size
      andNItems: (size_t)nitems
{
	return [[self alloc] initWithObject: obj
				    andSize: size
				  andNItems: nitems];
}








- initWithObject: (id)obj
	 andSize: (size_t)size
       andNItems: (size_t)nitems
{
	if ((self = [super initWithObject: obj])) {
		req_size = size;
		req_items = nitems;













	}

	return self;
}

- (size_t)requestedSize
{







>
>
>
>
>
>
>








>
>
>
>
>
>
>
>
>
>
>
>
>







218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
	andSize: (size_t)size
      andNItems: (size_t)nitems
{
	return [[self alloc] initWithObject: obj
				    andSize: size
				  andNItems: nitems];
}

+ newWithObject: (id)obj
	andSize: (size_t)size
{
	return [[self alloc] initWithObject: obj
				    andSize: size];
}

- initWithObject: (id)obj
	 andSize: (size_t)size
       andNItems: (size_t)nitems
{
	if ((self = [super initWithObject: obj])) {
		req_size = size;
		req_items = nitems;
		has_items = YES;
	}

	return self;
}

- initWithObject: (id)obj
	 andSize: (size_t)size
{
	if ((self = [super initWithObject: obj])) {
		req_size = size;
		req_items = 0;
		has_items = NO;
	}

	return self;
}

- (size_t)requestedSize
{
248
249
250
251
252
253
254

255
256



257
258
259
260
261
262
263
264
265
266
267

268
269



270
271
272
273
274
275
276

@implementation OFReadFailedException
- (char*)cString
{
	if (string != NULL)
		return string;;


	asprintf(&string, "Failed to read %zu items of size %zu in object of "
	    "class %s!", req_items, req_size, [object name]);




	return string;
}
@end

@implementation OFWriteFailedException
- (char*)cString
{
	if (string != NULL)
		return string;


	asprintf(&string, "Failed to write %zu items of size %zu in object of "
	    "class %s!", req_items, req_size, [object name]);




	return string;
}
@end

@implementation OFNotConnectedException
- (char*)cString







>
|
|
>
>
>











>
|
|
>
>
>







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304

@implementation OFReadFailedException
- (char*)cString
{
	if (string != NULL)
		return string;;

	if (has_items)
		asprintf(&string, "Failed to read %zu items of size %zu in "
		    "object of class %s!", req_items, req_size, [object name]);
	else
		asprintf(&string, "Failed to read %zu bytes in object of class "
		    "%s!", req_size, [object name]);

	return string;
}
@end

@implementation OFWriteFailedException
- (char*)cString
{
	if (string != NULL)
		return string;

	if (has_items)
		asprintf(&string, "Failed to write %zu items of size %zu in "
		    "object of class %s!", req_items, req_size, [object name]);
	else
		asprintf(&string, "Failed to write %zu bytes in object of "
		    "class %s!", req_size, [object name]);

	return string;
}
@end

@implementation OFNotConnectedException
- (char*)cString