    indexing
    	description: "Formatter for integral numbers"
    	legal: "See notice at end of class."
    	status: "See notice at end of class."
    	names: format_integer
    	date: "$Date: 2006-01-22 18:25:44 -0800 (Sun, 22 Jan 2006) $"
    	revision: "$Revision: 56675 $"

    class interface
    	FORMAT_INTEGER

    create
    	make (w: INTEGER_32)
    		require
    			reasonable_field: w >= 1
    		ensure
    			blank_fill: fill_character = ' '
    			show_sign_negative: show_sign_negative
    			no_separator: no_separator
    			width_set: width = w
    			right_justified: right_justified
    			leading_sign: leading_sign

    feature -- Initialization

    	make (w: INTEGER_32)
    		require
    			reasonable_field: w >= 1
    		ensure
    			blank_fill: fill_character = ' '
    			show_sign_negative: show_sign_negative
    			no_separator: no_separator
    			width_set: width = w
    			right_justified: right_justified
    			leading_sign: leading_sign

    feature -- Access

    	bracketted_negative: BOOLEAN
    			-- Enclose negative numbers in brackets?

    	fill_character: CHARACTER_8
    			-- Padding character.

    	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)

    	justification: INTEGER_32
    			-- Where in the field the format goes.

    	separator: CHARACTER_8
    			-- Separator between 1000's of numbers.

    	sign_format: INTEGER_32
    			-- How the sign is formatted.

    	sign_string: STRING_8
    			-- Formatting details for the sign.

    	trailing_sign: BOOLEAN
    			-- Is the sign at the end?

    	width: INTEGER_32
    			-- Width of the field.

    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 `other' attached to an object considered
    			-- equal to current object?
    			-- (from ANY)
    		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

    	centered: BOOLEAN
    			-- Are numbers to be formatted centered?
    		ensure
    			Result = (justification = center_justification)

    	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

    	ignore_sign: BOOLEAN
    			-- Ignore the sign of a number?
    		ensure
    			Result = (sign_format = ignore_sign_value)

    	leading_sign: BOOLEAN
    			-- Is the sign leading?
    		ensure
    			Result = not trailing_sign

    	left_justified: BOOLEAN
    			-- Are numbers to be formatted with spaces on the right?
    		ensure
    			Result = (justification = left_justification)

    	no_separator: BOOLEAN
    			-- Is there a separator?
    		ensure
    			Result = (separator = '%U')

    	not_justified: BOOLEAN
    			-- Are numbers to be formatted in smallest string possible
    		ensure
    			Result = (justification = no_justification)

    	right_justified: BOOLEAN
    			-- Are numbers to be formatted with spaces on the left?
    		ensure
    			Result = (justification = right_justification)

    	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))

    	show_sign: BOOLEAN
    			-- Are numbers to show sign whether positive or negative?
    		ensure
    			Result = (sign_format = show_sign_value)

    	show_sign_negative: BOOLEAN
    			-- Are numbers to show sign only when negative?
    		ensure
    			Result = (sign_format = sign_negative_value)

    	show_sign_positive: BOOLEAN
    			-- Are numbers to show sign only when positive?
    		ensure
    			Result = (sign_format = sign_positive_value)

    feature -- Status setting

    	asterisk_fill
    			-- Fill numbers with asterisks.
    		ensure
    			fill_character = '*'

    	blank_fill
    			-- Fill numbers with blanks.
    		ensure
    			fill_character = ' '

    	bracket_negative
    			-- Bracket negative numbers.
    		ensure
    			bracketted_negative

    	center_justify
    			-- Put padding on right and left
    		ensure
    			centered

    	comma_separate
    			-- Set separator to comma.
    		ensure
    			separator = ','

    	dollar_fill
    			-- Fill numbers with dollars.
    		ensure
    			fill_character = '$'

    	dot_separate
    			-- Set separator to period.
    		ensure
    			separator = '.'

    	left_justify
    			--Put padding on right
    		ensure
    			left_justified

    	no_justify
    			-- Always return the smallest string possible
    		ensure
    			not_justified

    	remove_separator
    			-- Remove the separator.
    		ensure
    			separator = '%U'

    	right_justify
    			-- Put padding on left
    		ensure
    			right_justified

    	set_fill (c: CHARACTER_8)
    			-- Fill numbers with `c'
    		ensure
    			fill_character = c

    	set_separator (c: CHARACTER_8)
    			-- Set the separator to `c'
    		ensure
    			separator = c

    	set_sign (s: STRING_8)
    			-- Set sign values for positive, zero, negative
    			-- All values must be the same length.
    			-- Stored as negative, zero, positive.
    		require
    			s /= Void
    			s.count >= 3
    			s.count \\ 3 = 0
    		ensure
    			sign_string.is_equal (s)

    	set_width (w: INTEGER_32)
    			-- Set width to `w'
    		require
    			wide_enough: w >= 1
    		ensure
    			width = w

    	sign_cr_dr
    			-- Set sign for CR/DR
    		ensure
    			sign_string.is_equal ("CR DR")

    	sign_dr_cr
    			-- Set sign for DR/CR
    		ensure
    			sign_string.is_equal ("DR CR")

    	sign_floating_dollar
    			-- Set sign for floating dollar.
    		ensure
    			sign_string.is_equal ("$$$")

    	sign_floating_dollar_signed
    			-- Set sign for floating dollar include sign.
    		ensure
    			sign_string.is_equal ("-$ $+$")

    	sign_ignore
    			-- Do not show sign.
    		ensure
    			ignore_sign

    	sign_leading
    			-- Set the sign to lead
    		ensure
    			leading_sign

    	sign_negative_only
    			-- Show sign for negative numbers only.
    		ensure
    			show_sign_negative

    	sign_normal
    			-- Set sign for - and +.
    		ensure
    			sign_string.is_equal ("- +")

    	sign_positive_only
    			-- Show sign for positive numbers only.
    		ensure
    			show_sign_positive

    	sign_show
    			-- Show sign for all numbers.
    		ensure
    			show_sign

    	sign_trailing
    			-- Set the sign to trail
    		ensure
    			trailing_sign

    	unbracket_negative
    			-- Do not bracket negative numbers.
    		ensure
    			not bracketted_negative

    	underscore_separate
    			-- Set separator to underscore.
    		ensure
    			separator = '_'

    	zero_fill
    			-- Fill numbers with zeros.
    		ensure
    			fill_character = '0'

    feature -- Conversion

    	formatted (i: INTEGER_32): STRING_8
    			-- Format the integer.
    		ensure
    			exists: Result /= Void
    			correct_length: not_justified or Result.count >= width

    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)

    invariant
    	sign_string_constraint: sign_string /= Void
    	wide_enough: width >= 1
    	no_justification <= justification and justification <= right_justification

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

    indexing
    	library: "EiffelBase: Library of reusable components for Eiffel."
    	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 FORMAT_INTEGER