    indexing
    	description: "A low-level string class to convert Eiffel strings to Win32 unicode strings."
    	legal: "See notice at end of class."
    	status: "See notice at end of class."
    	date: "$Date: 2006-10-05 08:59:27 -0700 (Thu, 05 Oct 2006) $"
    	revision: "$Revision: 64173 $"

    class interface
    	WEL_STRING

    create
    	make (a_string: STRING_GENERAL)
    			-- Make a C string from `a_string'.
    		require
    			a_string_not_void: a_string /= Void

    	make_empty (a_length: INTEGER_32)
    			-- Make an empty C string of `a_length' characters.
    			-- C memory area is not initialized.
    		require
    			a_length_positive: a_length >= 0

    	make_by_pointer (a_ptr: POINTER)
    			-- Make a copy of string pointed by `a_ptr'.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer

    	make_by_pointer_and_count (a_ptr: POINTER; a_length: INTEGER_32)
    			-- Make a copy of first `a_length' byte of string pointed by `a_ptr'.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer
    			a_length_non_negative: a_length >= 0
    			a_length_valid: (a_length \\ {WEL_STRING}.character_size) = 0

    	share_from_pointer (a_ptr: POINTER)
    			-- New instance sharing `a_ptr'.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer

    	share_from_pointer_and_count (a_ptr: POINTER; a_length: INTEGER_32)
    			-- New instance sharing `a_ptr' of `a_length' byte.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer
    			a_length_non_negative: a_length >= 0
    			a_length_valid: (a_length \\ {WEL_STRING}.character_size) = 0

    feature -- Initialization

    	share_from_pointer (a_ptr: POINTER)
    			-- New instance sharing `a_ptr'.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer

    	share_from_pointer_and_count (a_ptr: POINTER; a_length: INTEGER_32)
    			-- New instance sharing `a_ptr' of `a_length' byte.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer
    			a_length_non_negative: a_length >= 0
    			a_length_valid: (a_length \\ {WEL_STRING}.character_size) = 0

    feature -- Access

    	generating_type: STRING_8
    			-- Name of current object's generating type
    			-- (type of which it is a direct instance)
    			-- (from ANY)

    	generator: STRING_8
    			-- Name of current object's generating class
    			-- (base class of the type of which it is a direct instance)
    			-- (from ANY)

    	item: POINTER
    			-- Get pointer to allocated area.
    		ensure
    			item_not_null: Result /= default_pointer

    	managed_data: MANAGED_POINTER
    			-- Hold data of Current.

    	null_separated_strings: LIST [STRING_32]
    			-- Retrieve all string contained in item. Strings are
    			-- NULL separared inside item.
    		ensure
    			result_not_void: Result /= Void

    	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 (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 // character_size)
    			a_string_large_enough: a_string.count >= end_pos - start_pos + 1

    	space_separated_strings: LIST [STRING_32]
    			-- Retrieve all string contained in item. Strings are
    			-- space-separared inside item.
    		ensure
    			result_not_void: Result /= Void

    	string: STRING_32
    			-- Eiffel string, ignoring count. Reads until a null character is being read.
    		ensure
    			string_not_void: Result /= Void

    	substring (start_pos, end_pos: INTEGER_32): STRING_32
    			-- 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 // character_size)
    		ensure
    			susbstring_not_void: Result /= Void

    feature -- Measurement

    	bytes_count: INTEGER_32
    			-- Number of bytes which makes up Current.
    		ensure
    			bytes_count_non_negative: Result >= 0

    	capacity: INTEGER_32
    			-- Number of bytes in Current.

    	character_capacity: INTEGER_32
    			-- Number of characters in Current.

    	frozen character_size: INTEGER_32
    			-- Number of bytes occupied by a TCHAR.

    	count: INTEGER_32
    			-- Number of characters in Current.

    	length: INTEGER_32
    			-- Synonym for count.
    		ensure
    			length_not_negative: Result >= 0

    feature -- Comparison

    	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void
    			-- or attached to isomorphic object structures?
    			-- (from ANY)
    		ensure -- from ANY
    			shallow_implies_deep: standard_equal (some, other) implies Result
    			both_or_none_void: (some = Void) implies (Result = (other = Void))
    			same_type: (Result and (some /= Void)) implies some.same_type (other)
    			symmetric: Result implies deep_equal (other, some)

    	frozen equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached
    			-- to objects considered equal?
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

    	is_equal (other: like Current): BOOLEAN
    			-- Is content of string identical to content of string `other'?
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			symmetric: Result implies other.is_equal (Current)
    			consistent: standard_is_equal (other) implies Result

    	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached to
    			-- field-by-field identical objects of the same type?
    			-- Always uses default object comparison criterion.
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

    	frozen standard_is_equal (other: like Current): BOOLEAN
    			-- Is `other' attached to an object of the same type
    			-- as current object, and field-by-field identical to it?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			same_type: Result implies same_type (other)
    			symmetric: Result implies other.standard_is_equal (Current)

    feature -- Status report

    	conforms_to (other: ANY): BOOLEAN
    			-- Does type of current object conform to type
    			-- of `other' (as per Eiffel: The Language, chapter 13)?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void

    	exists: BOOLEAN is True
    			-- item is always valid.

    	same_type (other: ANY): BOOLEAN
    			-- Is type of current object identical to type of `other'?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			definition: Result = (conforms_to (other) and other.conforms_to (Current))

    feature -- Element change

    	fill_blank
    			-- Fill Current with zeros.

    	fill_value (a_value: INTEGER_8)
    			-- Fill Current with `a_value'.

    	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

    	set_null_character (offset: INTEGER_32)
    			-- Set `%U' at `offset' position of `Current'.
    			-- First position being  at `0' index.
    		require
    			valid_offset: offset >= 0 and offset <= (capacity // character_size)
    		ensure
    			string_set: managed_data.read_integer_16 (offset) = 0

    	set_size_in_string (n: INTEGER_32)
    			-- Set two first bytes of string pointed by item to
    			-- value represented by `n' in a two bytes representation.
    		require
    			valid_size: n > 0
    			small_enough: n <= {INTEGER_16}.max_value

    	set_string (a_string: STRING_GENERAL)
    			-- Set string with `a_string'.
    		require
    			a_string_not_void: a_string /= Void

    	set_substring (a_string: 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

    feature -- Duplication

    	copy (other: like Current)
    			-- Update current object using fields of object attached
    			-- to `other', so as to yield equal objects.
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_equal: is_equal (other)

    	frozen deep_copy (other: like Current)
    			-- Effect equivalent to that of:
    			--		copy (`other' . deep_twin)
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, other)

    	frozen deep_twin: like Current
    			-- New object structure recursively duplicated from Current.
    			-- (from ANY)
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, Result)

    	frozen standard_copy (other: like Current)
    			-- Copy every field of `other' onto corresponding field
    			-- of current object.
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_standard_equal: standard_is_equal (other)

    	frozen standard_twin: like Current
    			-- New object field-by-field identical to `other'.
    			-- Always uses default copying semantics.
    			-- (from ANY)
    		ensure -- from ANY
    			standard_twin_not_void: Result /= Void
    			equal: standard_equal (Result, Current)

    	frozen twin: like Current
    			-- New object equal to `Current'
    			-- twin calls copy; to change copying/twining semantics, redefine copy.
    			-- (from ANY)
    		ensure -- from ANY
    			twin_not_void: Result /= Void
    			is_equal: Result.is_equal (Current)

    feature -- Basic operations

    	frozen default: like Current
    			-- Default value of object's type
    			-- (from ANY)

    	frozen default_pointer: POINTER
    			-- Default value of type `POINTER'
    			-- (Avoid the need to write `p'.default for
    			-- some `p' of type `POINTER'.)
    			-- (from ANY)

    	default_rescue
    			-- Process exception for routines with no Rescue clause.
    			-- (Default: do nothing.)
    			-- (from ANY)

    	frozen do_nothing
    			-- Execute a null action.
    			-- (from ANY)

    feature -- Output

    	io: STD_FILES
    			-- Handle to standard file setup
    			-- (from ANY)

    	out: STRING_8
    			-- New string containing terse printable representation
    			-- of current object
    			-- Was declared in ANY as synonym of tagged_out.
    			-- (from ANY)

    	print (some: ANY)
    			-- Write terse external representation of `some'
    			-- on standard output.
    			-- (from ANY)

    	frozen tagged_out: STRING_8
    			-- New string containing terse printable representation
    			-- of current object
    			-- Was declared in ANY as synonym of out.
    			-- (from ANY)

    feature -- Platform

    	operating_environment: OPERATING_ENVIRONMENT
    			-- Objects available from the operating system
    			-- (from ANY)

    feature --{NONE} -- Initialization

    	make (a_string: STRING_GENERAL)
    			-- Make a C string from `a_string'.
    		require
    			a_string_not_void: a_string /= Void

    	make_by_pointer (a_ptr: POINTER)
    			-- Make a copy of string pointed by `a_ptr'.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer

    	make_by_pointer_and_count (a_ptr: POINTER; a_length: INTEGER_32)
    			-- Make a copy of first `a_length' byte of string pointed by `a_ptr'.
    		require
    			a_ptr_not_null: a_ptr /= default_pointer
    			a_length_non_negative: a_length >= 0
    			a_length_valid: (a_length \\ {WEL_STRING}.character_size) = 0

    	make_empty (a_length: INTEGER_32)
    			-- Make an empty C string of `a_length' characters.
    			-- C memory area is not initialized.
    		require
    			a_length_positive: a_length >= 0

    invariant
    	managed_data_not_void: managed_data /= Void
    	count_not_negative: count >= 0
    	bytes_count_valid: (bytes_count \\ character_size) = 0

    		-- from ANY
    	reflexive_equality: standard_is_equal (Current)
    	reflexive_conformance: conforms_to (Current)

    indexing
    	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
    	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
    	source: "[
    		Eiffel Software
    		356 Storke Road, 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 WEL_STRING