Changeset 5324

Show
Ignore:
Timestamp:
02/28/08 13:24:33 (4 months ago)
Author:
morris
Message:

Add wi_string_replace_string_with_string()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/libwired/data/wi-string.c

    r5311 r5324  
    891891#pragma mark - 
    892892 
     893void 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 
     904wi_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 
    893917void wi_string_insert_string_at_index(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t index) { 
    894918        _WI_STRING_INDEX_ASSERT(string, index); 
     
    10451069#pragma mark - 
    10461070 
    1047 wi_range_t wi_string_range_of_string(wi_string_t *string, wi_string_t *otherstring, wi_string_options_t options) { 
     1071wi_range_t wi_string_range_of_string(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options) { 
    10481072        return wi_string_range_of_string_in_range(string, otherstring, options, wi_make_range(0, string->length)); 
    10491073} 
     
    10511075 
    10521076 
    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) { 
     1077wi_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) { 
    10541078        wi_range_t              range; 
    10551079         
     
    10661090 
    10671091 
    1068 wi_uinteger_t wi_string_index_of_string(wi_string_t *string, wi_string_t *otherstring, wi_string_options_t options) { 
     1092wi_uinteger_t wi_string_index_of_string(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options) { 
    10691093        return wi_string_index_of_string_in_range(string, otherstring, options, wi_make_range(0, string->length)); 
    10701094} 
     
    10721096 
    10731097 
    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) { 
     1098wi_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) { 
    10751099        char                    *p; 
    10761100        wi_uinteger_t   i, index; 
     
    11091133 
    11101134 
    1111 wi_uinteger_t wi_string_index_of_char(wi_string_t *string, int ch, wi_string_options_t options) { 
     1135wi_uinteger_t wi_string_index_of_char(wi_string_t *string, int ch, wi_uinteger_t options) { 
    11121136        wi_uinteger_t   i, index = WI_NOT_FOUND; 
    11131137        char                    *p; 
     
    11391163  
    11401164 
    1141 wi_boolean_t wi_string_contains_string(wi_string_t *string, wi_string_t *otherstring, wi_string_options_t options) { 
     1165wi_boolean_t wi_string_contains_string(wi_string_t *string, wi_string_t *otherstring, wi_uinteger_t options) { 
    11421166        return (wi_string_index_of_string(string, otherstring, options) != WI_NOT_FOUND); 
    11431167} 
  • libwired/trunk/libwired/data/wi-string.h

    r5310 r5324  
    101101WI_EXPORT wi_string_t *                                         wi_string_by_appending_format_and_arguments(wi_string_t *, wi_string_t *, va_list); 
    102102 
     103WI_EXPORT void                                                          wi_string_replace_string_with_string(wi_string_t *, wi_string_t *, wi_string_t *, wi_uinteger_t); 
     104WI_EXPORT wi_string_t *                                         wi_string_by_replacing_string_with_string(wi_string_t *, wi_string_t *, wi_string_t *, wi_uinteger_t); 
     105 
    103106WI_EXPORT void                                                          wi_string_insert_string_at_index(wi_string_t *, wi_string_t *, wi_uinteger_t); 
    104107 
     
    117120WI_EXPORT wi_array_t *                                          wi_string_components_separated_by_string(wi_string_t *, wi_string_t *); 
    118121 
    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); 
     122WI_EXPORT wi_range_t                                            wi_string_range_of_string(wi_string_t *, wi_string_t *, wi_uinteger_t); 
     123WI_EXPORT wi_range_t                                            wi_string_range_of_string_in_range(wi_string_t *, wi_string_t *, wi_uinteger_t, wi_range_t); 
     124WI_EXPORT wi_uinteger_t                                         wi_string_index_of_string(wi_string_t *, wi_string_t *, wi_uinteger_t); 
     125WI_EXPORT wi_uinteger_t                                         wi_string_index_of_string_in_range(wi_string_t *, wi_string_t *, wi_uinteger_t, wi_range_t); 
     126WI_EXPORT wi_uinteger_t                                         wi_string_index_of_char(wi_string_t *, int, wi_uinteger_t); 
     127WI_EXPORT wi_boolean_t                                          wi_string_contains_string(wi_string_t *, wi_string_t *, wi_uinteger_t); 
    125128WI_EXPORT wi_boolean_t                                          wi_string_has_prefix(wi_string_t *, wi_string_t *); 
    126129WI_EXPORT wi_boolean_t                                          wi_string_has_suffix(wi_string_t *, wi_string_t *);