indexing
	description: "Character formatters"
	library: "Gobo Eiffel Utility Library"
	author: "Eric Bezault <ericb@gobo.demon.co.uk>"
	copyright: "Copyright (c) 1997, Eric Bezault"

class interface
	UT_CHARACTER_FORMATTER

feature -- Access

	array_formatter_: UT_ARRAY_FORMATTER
			-- Formatting routines that ought
			-- to be in class ARRAY
			-- (from UT_IMPORTED_FORMATTERS)
		ensure -- from UT_IMPORTED_FORMATTERS
			array_formatter_not_void: Result /= void

	character_formatter_: UT_CHARACTER_FORMATTER
			-- Formatting routines that ought
			-- to be in class CHARACTER
			-- (from UT_IMPORTED_FORMATTERS)
		ensure -- from UT_IMPORTED_FORMATTERS
			character_formatter_not_void: Result /= void

	eiffel_character_out (c: CHARACTER): STRING
			-- Formatted version of c; if c is not
			-- printable, it is replaced by its escaped
			-- character sequence as described in ETL,
			-- section 25.15, page 422;
			-- Return a new string at each call.
			-- Regexp: [ !#$&(-~]|%[BFNRTU%'"]|%/[0-9]+/
		ensure
			eiffel_character_out_not_void: Result /= void

	integer_formatter_: UT_INTEGER_FORMATTER
			-- Formatting routines that ought
			-- to be in class INTEGER
			-- (from UT_IMPORTED_FORMATTERS)
		ensure -- from UT_IMPORTED_FORMATTERS
			integer_formatter_not_void: Result /= void

	output_stream_: KL_OUTPUT_STREAM_ROUTINES
			-- Routines that ought to be in class OUTPUT_STREAM
			-- (from KL_IMPORTED_OUTPUT_STREAM_ROUTINES)
		ensure -- from KL_IMPORTED_OUTPUT_STREAM_ROUTINES
			output_stream_routines_not_void: Result /= void

	quoted_eiffel_character_out (c: CHARACTER): STRING
			-- Formatted version of c surrounded by single
			-- quotes; if c is not printable, it is replaced
			-- by its escaped character sequence as described
			-- in ETL, section 25.15, page 422;
			-- Return a new string at each call.
			-- Regexp: \'([ !#$&(-~]|%[BFNRTU%'"]|%/[0-9]+/)\'
		ensure
			quoted_eiffel_character_out_not_void: Result /= void

	string_: KL_STRING_ROUTINES
			-- Routines that ought to be in class STRING
			-- (from KL_IMPORTED_STRING_ROUTINES)
		ensure -- from KL_IMPORTED_STRING_ROUTINES
			string_routines_not_void: Result /= void

	string_formatter_: UT_STRING_FORMATTER
			-- Formatting routines that ought
			-- to be in class STRING
			-- (from UT_IMPORTED_FORMATTERS)
		ensure -- from UT_IMPORTED_FORMATTERS
			string_formatter_not_void: Result /= void
	
feature -- File handling

	put_eiffel_character (a_file: like output_stream_type; c: CHARACTER)
			-- Write c to a_file; if c is not printable,
			-- it is replaced by its escaped character sequence
			-- as described in ETL, section 25.15, page 422.
		require
			a_file_not_void: a_file /= void;
			a_file_is_open_write: output_stream_.is_open_write (a_file)

	put_quoted_eiffel_character (a_file: like output_stream_type; c: CHARACTER)
			-- Write c surrounded by single quotes to a_string;
			-- if c is not printable, it is replaced by its
			-- escaped character sequence as described in ETL,
			-- section 25.15, page 422.
		require
			a_file_not_void: a_file /= void;
			a_file_is_open_write: output_stream_.is_open_write (a_file)
	
feature -- String handling

	append_eiffel_character (a_string: STRING; c: CHARACTER)
			-- Append c to a_string; if c is not printable,
			-- it is replaced by its escaped character sequence
			-- as described in ETL, section 25.15, page 422.
		require
			a_string_not_void: a_string /= void

	append_quoted_eiffel_character (a_string: STRING; c: CHARACTER)
			-- Append c surrounded by single quotes to a_string;
			-- if c is not printable, it is replaced by its
			-- escaped character sequence as described in ETL,
			-- section 25.15, page 422.
		require
			a_string_not_void: a_string /= void
	
feature -- Type anchors

	output_stream_type: IO_MEDIUM
			-- (from KL_IMPORTED_OUTPUT_STREAM_ROUTINES)
	
invariant

		-- from GENERAL
	reflexive_equality: standard_is_equal (Current);
	reflexive_conformance: conforms_to (Current);

end -- class UT_CHARACTER_FORMATTER