Changeset 5324
- Timestamp:
- 02/28/08 13:24:33 (4 months ago)
- Files:
-
- libwired/trunk/libwired/data/wi-string.c (modified) (7 diffs)
- libwired/trunk/libwired/data/wi-string.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/data/wi-string.c
r5311 r5324 891 891 #pragma mark - 892 892 893 void wi_string_replace_string_with_string(wi_string_t *string, wi_string_t *target, wi_string_t *replacement, wi_uinteger_t options) { 894 wi_range_t range; 895 896 while((range = wi_string_range_of_string(string, target, options)).location != WI_NOT_FOUND) { 897 wi_string_delete_characters_in_range(string, range); 898 wi_string_insert_string_at_index(string, replacement, range.location); 899 } 900 } 901 902 903 904 wi_string_t * wi_string_by_replacing_string_with_string(wi_string_t *string, wi_string_t *target, wi_string_t *replacement, wi_uinteger_t options) { 905 wi_string_t *newstring; 906 907 newstring = wi_copy(string); 908 wi_string_replace_string_with_string(newstring, target, replacement, options); 909 910 return wi_autorelease(newstring); 911 } 912 913 914 915 #pragma mark - 916 893 917 void wi_string_insert_string_at_index(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t index) { 894 918 _WI_STRING_INDEX_ASSERT(string, index); … … 1045 1069 #pragma mark - 1046 1070 1047 wi_range_t wi_string_range_of_string(wi_string_t *string, wi_string_t *otherstring, wi_ string_options_t options) {1071 wi_range_t wi_string_range_of_string(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options) { 1048 1072 return wi_string_range_of_string_in_range(string, otherstring, options, wi_make_range(0, string->length)); 1049 1073 } … … 1051 1075 1052 1076 1053 wi_range_t wi_string_range_of_string_in_range(wi_string_t *string, wi_string_t *otherstring, wi_ string_options_t options, wi_range_t inrange) {1077 wi_range_t wi_string_range_of_string_in_range(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options, wi_range_t inrange) { 1054 1078 wi_range_t range; 1055 1079 … … 1066 1090 1067 1091 1068 wi_uinteger_t wi_string_index_of_string(wi_string_t *string, wi_string_t *otherstring, wi_ string_options_t options) {1092 wi_uinteger_t wi_string_index_of_string(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options) { 1069 1093 return wi_string_index_of_string_in_range(string, otherstring, options, wi_make_range(0, string->length)); 1070 1094 } … … 1072 1096 1073 1097 1074 wi_uinteger_t wi_string_index_of_string_in_range(wi_string_t *string, wi_string_t *otherstring, wi_ string_options_t options, wi_range_t range) {1098 wi_uinteger_t wi_string_index_of_string_in_range(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options, wi_range_t range) { 1075 1099 char *p; 1076 1100 wi_uinteger_t i, index; … … 1109 1133 1110 1134 1111 wi_uinteger_t wi_string_index_of_char(wi_string_t *string, int ch, wi_ string_options_t options) {1135 wi_uinteger_t wi_string_index_of_char(wi_string_t *string, int ch, wi_uinteger_t options) { 1112 1136 wi_uinteger_t i, index = WI_NOT_FOUND; 1113 1137 char *p; … … 1139 1163 1140 1164 1141 wi_boolean_t wi_string_contains_string(wi_string_t *string, wi_string_t *otherstring, wi_ string_options_t options) {1165 wi_boolean_t wi_string_contains_string(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options) { 1142 1166 return (wi_string_index_of_string(string, otherstring, options) != WI_NOT_FOUND); 1143 1167 } libwired/trunk/libwired/data/wi-string.h
r5310 r5324 101 101 WI_EXPORT wi_string_t * wi_string_by_appending_format_and_arguments(wi_string_t *, wi_string_t *, va_list); 102 102 103 WI_EXPORT void wi_string_replace_string_with_string(wi_string_t *, wi_string_t *, wi_string_t *, wi_uinteger_t); 104 WI_EXPORT wi_string_t * wi_string_by_replacing_string_with_string(wi_string_t *, wi_string_t *, wi_string_t *, wi_uinteger_t); 105 103 106 WI_EXPORT void wi_string_insert_string_at_index(wi_string_t *, wi_string_t *, wi_uinteger_t); 104 107 … … 117 120 WI_EXPORT wi_array_t * wi_string_components_separated_by_string(wi_string_t *, wi_string_t *); 118 121 119 WI_EXPORT wi_range_t wi_string_range_of_string(wi_string_t *, wi_string_t *, wi_ string_options_t);120 WI_EXPORT wi_range_t wi_string_range_of_string_in_range(wi_string_t *, wi_string_t *, wi_ string_options_t, wi_range_t);121 WI_EXPORT wi_uinteger_t wi_string_index_of_string(wi_string_t *, wi_string_t *, wi_ string_options_t);122 WI_EXPORT wi_uinteger_t wi_string_index_of_string_in_range(wi_string_t *, wi_string_t *, wi_ string_options_t, wi_range_t);123 WI_EXPORT wi_uinteger_t wi_string_index_of_char(wi_string_t *, int, wi_ string_options_t);124 WI_EXPORT wi_boolean_t wi_string_contains_string(wi_string_t *, wi_string_t *, wi_ string_options_t);122 WI_EXPORT wi_range_t wi_string_range_of_string(wi_string_t *, wi_string_t *, wi_uinteger_t); 123 WI_EXPORT wi_range_t wi_string_range_of_string_in_range(wi_string_t *, wi_string_t *, wi_uinteger_t, wi_range_t); 124 WI_EXPORT wi_uinteger_t wi_string_index_of_string(wi_string_t *, wi_string_t *, wi_uinteger_t); 125 WI_EXPORT wi_uinteger_t wi_string_index_of_string_in_range(wi_string_t *, wi_string_t *, wi_uinteger_t, wi_range_t); 126 WI_EXPORT wi_uinteger_t wi_string_index_of_char(wi_string_t *, int, wi_uinteger_t); 127 WI_EXPORT wi_boolean_t wi_string_contains_string(wi_string_t *, wi_string_t *, wi_uinteger_t); 125 128 WI_EXPORT wi_boolean_t wi_string_has_prefix(wi_string_t *, wi_string_t *); 126 129 WI_EXPORT wi_boolean_t wi_string_has_suffix(wi_string_t *, wi_string_t *);
