ObjFW  Diff

Differences From Artifact [780687227d]:

To Artifact [e5f7685ba0]:


132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
132
133
134
135
136
137
138

139
140
141
142
143
144
145
146







-
+







 */
typedef void (^OFStringLineEnumerationBlock)(OFString *line, bool *stop);
#endif

#ifdef __OBJC__
@class OFArray OF_GENERIC(ObjectType);
@class OFCharacterSet;
@class OFURI;
@class OFIRI;

/**
 * @class OFString OFString.h ObjFW/OFString.h
 *
 * @brief A class for handling strings.
 */
@interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing,
551
552
553
554
555
556
557
558

559
560

561
562

563
564
565
566

567
568
569
570

571
572
573

574
575
576

577
578
579
580
581

582
583
584
585
586
587
588
551
552
553
554
555
556
557

558
559

560
561

562
563
564
565

566
567
568
569

570
571
572

573
574
575

576
577
578
579
580

581
582
583
584
585
586
587
588







-
+

-
+

-
+



-
+



-
+


-
+


-
+




-
+







 * @throw OFInvalidEncodingException The string is not in the specified encoding
 */
+ (instancetype)stringWithContentsOfFile: (OFString *)path
				encoding: (OFStringEncoding)encoding;
# endif

/**
 * @brief Creates a new OFString with the contents of the specified URI.
 * @brief Creates a new OFString with the contents of the specified IRI.
 *
 * If the URI's scheme is file, it tries UTF-8 encoding.
 * If the IRI's scheme is file, it tries UTF-8 encoding.
 *
 * If the URI's scheme is http(s), it tries to detect the encoding from the HTTP
 * If the IRI's scheme is http(s), it tries to detect the encoding from the HTTP
 * headers. If it could not detect the encoding using the HTTP headers, it tries
 * UTF-8.
 *
 * @param URI The URI to the contents for the string
 * @param IRI The IRI to the contents for the string
 * @return A new autoreleased OFString
 * @throw OFInvalidEncodingException The string is not in the expected encoding
 */
+ (instancetype)stringWithContentsOfURI: (OFURI *)URI;
+ (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI;

/**
 * @brief Creates a new OFString with the contents of the specified URI in the
 * @brief Creates a new OFString with the contents of the specified IRI in the
 *	  specified encoding.
 *
 * @param URI The URI to the contents for the string
 * @param IRI The IRI to the contents for the string
 * @param encoding The encoding to assume
 * @return A new autoreleased OFString
 * @throw OFInvalidEncodingException The string is not in the specified encoding
 */
+ (instancetype)stringWithContentsOfURI: (OFURI *)URI
+ (instancetype)stringWithContentsOfIRI: (OFIRI *)IRI
			       encoding: (OFStringEncoding)encoding;

/**
 * @brief Initializes an already allocated OFString from a UTF-8 encoded C
 *	  string.
 *
 * @param UTF8String A UTF-8 encoded C string to initialize the OFString with
845
846
847
848
849
850
851
852

853
854

855
856

857
858
859
860

861
862
863
864

865
866
867
868

869
870

871
872
873
874
875

876
877
878
879
880
881
882
845
846
847
848
849
850
851

852
853

854
855

856
857
858
859

860
861
862
863

864
865
866
867

868
869

870
871
872
873
874

875
876
877
878
879
880
881
882







-
+

-
+

-
+



-
+



-
+



-
+

-
+




-
+







 */
- (instancetype)initWithContentsOfFile: (OFString *)path
			      encoding: (OFStringEncoding)encoding;
# endif

/**
 * @brief Initializes an already allocated OFString with the contents of the
 *	  specified URI.
 *	  specified IRI.
 *
 * If the URI's scheme is file, it tries UTF-8 encoding.
 * If the IRI's scheme is file, it tries UTF-8 encoding.
 *
 * If the URI's scheme is http(s), it tries to detect the encoding from the HTTP
 * If the IRI's scheme is http(s), it tries to detect the encoding from the HTTP
 * headers. If it could not detect the encoding using the HTTP headers, it tries
 * UTF-8.
 *
 * @param URI The URI to the contents for the string
 * @param IRI The IRI to the contents for the string
 * @return An initialized OFString
 * @throw OFInvalidEncodingException The string is not in the expected encoding
 */
- (instancetype)initWithContentsOfURI: (OFURI *)URI;
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI;

/**
 * @brief Initializes an already allocated OFString with the contents of the
 *	  specified URI in the specified encoding.
 *	  specified IRI in the specified encoding.
 *
 * @param URI The URI to the contents for the string
 * @param IRI The IRI to the contents for the string
 * @param encoding The encoding to assume
 * @return An initialized OFString
 * @throw OFInvalidEncodingException The string is not in the specified encoding
 */
- (instancetype)initWithContentsOfURI: (OFURI *)URI
- (instancetype)initWithContentsOfIRI: (OFIRI *)IRI
			     encoding: (OFStringEncoding)encoding;

/**
 * @brief Writes the OFString into the specified C string with the specified
 *	  encoding.
 *
 * @param cString The C string to write into
1303
1304
1305
1306
1307
1308
1309
1310

1311
1312

1313
1314

1315
1316
1317

1318
1319
1320


1321
1322
1323
1324

1325
1326
1327
1328
1329
1330
1331
1303
1304
1305
1306
1307
1308
1309

1310
1311

1312
1313

1314
1315
1316

1317
1318


1319
1320
1321
1322
1323

1324
1325
1326
1327
1328
1329
1330
1331







-
+

-
+

-
+


-
+

-
-
+
+



-
+







 * @throw OFInvalidEncodingException The string cannot be represented in the
 *				     specified encoding
 */
- (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding;
# endif

/**
 * @brief Writes the string to the specified URI using UTF-8 encoding.
 * @brief Writes the string to the specified IRI using UTF-8 encoding.
 *
 * @param URI The URI to write to
 * @param IRI The IRI to write to
 */
- (void)writeToURI: (OFURI *)URI;
- (void)writeToIRI: (OFIRI *)IRI;

/**
 * @brief Writes the string to the specified URI using the specified encoding.
 * @brief Writes the string to the specified IRI using the specified encoding.
 *
 * @param URI The URI to write to
 * @param encoding The encoding to use to write the string to the URI
 * @param IRI The IRI to write to
 * @param encoding The encoding to use to write the string to the IRI
 * @throw OFInvalidEncodingException The string cannot be represented in the
 *				     specified encoding
 */
- (void)writeToURI: (OFURI *)URI encoding: (OFStringEncoding)encoding;
- (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding;

# ifdef OF_HAVE_BLOCKS
/**
 * Enumerates all lines in the receiver using the specified block.
 *
 * @brief block The block to call for each line
 */