ObjFW  Diff

Differences From Artifact [1cf435b925]:

To Artifact [25f3180e0b]:


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#endif

@class OFArray;
@class OFURL;

/**
 * \brief A class for handling strings.
 *
 * <b>Warning:</b> If you add methods to OFString using a category, you are not
 * allowed to access the ivars directly, as these might be still uninitialized
 * for a constant string and get initialized on the first message! Therefore,
 * you should use the corresponding methods to get the ivars, which ensures the
 * constant string is initialized.
 */
@interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing,
    OFSerialization, OFJSONRepresentation>
#ifdef OF_HAVE_PROPERTIES
@property (readonly) size_t length;
#endif








<
<
<
<
<
<







71
72
73
74
75
76
77






78
79
80
81
82
83
84
#endif

@class OFArray;
@class OFURL;

/**
 * \brief A class for handling strings.






 */
@interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing,
    OFSerialization, OFJSONRepresentation>
#ifdef OF_HAVE_PROPERTIES
@property (readonly) size_t length;
#endif

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 */
+ (instancetype)stringWithUTF8String: (const char*)UTF8String
			      length: (size_t)UTF8StringLength;

/**
 * \brief Creates a new OFString from a C string with the specified encoding.
 *
 * \param string A C string to initialize the OFString with
 * \param encoding The encoding of the C string
 * \return A new autoreleased OFString
 */
+ (instancetype)stringWithCString: (const char*)cString
			 encoding: (of_string_encoding_t)encoding;

/**







|







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 */
+ (instancetype)stringWithUTF8String: (const char*)UTF8String
			      length: (size_t)UTF8StringLength;

/**
 * \brief Creates a new OFString from a C string with the specified encoding.
 *
 * \param cString A C string to initialize the OFString with
 * \param encoding The encoding of the C string
 * \return A new autoreleased OFString
 */
+ (instancetype)stringWithCString: (const char*)cString
			 encoding: (of_string_encoding_t)encoding;

/**
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259

/**
 * \brief Creates a new OFString containing the constructed specified path.
 *
 * \param firstComponent The first component of the path
 * \return A new autoreleased OFString
 */
+ (instancetype)stringWithPath: (OFString*)firstComponent, ...;

/**
 * \brief Creates a new OFString with the contents of the specified UTF-8
 *	  encoded file.
 *
 * \param path The path to the file
 * \return A new autoreleased OFString







|







239
240
241
242
243
244
245
246
247
248
249
250
251
252
253

/**
 * \brief Creates a new OFString containing the constructed specified path.
 *
 * \param firstComponent The first component of the path
 * \return A new autoreleased OFString
 */
+ (instancetype)stringWithPath: (OFString*)firstComponent, ... OF_SENTINEL;

/**
 * \brief Creates a new OFString with the contents of the specified UTF-8
 *	  encoded file.
 *
 * \param path The path to the file
 * \return A new autoreleased OFString
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
/**
 * \brief Initializes an already allocated OFString with the constructed
 *	  specified path.
 *
 * \param firstComponent The first component of the path
 * \return A new autoreleased OFString
 */
- initWithPath: (OFString*)firstComponent, ...;

/**
 * \brief Initializes an already allocated OFString with the constructed
 *	  specified path.
 *
 * \param firstComponent The first component of the path
 * \param arguments A va_list with the other components of the path







|







471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/**
 * \brief Initializes an already allocated OFString with the constructed
 *	  specified path.
 *
 * \param firstComponent The first component of the path
 * \return A new autoreleased OFString
 */
- initWithPath: (OFString*)firstComponent, ... OF_SENTINEL;

/**
 * \brief Initializes an already allocated OFString with the constructed
 *	  specified path.
 *
 * \param firstComponent The first component of the path
 * \param arguments A va_list with the other components of the path
624
625
626
627
628
629
630
631

632
633
634
635
636
637
638
639
640
641
642
643

644
645
646
647
648
649
650
- (of_range_t)rangeOfString: (OFString*)string;

/**
 * \brief Returns the range of the string.
 *
 * \param string The string to search
 * \param options Options modifying search behaviour.
 *		  Possible values: OF_STRING_SEARCH_BACKWARDS

 * \return The range of the first occurrence of the string or a range with
 *	   OF_NOT_FOUND as start position if it was not found
 */
- (of_range_t)rangeOfString: (OFString*)string
		    options: (int)options;

