class TEXT_FILE_WRITE

Features exported to INTERNALS_HANDLER

Basic output facilities to write a named file on the disk.

Note: most features are common with STD_OUTPUT so you can test your

      program first on the screen and then, changing of instance
      (STD_OUTPUT/TEXT_FILE_WRITE), doing the same on a file.

Direct parents

conformant parents

FILE, MEMORY, TERMINAL_OUTPUT_STREAM

Summary

creation features

exported features

To write a number:

Other features:

Garbage collector information and tuning:

SmartEiffel Garbage collector information and tuning:

Other features:

Details

make

The new created object is not connected. (See also connect_to and connect_for_appending_to.)

ensure

  • not is_connected

connect_to (new_path: STRING)

Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file.

require

  • not is_connected
  • not_malformed_path: not new_path.is_empty

ensure

  • is_connected implies character_count = 0
  • is_connected implies path.same_as(new_path)

connect_for_appending_to (new_path: STRING)

Open for writing. The file is created if it does not exist. The stream is positioned at the end of the file.

require

  • not is_connected
  • not new_path.is_empty

ensure

  • is_connected implies character_count = 0

flushed_character_count: INTEGER_64

Note that '%N' is counted as one character even if two bytes are written in the file.

character_count: INTEGER_64

See also flushed_character_count Note that '%N' is counted as one character even if two bytes are written in the file.

require

  • is_connected

connect_to (new_path: STRING)

Truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file.

require

  • not is_connected
  • not_malformed_path: not new_path.is_empty

ensure

  • is_connected implies character_count = 0
  • is_connected implies path.same_as(new_path)

connect_for_appending_to (new_path: STRING)

Open for writing. The file is created if it does not exist. The stream is positioned at the end of the file.

require

  • not is_connected
  • not new_path.is_empty

ensure

  • is_connected implies character_count = 0

disconnect

Try to disconnect the stream. Note that it *does not* ensure that the stream will effectively be disconnected (some terminal streams, for instance, are always connected) but the feature can be used to "shake off" filters.

require

  • is_connected
  • can_disconnect
  • is_connected

ensure

  • not is_filtered
  • not is_connected

dispose

Action to be executed just before garbage collection reclaims an object. (The default action is to do nothing at all.) If you want to change the default action, please make your class inherit DISPOSABLE and effect dispose instead of inheriting MEMORY and redefining this dispose feature.

require

  • disconnect_file_after_use: not is_connected

path: STRING

Not Void when connected to the corresponding file on the disk.

is_connected: BOOLEAN

Is this file connected to some file of the operating system?

ensure

  • definition: Result = (path /= Void)

deferred disconnect

Disconnect from any file.

require

  • is_connected

ensure

  • not is_connected

can_put_character (c: CHARACTER): BOOLEAN
can_disconnect: BOOLEAN

True if the stream can be safely disconnected (without data loss, etc.)

require

  • is_connected

put_character (c: CHARACTER)

require

  • is_connected
  • not is_filtered and then can_put_character(c)

flush

Flushes the pipe. If is_filtered, calls the filter's flush instead.

require

  • is_connected

detach

Shake off the filter.

ensure

  • not is_filtered

deferred is_connected: BOOLEAN

True if the stream is connected. Only in that case can data be transfered via this stream.

deferred disconnect

Try to disconnect the stream. Note that it *does not* ensure that the stream will effectively be disconnected (some terminal streams, for instance, are always connected) but the feature can be used to "shake off" filters.

require

  • is_connected
  • can_disconnect

ensure

  • not is_filtered

is_filtered: BOOLEAN

True if some filter is using this stream as backend. use that filter instead.

deferred detach

Shake off the filter.

ensure

  • not is_filtered

descriptor: INTEGER

Some OS-dependent descriptor. Mainly used by the sequencer library (see READY_CONDITION).

require

  • is_connected
  • has_descriptor

has_descriptor: BOOLEAN

True if that stream can be associated to some OS-meaningful descriptor.

require

  • is_connected

deferred can_disconnect: BOOLEAN

True if the stream can be safely disconnected (without data loss, etc.)

require

  • is_connected

deferred put_character (c: CHARACTER)

require

  • is_connected
  • not is_filtered and then can_put_character(c)

deferred flush

Flushes the pipe. If is_filtered, calls the filter's flush instead.

