ObjFW  Check-in [7558e235fe]

Overview
Comment:Only allow an OFConstantString as format.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7558e235fe6d22850b95889702cc22c61c3624a84568ac853d17fc1863e9cd9d
User & Date: js on 2011-07-06 22:55:00
Other Links: manifest | tags
Context
2011-07-06
23:27
Some broken glibc versions need -fgnu89-inline... check-in: 521809b613 user: js tags: trunk
22:55
Only allow an OFConstantString as format. check-in: 7558e235fe user: js tags: trunk
22:49
Add +[threadWithBlock:] to OFThread. check-in: d966ede8fe user: js tags: trunk
Changes

Modified src/OFDate.h from [63ca3c4f75] to [a617c5259e].

14
15
16
17
18
19
20

21
22
23
24
25
26
27
 * file.
 */

#import "OFObject.h"
#import "OFSerialization.h"

@class OFString;


/**
 * \brief A class for storing, accessing and comparing dates.
 */
@interface OFDate: OFObject <OFCopying, OFComparing, OFSerialization>
{
	int64_t seconds;







>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 * file.
 */

#import "OFObject.h"
#import "OFSerialization.h"

@class OFString;
@class OFConstantString;

/**
 * \brief A class for storing, accessing and comparing dates.
 */
@interface OFDate: OFObject <OFCopying, OFComparing, OFSerialization>
{
	int64_t seconds;
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
262
263
264
- (uint16_t)localDayOfYear;

/**
 * \brief Creates a string of the date with the specified format.
 *
 * See the manpage for strftime for information on the format.
 *
 * \param fmt The format for the date string
 * \return A new, autoreleased OFString
 */
- (OFString*)dateStringWithFormat: (OFString*)fmt;

/**
 * \brief Creates a string of the local date with the specified format.
 *
 * See the manpage for strftime for information on the format.
 *
 * \param fmt The format for the date string
 * \return A new, autoreleased OFString
 */
- (OFString*)localDateStringWithFormat: (OFString*)fmt;

/**
 * \brief Returns the earlier of the two dates.
 *
 * \param date Another date
 * \return The earlier date of the two dates
 */







|


|






|


|







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
- (uint16_t)localDayOfYear;

/**
 * \brief Creates a string of the date with the specified format.
 *
 * See the manpage for strftime for information on the format.
 *
 * \param format The format for the date string
 * \return A new, autoreleased OFString
 */
- (OFString*)dateStringWithFormat: (OFConstantString*)format;

/**
 * \brief Creates a string of the local date with the specified format.
 *
 * See the manpage for strftime for information on the format.
 *
 * \param format The format for the date string
 * \return A new, autoreleased OFString
 */
- (OFString*)localDateStringWithFormat: (OFConstantString*)format;

/**
 * \brief Returns the earlier of the two dates.
 *
 * \param date Another date
 * \return The earlier date of the two dates
 */

Modified src/OFDate.m from [884edb1d64] to [eec5fc6376].

439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
}

- (uint16_t)localDayOfYear
{
	LOCALTIME_RET(tm_yday + 1)
}

- (OFString*)dateStringWithFormat: (OFString*)format
{
	OFString *ret;
	time_t seconds_ = (time_t)seconds;
	struct tm tm;
	char *buffer;

	if (seconds != seconds_)







|







439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
}

- (uint16_t)localDayOfYear
{
	LOCALTIME_RET(tm_yday + 1)
}

- (OFString*)dateStringWithFormat: (OFConstantString*)format
{
	OFString *ret;
	time_t seconds_ = (time_t)seconds;
	struct tm tm;
	char *buffer;

	if (seconds != seconds_)
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;
}

- (OFString*)localDateStringWithFormat: (OFString*)format
{
	OFString *ret;
	time_t seconds_ = (time_t)seconds;
	struct tm tm;
	char *buffer;

	if (seconds != seconds_)







|







485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
	} @finally {
		[self freeMemory: buffer];
	}

	return ret;
}