/**
 * \brief Returns the range of the string in the specified range.
 *
 * \param string The string to search
 * \param options Options modifying search behaviour.
 *		  Possible values: OF_STRING_SEARCH_BACKWARDS

 * \param range The range in which to search
 * \return The range of the first occurrence of the string or a range with
 *	   OF_NOT_FOUND as start position if it was not found
 */
- (of_range_t)rangeOfString: (OFString*)string
		    options: (int)options
		      range: (of_range_t)range;







|
>











|
>







618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
- (of_range_t)rangeOfString: (OFString*)string;

/**
 * \brief Returns the range of the string.
 *
 * \param string The string to search
 * \param options Options modifying search behaviour.
 *		  Possible values:
 *		    * OF_STRING_SEARCH_BACKWARDS
 * \return The range of the first occurrence of the string or a range with
 *	   OF_NOT_FOUND as start position if it was not found
 */
- (of_range_t)rangeOfString: (OFString*)string
		    options: (int)options;

/**
 * \brief Returns the range of the string in the specified range.
 *
 * \param string The string to search
 * \param options Options modifying search behaviour.
 *		  Possible values:
 *		    * OF_STRING_SEARCH_BACKWARDS
 * \param range The range in which to search
 * \return The range of the first occurrence of the string or a range with
 *	   OF_NOT_FOUND as start position if it was not found
 */
- (of_range_t)rangeOfString: (OFString*)string
		    options: (int)options
		      range: (of_range_t)range;
703
704
705
706
707
708
709
710

711
712
713
714
715
716
717
/**
 * \brief Creates a new string by replacing the occurrences of the specified
 *	  string in the specified range with the specified replacement.
 *
 * \param string The string to replace
 * \param replacement The string with which it should be replaced
 * \param options Options modifying search behaviour.
 *		  Possible values: None yet

 * \param range The range in which to replace the string
 * \return A new string with the occurrences of the specified string replaced
 */
- (OFString*)stringByReplacingOccurrencesOfString: (OFString*)string
				       withString: (OFString*)replacement
					  options: (int)options
					    range: (of_range_t)range;







|
>







699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
/**
 * \brief Creates a new string by replacing the occurrences of the specified
 *	  string in the specified range with the specified replacement.
 *
 * \param string The string to replace
 * \param replacement The string with which it should be replaced
 * \param options Options modifying search behaviour.
 *		  Possible values:
 *		    * None yet
 * \param range The range in which to replace the string
 * \return A new string with the occurrences of the specified string replaced
 */
- (OFString*)stringByReplacingOccurrencesOfString: (OFString*)string
				       withString: (OFString*)replacement
					  options: (int)options
					    range: (of_range_t)range;
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
 * \return The string in lowercase
 */
- (OFString*)lowercaseString;

/**
 * \brief Returns the string capitalized.
 *
 * \note This only considers spaces, tab and newlines to be word delimiters!
 *	 Also note that this might change in the future to all word delimiters
 *	 specified by Unicode!
 *
 * \return The capitalized string
 */
- (OFString*)capitalizedString;








|







726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
 * \return The string in lowercase
 */
- (OFString*)lowercaseString;

/**
 * \brief Returns the string capitalized.
 *
 * \note This only considers spaces, tabs and newlines to be word delimiters!
 *	 Also note that this might change in the future to all word delimiters
 *	 specified by Unicode!
 *
 * \return The capitalized string
 */
- (OFString*)capitalizedString;

787
788
789
790
791
792
793
794
795

796
797
798
799
800
801
802
 */
- (OFArray*)componentsSeparatedByString: (OFString*)delimiter;

/**
 * \brief Separates an OFString into an OFArray of OFStrings.
 *
 * \param delimiter The delimiter for separating
 * \param options Options according to which the string should be separated
 * 		  Possible values: OF_STRING_SKIP_EMPTY

 * \return An autoreleased OFArray with the separated string
 */
- (OFArray*)componentsSeparatedByString: (OFString*)delimiter
				options: (int)options;

/**
 * \brief Returns the components of the path.







|
|
>







784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
 */
- (OFArray*)componentsSeparatedByString: (OFString*)delimiter;

/**
 * \brief Separates an OFString into an OFArray of OFStrings.
 *
 * \param delimiter The delimiter for separating
 * \param options Options according to which the string should be separated.
 * 		  Possible values:
 * 		    * OF_STRING_SKIP_EMPTY
 * \return An autoreleased OFArray with the separated string
 */
- (OFArray*)componentsSeparatedByString: (OFString*)delimiter
				options: (int)options;

/**
 * \brief Returns the components of the path.