ObjFW  Check-in [9aacc26542]

Overview
Comment:Add +[OFString stringWithData:encoding:]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9aacc26542a6917a63475a6e391313abf9cc9344d3e4f2ebd03b39091d64c775
User & Date: js on 2017-07-23 17:55:16
Other Links: manifest | tags
Context
2017-07-23
18:02
Add -[OFString dataWithEncoding:] check-in: db06863643 user: js tags: trunk
17:55
Add +[OFString stringWithData:encoding:] check-in: 9aacc26542 user: js tags: trunk
2017-07-22
23:04
OFFile: Simplify mode check-in: 23e57c5040 user: js tags: trunk
Changes

Modified src/OFString.h from [2abf4074c0] to [89bf3fd41c].

164
165
166
167
168
169
170










171
172
173
174
175
176
177
 * @param cStringLength The length of the C string
 * @return A new autoreleased OFString
 */
+ (instancetype)stringWithCString: (const char *)cString
			 encoding: (of_string_encoding_t)encoding
			   length: (size_t)cStringLength;











/*!
 * @brief Creates a new OFString from another string.
 *
 * @param string A string to initialize the OFString with
 * @return A new autoreleased OFString
 */
+ (instancetype)stringWithString: (OFString *)string;







>
>
>
>
>
>
>
>
>
>







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
 * @param cStringLength The length of the C string
 * @return A new autoreleased OFString
 */
+ (instancetype)stringWithCString: (const char *)cString
			 encoding: (of_string_encoding_t)encoding
			   length: (size_t)cStringLength;

/*!
 * @brief Creates a new OFString from OFData with the specified encoding.
 *
 * @param data OFData with the contents of the string
 * @param encoding The encoding in which the string is stored in the OFData
 * @return An new autoreleased OFString
 */
+ (instancetype)stringWithData: (OFData *)data
		      encoding: (of_string_encoding_t)encoding;

/*!
 * @brief Creates a new OFString from another string.
 *
 * @param string A string to initialize the OFString with
 * @return A new autoreleased OFString
 */
+ (instancetype)stringWithString: (OFString *)string;
398
399
400
401
402
403
404











405
406
407
408
409
410
411
 * @param cStringLength The length of the C string
 * @return An initialized OFString
 */
- initWithCString: (const char *)cString
	 encoding: (of_string_encoding_t)encoding
	   length: (size_t)cStringLength;












/*!
 * @brief Initializes an already allocated OFString with another string.
 *
 * @param string A string to initialize the OFString with
 * @return An initialized OFString
 */
- initWithString: (OFString *)string;







>
>
>
>
>
>
>
>
>
>
>







408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
 * @param cStringLength The length of the C string
 * @return An initialized OFString
 */
- initWithCString: (const char *)cString
	 encoding: (of_string_encoding_t)encoding
	   length: (size_t)cStringLength;

/*!
 * @brief Initializes an already allocated OFString from OFData with the
 *	  specified encoding.
 *
 * @param data OFData with the contents of the string
 * @param encoding The encoding in which the string is stored in the OFData
 * @return An initialized OFString
 */
- initWithData: (OFData *)data
      encoding: (of_string_encoding_t)encoding;

/*!
 * @brief Initializes an already allocated OFString with another string.
 *
 * @param string A string to initialize the OFString with
 * @return An initialized OFString
 */
- initWithString: (OFString *)string;

Modified src/OFString.m from [18c9b8230b] to [3b9b1e2811].

465
466
467
468
469
470
471







472
473
474
475
476
477
478
						 storage: storage];
	}

	return (id)[[OFString_UTF8 alloc] initWithCString: cString
						 encoding: encoding
						   length: cStringLength];
}








- initWithString: (OFString *)string
{
	return (id)[[OFString_UTF8 alloc] initWithString: string];
}

- initWithCharacters: (const of_unichar_t *)string







>
>
>
>
>
>
>







465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
						 storage: storage];
	}

	return (id)[[OFString_UTF8 alloc] initWithCString: cString
						 encoding: encoding
						   length: cStringLength];
}

- initWithData: (OFData *)data
      encoding: (of_string_encoding_t)encoding
{
	return (id)[[OFString_UTF8 alloc] initWithData: data
					      encoding: encoding];
}

- initWithString: (OFString *)string
{
	return (id)[[OFString_UTF8 alloc] initWithString: string];
}

- initWithCharacters: (const of_unichar_t *)string
671
672
673
674
675
676
677







678
679
680
681
682
683
684
			 encoding: (of_string_encoding_t)encoding
			   length: (size_t)cStringLength
{
	return [[[self alloc] initWithCString: cString
				     encoding: encoding
				       length: cStringLength] autorelease];
}








+ (instancetype)stringWithString: (OFString *)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

+ (instancetype)stringWithCharacters: (const of_unichar_t *)string







>
>
>
>
>
>
>







678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
			 encoding: (of_string_encoding_t)encoding
			   length: (size_t)cStringLength
{
	return [[[self alloc] initWithCString: cString
				     encoding: encoding
				       length: cStringLength] autorelease];
}

+ (instancetype)stringWithData: (OFData *)data
		      encoding: (of_string_encoding_t)encoding
{
	return [[[self alloc] initWithData: data
				  encoding: encoding] autorelease];
}

+ (instancetype)stringWithString: (OFString *)string
{
	return [[[self alloc] initWithString: string] autorelease];
}

+ (instancetype)stringWithCharacters: (const of_unichar_t *)string
849
850
851
852
853
854
855


















856
857
858
859
860
861
862

- initWithCString: (const char *)cString
	 encoding: (of_string_encoding_t)encoding
	   length: (size_t)cStringLength
{
	OF_INVALID_INIT_METHOD
}



















- initWithString: (OFString *)string
{
	OF_INVALID_INIT_METHOD
}

- initWithCharacters: (const of_unichar_t *)string







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







863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894

- initWithCString: (const char *)cString
	 encoding: (of_string_encoding_t)encoding
	   length: (size_t)cStringLength
{
	OF_INVALID_INIT_METHOD
}

- initWithData: (OFData *)data
      encoding: (of_string_encoding_t)encoding
{
	@try {
		if ([data itemSize] != 1)
			@throw [OFInvalidArgumentException exception];

		self = [self initWithCString: [data items]
				    encoding: encoding
				      length: [data count]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- initWithString: (OFString *)string
{
	OF_INVALID_INIT_METHOD
}

- initWithCharacters: (const of_unichar_t *)string