- (OFString*)localDateStringWithFormat: (OFConstantString*)format
{
	OFString *ret;
	time_t seconds_ = (time_t)seconds;
	struct tm tm;
	char *buffer;

	if (seconds != seconds_)

Modified src/OFMutableString.h from [109265f25d] to [1f0a784977].

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
 * \brief Appends a formatted string to the OFMutableString.
 *
 * See printf for the format syntax.
 *
 * \param format A format string which generates the string to append
 */
- (void)appendFormat: (OFString*)format, ...;

/**
 * \brief Appends a formatted string to the OFMutableString.
 *
 * See printf for the format syntax.
 *
 * \param format A format string which generates the string to append
 * \param arguments The arguments used in the format string
 */
- (void)appendFormat: (OFString*)format
       withArguments: (va_list)arguments;

/**
 * \brief Prepends another OFString to the OFMutableString.
 *
 * \param string An OFString to prepend
 */







|









|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
 * \brief Appends a formatted string to the OFMutableString.
 *
 * See printf for the format syntax.
 *
 * \param format A format string which generates the string to append
 */
- (void)appendFormat: (OFConstantString*)format, ...;

/**
 * \brief Appends a formatted string to the OFMutableString.
 *
 * See printf for the format syntax.
 *
 * \param format A format string which generates the string to append
 * \param arguments The arguments used in the format string
 */
- (void)appendFormat: (OFConstantString*)format
       withArguments: (va_list)arguments;

/**
 * \brief Prepends another OFString to the OFMutableString.
 *
 * \param string An OFString to prepend
 */

Modified src/OFMutableString.m from [a73fb6b373] to [9305a9d8ab].

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
	if (string_ == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	[self appendCString: [string_ cString]];
}

- (void)appendFormat: (OFString*)format, ...
{
	va_list arguments;

	va_start(arguments, format);
	[self appendFormat: format
	     withArguments: arguments];
	va_end(arguments);
}

- (void)appendFormat: (OFString*)format
       withArguments: (va_list)arguments
{
	char *t;
	int len;

	if (format == nil)
		@throw [OFInvalidArgumentException newWithClass: isa







|









|







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
	if (string_ == nil)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	[self appendCString: [string_ cString]];
}

- (void)appendFormat: (OFConstantString*)format, ...
{
	va_list arguments;

	va_start(arguments, format);
	[self appendFormat: format
	     withArguments: arguments];
	va_end(arguments);
}

- (void)appendFormat: (OFConstantString*)format
       withArguments: (va_list)arguments
{
	char *t;
	int len;

	if (format == nil)
		@throw [OFInvalidArgumentException newWithClass: isa

Modified src/OFStream.h from [4293607bf6] to [a5c5c3482e].

668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691

/**
 * Writes a formatted string into the stream.
 *
 * \param format A string used as format
 * \return The number of bytes written
 */
- (size_t)writeFormat: (OFString*)format, ...;

/**
 * Writes a formatted string into the stream.
 *
 * \param format A string used as format
 * \param arguments The arguments used in the format string
 * \return The number of bytes written
 */
- (size_t)writeFormat: (OFString*)format
	withArguments: (va_list)arguments;

/**
 * \return The number of bytes still present in the internal cache.
 */
- (size_t)pendingBytes;








|








|







668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691

/**
 * Writes a formatted string into the stream.
 *
 * \param format A string used as format
 * \return The number of bytes written
 */
- (size_t)writeFormat: (OFConstantString*)format, ...;

/**
 * Writes a formatted string into the stream.
 *
 * \param format A string used as format
 * \param arguments The arguments used in the format string
 * \return The number of bytes written
 */
- (size_t)writeFormat: (OFConstantString*)format
	withArguments: (va_list)arguments;

/**
 * \return The number of bytes still present in the internal cache.
 */
- (size_t)pendingBytes;

Modified src/OFStream.m from [31bd6101f0] to [c34080c5bb].

1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
	} @finally {
		[self freeMemory: buffer];
	}

	return stringLength + 1;
}

- (size_t)writeFormat: (OFString*)format, ...
{
	va_list arguments;
	size_t ret;

	va_start(arguments, format);
	ret = [self writeFormat: format
		  withArguments: arguments];
	va_end(arguments);

	return ret;
}

- (size_t)writeFormat: (OFString*)format
	withArguments: (va_list)arguments
{
	char *cString;
	int length;

	if (format == nil)
		@throw [OFInvalidArgumentException newWithClass: isa







|












|







1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
	} @finally {
		[self freeMemory: buffer];
	}

	return stringLength + 1;
}

- (size_t)writeFormat: (OFConstantString*)format, ...
{
	va_list arguments;
	size_t ret;

	va_start(arguments, format);
	ret = [self writeFormat: format
		  withArguments: arguments];
	va_end(arguments);

	return ret;
}

- (size_t)writeFormat: (OFConstantString*)format
	withArguments: (va_list)arguments
{
	char *cString;
	int length;

	if (format == nil)
		@throw [OFInvalidArgumentException newWithClass: isa

Modified src/OFString.h from [e4ec21f536] to [62caae6241].

16
17
18
19
20
21
22


23
24
25
26
27
28
29

#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>

#import "OFObject.h"
#import "OFSerialization.h"



typedef uint32_t of_unichar_t;

/**
 * \brief The encoding of a string.
 */
typedef enum of_string_encoding_t {







>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>

#import "OFObject.h"
#import "OFSerialization.h"

@class OFConstantString;

typedef uint32_t of_unichar_t;

/**
 * \brief The encoding of a string.
 */
typedef enum of_string_encoding_t {
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/**
 * Creates a new OFString from a format string.
 * See printf for the format syntax.
 *
 * \param format A string used as format to initialize the OFString
 * \return A new autoreleased OFString
 */
+ stringWithFormat: (OFString*)format, ...;

/**
 * Creates a new OFString containing the constructed specified path.
 *
 * \param firstComponent The first component of the path
 * \return A new autoreleased OFString
 */







|







207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/**
 * Creates a new OFString from a format string.
 * See printf for the format syntax.
 *
 * \param format A string used as format to initialize the OFString
 * \return A new autoreleased OFString
 */
+ stringWithFormat: (OFConstantString*)format, ...;

/**
 * Creates a new OFString containing the constructed specified path.
 *
 * \param firstComponent The first component of the path
 * \return A new autoreleased OFString
 */
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/**
 * Initializes an already allocated OFString with a format string.
 * See printf for the format syntax.
 *
 * \param format A string used as format to initialize the OFString
 * \return An initialized OFString
 */
- initWithFormat: (OFString*)format, ...;

/**
 * Initializes an already allocated OFString with a format string.
 * See printf for the format syntax.
 *
 * \param format A string used as format to initialize the OFString
 * \param arguments The arguments used in the format string
 * \return An initialized OFString
 */
- initWithFormat: (OFString*)format
       arguments: (va_list)arguments;

/**
 * Initializes an already allocated OFString with the constructed specified
 * path.
 *
 * \param firstComponent The first component of the path







|









|







405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
/**
 * Initializes an already allocated OFString with a format string.
 * See printf for the format syntax.
 *
 * \param format A string used as format to initialize the OFString
 * \return An initialized OFString
 */
- initWithFormat: (OFConstantString*)format, ...;

/**
 * Initializes an already allocated OFString with a format string.
 * See printf for the format syntax.
 *
 * \param format A string used as format to initialize the OFString
 * \param arguments The arguments used in the format string
 * \return An initialized OFString
 */
- initWithFormat: (OFConstantString*)format
       arguments: (va_list)arguments;

/**
 * Initializes an already allocated OFString with the constructed specified
 * path.
 *
 * \param firstComponent The first component of the path

Modified src/OFString.m from [88ca1bcd74] to [de837b0b69].

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
		 length: (size_t)length
{
	return [[[self alloc] initWithUTF16String: string
					byteOrder: byteOrder
					   length: length] autorelease];
}

+ stringWithFormat: (OFString*)format, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, format);
	ret = [[[self alloc] initWithFormat: format
				  arguments: arguments] autorelease];







|







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
		 length: (size_t)length
{
	return [[[self alloc] initWithUTF16String: string
					byteOrder: byteOrder
					   length: length] autorelease];
}

+ stringWithFormat: (OFConstantString*)format, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, format);
	ret = [[[self alloc] initWithFormat: format
				  arguments: arguments] autorelease];
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
		[self release];
		@throw e;
	}

	return self;
}

- initWithFormat: (OFString*)format, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, format);
	ret = [self initWithFormat: format
			 arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithFormat: (OFString*)format
       arguments: (va_list)arguments
{
	self = [super init];

	@try {
		int len;








|












|







832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
		[self release];
		@throw e;
	}

	return self;
}

- initWithFormat: (OFConstantString*)format, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, format);
	ret = [self initWithFormat: format
			 arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithFormat: (OFConstantString*)format
       arguments: (va_list)arguments
{
	self = [super init];

	@try {
		int len;