require

  • is_connected

deferred can_put_character (c: CHARACTER): BOOLEAN
deferred is_filtered: BOOLEAN
deferred is_connected: BOOLEAN
put_string (s: STRING)

Output s to current output device.

require

  • is_connected
  • not is_filtered
  • s /= Void

put_unicode_string (unicode_string: UNICODE_STRING)

Output the UTF-8 encoding of the unicode_string.

require

  • is_connected
  • not is_filtered
  • unicode_string /= Void

put_line (s: STRING)

Output the string followed by a '%N'.

frozen put_integer (i: INTEGER_64)

Output i to current output device.

require

  • is_connected
  • not is_filtered

frozen put_integer_format (i: INTEGER_64, s: INTEGER)

Output i to current output device using at most s character.

require

  • is_connected
  • not is_filtered

put_real (r: REAL)

Output r to current output device.

require

  • is_connected
  • not is_filtered

put_real_format (r: REAL, f: INTEGER)

Output r with only f digit for the fractionnal part. Examples:

   put_real(3.519,2) print "3.51".

require

  • is_connected
  • not is_filtered
  • f >= 0

put_double (d: REAL)
This feature is obsolete: Now use `put_real' (October 2004).
put_double_format (d: REAL, f: INTEGER)
This feature is obsolete: Now use `put_real_format' (October 2004).
put_real_scientific (r: REAL, f: INTEGER)

Output r using the scientific notation with only f digit for the fractionnal part. Examples:

   put_real_scientific(3.519,2) print "3.16e+00".

require

  • is_connected
  • not is_filtered
  • f >= 0

put_number (number: NUMBER)

Output the number.

require

  • is_connected
  • not is_filtered
  • number /= Void

put_boolean (b: BOOLEAN)

Output b to current output device according to the Eiffel format.

require

  • is_connected
  • not is_filtered

put_pointer (p: POINTER)

Output a viewable version of p.

require

  • is_connected
  • not is_filtered

put_new_line

Output a newline character.

require

  • is_connected
  • not is_filtered

put_spaces (nb: INTEGER)

Output nb spaces character.

require

  • is_connected
  • not is_filtered
  • nb >= 0

append_file (file_name: STRING)

require

  • is_connected
  • not is_filtered
  • (create {FILE_TOOLS}.default_create).is_readable(file_name)

frozen collecting: BOOLEAN

Is garbage collection enabled?

frozen collection_off

Disable garbage collection.

frozen collection_on

Enable garbage collection.

frozen full_collect

Force a full collection cycle if garbage collection is enabled (i.e. collecting is True); do nothing otherwise.

frozen collector_counter: INTEGER

The number of collections actually performed or -1 when the system is not using the SmartEiffel garbage collector (i.e. when the system is compiled using the -no_gc flag).

ensure

  • Result >= -1

frozen smart_eiffel_collector: BOOLEAN

Is the SmartEiffel garbage collector really used?

ensure

  • Result = (collector_counter >= 0)

frozen small_eiffel_collector: BOOLEAN
This feature is obsolete: Use `smart_eiffel_collector' (July 20, 2004)
frozen low_memory_strategy: BOOLEAN

Is the low memory strategy in use? When this strategy is used, the garbage collector try to use as few memory as possible.

require

  • smart_eiffel_collector

frozen set_low_memory_strategy

require

  • smart_eiffel_collector

ensure

  • low_memory_strategy

frozen high_memory_strategy: BOOLEAN

Is the high memory strategy in use? When this strategy is used, the garbage collector assume that more memory can be allocated if necessary.

require

  • smart_eiffel_collector

frozen set_high_memory_strategy

require

  • smart_eiffel_collector

ensure

  • high_memory_strategy

frozen default_memory_strategy: BOOLEAN

Is the default memory strategy in use? This is the default initial mode for the garbage collector (somewhere between low_memory_strategy and high_memory_strategy).

require

  • smart_eiffel_collector

frozen set_default_memory_strategy

require

  • smart_eiffel_collector

ensure

  • default_memory_strategy

frozen allocated_bytes: INTEGER

Total number of allocated bytes of memory in the heap.

require

  • collector_counter >= 0

pointer_size: INTEGER
This feature is obsolete: Use POINTER.object_size (2003/06/23)