note description: "A low-level string class to solve some garbage collector problems (mainly objects moving around) when interfacing with C APIs." library: "Free implementation of ELKS library" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date: 2020-05-19 14:23:13 +0000 (Tue, 19 May 2020) $" revision: "$Revision: 104257 $" class interface C_STRING create make, make_empty, make_by_pointer, make_by_pointer_and_count, make_shared_from_pointer, make_shared_from_pointer_and_count, own_from_pointer, own_from_pointer_and_count feature -- Initialization set_shared_from_pointer (a_ptr: POINTER) -- Share a_ptr. require a_ptr_not_null: a_ptr /= default_pointer set_shared_from_pointer_and_count (a_ptr: POINTER; a_length: INTEGER_32) -- Share a_ptr of a_length byte. require a_ptr_not_null: a_ptr /= default_pointer a_length_non_negative: a_length >= 0 feature -- Access substring (start_pos, end_pos: INTEGER_32): STRING_8 -- Copy of substring containing all characters at indices -- between start_pos and end_pos. require start_position_big_enough: start_pos >= 1 end_position_big_enough: start_pos <= end_pos + 1 end_position_not_too_big: end_pos <= capacity ensure susbstring_not_void: Result /= Void substring_8 (start_pos, end_pos: INTEGER_32): STRING_8 -- Copy of substring containing all characters at indices -- between start_pos and end_pos. require start_position_big_enough: start_pos >= 1 end_position_big_enough: start_pos <= end_pos + 1 end_position_not_too_big: end_pos <= capacity ensure susbstring_not_void: Result /= Void string: STRING_8 -- Eiffel string, ignoring count. Reads until a null character is being read. ensure string_not_void: Result /= Void string_8: STRING_8 -- Eiffel string, ignoring count. Reads until a null character is being read. ensure string_not_void: Result /= Void copy_to_string (a_string: STRING_GENERAL; source_index, destination_index, n: INTEGER_32) -- Copy n characters of Current from source_index position to a_string at -- destination_index. Other characters of a_string remain unchanged. require a_string_not_void: a_string /= Void source_index_positive: source_index >= 1 destination_index_positive: destination_index >= 1 n_non_negative: n >= 0 n_is_small_enough_for_source: source_index + (n - 1) <= capacity n_is_small_enough_for_destination: destination_index + (n - 1) <= a_string.count read_substring_into (a_string: STRING_GENERAL; start_pos, end_pos: INTEGER_32) -- Copy of substring containing all characters at indices -- between start_pos and end_pos into a_string. require a_string_not_void: a_string /= Void start_position_big_enough: start_pos >= 1 end_position_big_enough: start_pos <= end_pos + 1 end_position_not_too_big: end_pos <= capacity a_string_large_enough: a_string.count >= end_pos - start_pos + 1 read_string_into (a_string: STRING_GENERAL) -- Copy of substring containing all characters at indices -- between start_pos and end_pos into a_string replacing any -- existing characters. require a_string_not_void: a_string /= Void a_string_large_enough: a_string.count >= count read_substring_into_character_8_area (a_area: SPECIAL [CHARACTER_8]; start_pos, end_pos: INTEGER_32) -- Copy of substring containing all characters at indices -- between start_pos and end_pos into a_area. require a_area_not_void: a_area /= Void start_position_big_enough: start_pos >= 1 end_position_big_enough: start_pos <= end_pos + 1 end_position_not_too_big: end_pos <= capacity a_area_large_enough: a_area.count >= end_pos - start_pos + 1 ensure copied: read_substring_into_character_32_area (a_area: SPECIAL [CHARACTER_32]; start_pos, end_pos: INTEGER_32) -- Copy of substring containing all characters at indices -- between start_pos and end_pos into a_area. require a_area_not_void: a_area /= Void start_position_big_enough: start_pos >= 1 end_position_big_enough: start_pos <= end_pos + 1 end_position_not_too_big: end_pos <= capacity a_area_large_enough: a_area.count >= end_pos - start_pos + 1 ensure copied: read_unicode_substring_into_character_32_area (a_area: SPECIAL [CHARACTER_32]; start_pos, end_pos: INTEGER_32) -- Copy of Unicode substring containing all characters at indices -- between start_pos and end_pos into a_area. require a_area_not_void: a_area /= Void start_position_big_enough: start_pos >= 1 end_position_big_enough: start_pos <= end_pos + 1 end_position_not_too_big: end_pos <= capacity a_area_large_enough: a_area.count >= end_pos - start_pos + 1 item: POINTER -- Get pointer to allocated area. ensure item_not_null: Result /= default_pointer managed_data: MANAGED_POINTER -- Hold data of Current. feature -- Measurement capacity: INTEGER_32 -- Number of characters in Current. bytes_count: INTEGER_32 -- Number of bytes represented by the string. count: INTEGER_32 -- Number of characters in Current. Character_size: INTEGER_32 = 1 -- Size of a character feature -- Element change set_string (a_string: READABLE_STRING_GENERAL) -- Set string with a_string. require a_string_not_void: a_string /= Void a_string_is_string_8: a_string.is_valid_as_string_8 set_substring (a_string: READABLE_STRING_GENERAL; start_pos, end_pos: INTEGER_32) -- Set string with a_string. require a_string_not_void: a_string /= Void start_position_big_enough: start_pos >= 1 end_position_big_enough: start_pos <= end_pos + 1 end_pos_small_enough: end_pos <= a_string.count set_count (a_count: INTEGER_32) -- Set count with a_count. -- Note: Current content from index 1 to -- count.min (a_count) is unchanged. require a_count_non_negative: a_count >= 0 ensure count_set: count = a_count fill_blank -- Fill Current with zeros. fill_value (a_value: INTEGER_8) -- Fill Current with a_value. invariant managed_data_not_void: managed_data /= Void count_not_negative: count >= 0 note copyright: "Copyright (c) 1984-2020, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class C_STRING
Generated by ISE EiffelStudio