[Home] [Prev] [Next] [Index]

14.3.6 Input-Output of Characters and Strings

14.3.6 Input-Output of Characters and Strings

1
For an item of type CHARACTER the following procedures are provided:

2
procedure GET(FILE : in FILE_TYPE; ITEM : out CHARACTER);
procedure GET(ITEM : out CHARACTER);

3
After skipping any line terminators and any page terminators, reads the next character from the specified input file and returns the value of this character in the out parameter ITEM.

4
The exception END_ERROR is raised if an attempt is made to skip a file terminator.

5
procedure PUT(FILE : in FILE_TYPE; ITEM : in CHARACTER);
procedure PUT(ITEM : in CHARACTER);

6
If the line length of the specified output file is bounded (that is, does not have the conventional value zero), and the current column number exceeds it, has the effect of calling NEW_LINE with a spacing of one. Then, or otherwise, outputs the given character to the file.

7
For an item of type STRING the following procedures are provided:

8
procedure GET(FILE : in FILE_TYPE; ITEM : out STRING);
procedure GET(ITEM : out STRING);

9
Determines the length of the given string and attempts that number of GET operations for successive characters of the string (in particular, no operation is performed if the string is null).

10
procedure PUT(FILE : in FILE_TYPE; ITEM : in STRING);
procedure PUT(ITEM : in STRING);

11
Determines the length of the given string and attempts that number of PUT operations for successive characters of the string (in particular, no operation is performed if the string is null).

12
procedure GET_LINE(FILE : in FILE_TYPE; ITEM : out STRING;
               LAST : out NATURAL);
procedure GET_LINE(ITEM : out STRING; LAST : out NATURAL);

13
Replaces successive characters of the specified string by successive characters read from the specified input file. Reading stops if the end of the line is met, in which case the procedure SKIP_LINE is then called (in effect) with a spacing of one; reading also stops if the end of the string is met. Characters not replaced are left undefined.

14
If characters are read, returns in LAST the index value such that ITEM(LAST) is the last character replaced (the index of the first character replaced is ITEM'FIRST). If no characters are read, returns in LAST an index value that is one less than ITEM'FIRST.

15
The exception END_ERROR is raised if an attempt is made to skip a file terminator.

16
procedure PUT_LINE(FILE : in FILE_TYPE; ITEM : in STRING);
procedure PUT_LINE(ITEM : in STRING);

17
Calls the procedure PUT for the given string, and then the procedure NEW_LINE with a spacing of one.

Notes:

18
In a literal string parameter of PUT, the enclosing string bracket characters are not output. Each doubled string bracket character in the enclosed string is output as a single string bracket character, as a consequence of the rule for string literals (see 2.6).

19
A string read by GET or written by PUT can extend over several lines.

20
References:

*
current column number 14.3

*
end_error exception 14.4

*
file 14.1

*
file terminator 14.3

*
get procedure 14.3.5

*
line 14.3

*
line length 14.3

*
new_line procedure 14.3.4

*
page terminator 14.3

*
put procedure 14.3.4

*
skipping 14.3.5

14.3.7 Input-Output for Integer Types

1
The following procedures are defined in the generic package INTEGER_IO. This must be instantiated for the appropriate integer type (indicated by NUM in the specification).

2
Values are output as decimal or based literals, without underline characters or exponent, and preceded by a minus sign if negative. The format (which includes any leading spaces and minus sign) can be specified by an optional field width parameter. Values of widths of fields in output formats are of the nonnegative integer subtype FIELD. Values of bases are of the integer subtype NUMBER_BASE.

subtype NUMBER_BASE is INTEGER range 2 .. 16;

3
The default field width and base to be used by output procedures are defined by the following variables that are declared in the generic package INTEGER_IO:

DEFAULT_WIDTH : FIELD := NUM'WIDTH;
DEFAULT_BASE : NUMBER_BASE := 10;

4
The following procedures are provided:

5
procedure GET(FILE : in FILE_TYPE; ITEM : out NUM;
               WIDTH : in FIELD := 0);
procedure GET(ITEM : out NUM; WIDTH : in FIELD := 0);

6
If the value of the parameter WIDTH is zero, skips any leading blanks, line terminators, or page terminators, then reads a plus or a minus sign if present, then reads according to the syntax of an integer literal (which may be a based literal). If a nonzero value of WIDTH is supplied, then exactly WIDTH characters are input, or the characters (possibly none) up to a line terminator, whichever comes first; any skipped leading blanks are included in the count.

7
Returns, in the parameter ITEM, the value of type NUM that corresponds to the sequence input.

8
The exception DATA_ERROR is raised if the sequence input does not have the required syntax or if the value obtained is not of the subtype NUM.

9
procedure PUT( FILE : in FILE_TYPE;
               ITEM : in NUM;
               WIDTH : in FIELD := DEFAULT_WIDTH;
               BASE : in NUMBER_BASE := DEFAULT_BASE);

procedure PUT( ITEM : in NUM;
WIDTH : in FIELD := DEFAULT_WIDTH;
BASE : in NUMBER_BASE := DEFAULT_BASE);

10
Outputs the value of the parameter ITEM as an integer literal, with no underlines, no exponent, and no leading zeros (but a single zero for the value zero), and a preceding minus sign for a negative value.

11
If the resulting sequence of characters to be output has fewer than WIDTH characters, then leading spaces are first output to make up the difference.

12
Uses the syntax for decimal literal if the parameter BASE has the value ten (either explicitly or through DEFAULT_BASE); otherwise, uses the syntax for based literal, with any letters in upper case.

13
procedure GET(FROM : in STRING; ITEM : out NUM;
               LAST : out POSITIVE);

14
Reads an integer value from the beginning of the given string, following the same rules as the GET procedure that reads an integer value from a file, but treating the end of the string as a file terminator. Returns, in the parameter ITEM, the value of type NUM that corresponds to the sequence input. Returns in LAST the index value such that FROM(LAST) is the last character read.

15
The exception DATA_ERROR is raised if the sequence input does not have the required syntax or if the value obtained is not of the subtype NUM.

16
procedure PUT( TO : out STRING;
               ITEM : in NUM;
               BASE : in NUMBER_BASE := DEFAULT_BASE);

17
Outputs the value of the parameter ITEM to the given string, following the same rule as for output to a file, using the length of the given string as the value for WIDTH.

18
Examples:

package INT_IO is new INTEGER_IO(SMALL_INT); use INT_IO;
-- default format used at instantiation, DEFAULT_WIDTH = 4,
-- DEFAULT_BASE = 10
PUT(126);

-- "b126"

PUT(-126, 7);

-- "bbb-126"

PUT(126, WIDTH => 13, BASE => 2);          

-- "bbb2#1111110#"          

19
References:

*
based literal 2.4.2

*
blank 14.3.5

*
data_error exception 14.4

*
decimal literal 2.4.1

*
field subtype 14.3.5

*
file_type 14.1

*
get procedure 14.3.5

*
integer_io package 14.3.10

*
integer literal 2.4

*
layout_error exception 14.4

*
line terminator 14.3

*
put procedure 14.3.5

*
skipping 14.3.5

*
width 14.3.5

14.3.8 Input-Output for Real Types

1
The following procedures are defined in the generic packages FLOAT_IO and FIXED_IO, which must be instantiated for the appropriate floating point or fixed point type respectively (indicated by NUM in the specifications).

2
Values are output as decimal literals without underline characters. The format of each value output consists of a FORE field, a decimal point, an AFT field, and (if a nonzero EXP parameter is supplied) the letter E and an EXP field. The two possible formats thus correspond to:

FORE . AFT

3
and to:

FORE . AFT E EXP

4
without any spaces between these fields. The FORE field may include leading spaces, and a minus sign for negative values. The AFT field includes only decimal digits (possibly with trailing zeros). The EXP field includes the sign (plus or minus) and the exponent (possibly with leading zeros).

5
For floating point types, the default lengths of these fields are defined by the following variables that are declared in the generic package FLOAT_IO:

DEFAULT_FORE : FIELD := 2;
DEFAULT_AFT : FIELD := NUM'DIGITS-1;
DEFAULT_EXP : FIELD := 3;

6
For fixed point types, the default lengths of these fields are defined by the following variables that are declared in the generic package FIXED_IO:

DEFAULT_FORE : FIELD := NUM'FORE;
DEFAULT_AFT : FIELD := NUM'AFT;
DEFAULT_EXP : FIELD := 0;

7
The following procedures are provided:

8
procedure GET(FILE : in FILE_TYPE; ITEM : out NUM;
               WIDTH : in FIELD := 0);
procedure GET(ITEM : out NUM; WIDTH : in FIELD := 0);

9
If the value of the parameter WIDTH is zero, skips any leading blanks, line terminators, or page terminators, then reads a plus or a minus sign if present, then reads according to the syntax of a real literal (which may be a based literal). If a nonzero value of WIDTH is supplied, then exactly WIDTH characters are input, or the characters (possibly none) up to a line terminator, whichever comes first; any skipped leading blanks are included in the count.

10
Returns, in the parameter ITEM, the value of type NUM that corresponds to the sequence input.

11
The exception DATA_ERROR is raised if the sequence input does not have the required syntax or if the value obtained is not of the subtype NUM.

12
procedure PUT( FILE : in FILE_TYPE;
               ITEM : in NUM;
               FORE : in FIELD := DEFAULT_FORE;
               AFT : in FIELD := DEFAULT_AFT;
               EXP : in FIELD := DEFAULT_EXP);

procedure PUT( ITEM : in NUM;
               FORE : in FIELD := DEFAULT_FORE;
               AFT : in FIELD := DEFAULT_AFT;
               EXP : in FIELD := DEFAULT_EXP);

13
Outputs the value of the parameter ITEM as a decimal literal with the format defined by FORE, AFT and EXP. If the value is negative, a minus sign is included in the integer part. If EXP has the value zero, then the integer part to be output has as many digits as are needed to represent the integer part of the value of ITEM, overriding FORE if necessary, or consists of the digit zero if the value of ITEM has no integer part.

14
If EXP has a value greater than zero, then the integer part to be output has a single digit, which is nonzero except for the value 0.0 of ITEM.

15
In both cases, however, if the integer part to be output has fewer than FORE characters, including any minus sign, then leading spaces are first output to make up the difference. The number of digits of the fractional part is given by AFT, or is one if AFT equals zero. The value is rounded; a value of exactly one half in the last place may be rounded either up or down.

16
If EXP has the value zero, there is no exponent part. If EXP has a value greater than zero, then the exponent part to be output has as many digits as are needed to represent the exponent part of the value of ITEM (for which a single digit integer part is used), and includes an initial sign (plus or minus). If the exponent part to be output has fewer than EXP characters, including the sign, then leading zeros precede the digits, to make up the difference. For the value 0.0 of ITEM, the exponent has the value zero.

17
procedure GET(FROM : in STRING; ITEM : out NUM;
               LAST : out POSITIVE);

18
Reads a real value from the beginning of the given string, following the same rule as the GET procedure that reads a real value from a file, but treating the end of the string as a file terminator. Returns, in the parameter ITEM, the value of type NUM that corresponds to the sequence input. Returns in LAST the index value such that FROM(LAST) is the last character read.

19
The exception DATA_ERROR is raised if the sequence input does not have the required syntax, or if the value obtained is not of the subtype NUM.

20
procedure PUT( TO : out STRING;
               ITEM : in NUM;
               AFT : in FIELD := DEFAULT_AFT;
               EXP : in INTEGER := DEFAULT_EXP);

21
Outputs the value of the parameter ITEM to the given string, following the same rule as for output to a file, using a value for FORE such that the sequence of characters output exactly fills the string, including any leading spaces.

22
Examples:

package REAL_IO is new FLOAT_IO(REAL); use REAL_IO;
-- default format used at instantiation, DEFAULT_EXP = 3

X : REAL := -123.4567; -- digits 8 (see 3.5.7)

PUT(X); -- default format

"-1.2345670E+02"          

PUT(X, FORE => 5, AFT => 3, EXP => 2);          

--

"bbb-1.235E+2"

PUT(X, 5, 3, 0);

--

"b-123.457"

Note:

23
For an item with a positive value, if output to a string exactly fills the string without leading spaces, then output of the corresponding negative value will raise LAYOUT_ERROR.

24
References:

*
aft attribute 3.5.10

*
based literal 2.4.2

*
blank 14.3.5

*
data_error exception 14.3.5

*
decimal literal 2.4.1

*
field subtype 14.3.5

*
file_type 14.1

*
fixed_io package 14.3.10

*
floating_io package 14.3.10

*
fore attribute 3.5.10

*
get procedure 14.3.5

*
layout_error 14.3.5

*
line terminator 14.3.5

*
put procedure 14.3.5

*
real literal 2.4

*
skipping 14.3.5

*
width 14.3.5

14.3.9 Input-Output for Enumeration Types

1
The following procedures are defined in the generic package ENUMERATION_IO, which must be instantiated for the appropriate enumeration type (indicated by ENUM in the specification).

2
Values are output using either upper or lower case letters for identifiers. This is specified by the parameter SET, which is of the enumeration type TYPE_SET.

type TYPE_SET is (LOWER_CASE, UPPER_CASE);

3
The format (which includes any trailing spaces) can be specified by an optional field width parameter. The default field width and letter case are defined by the following variables that are declared in the generic package ENUMERATION_IO:

DEFAULT_WIDTH : FIELD := 0;
DEFAULT_SETTING : TYPE_SET := UPPER_CASE;

4
The following procedures are provided:

5
procedure GET(FILE : in FILE_TYPE; ITEM : out ENUM);
procedure GET(ITEM : out ENUM);

6
After skipping any leading blanks, line terminators, or page terminators, reads an identifier according to the syntax of this lexical element (lower and upper case being considered equivalent), or a character literal according to the syntax of this lexical element (including the apostrophes). Returns, in the parameter ITEM, the value of type ENUM that corresponds to the sequence input.

7
The exception DATA_ERROR is raised if the sequence input does not have the required syntax, or if the identifier or character literal does not correspond to a value of the subtype ENUM.

8
procedure PUT( FILE : in FILE_TYPE;
               ITEM : in ENUM;
               WIDTH : in FIELD := DEFAULT_WIDTH;
               SET : in TYPE_SET := DEFAULT_SETTING);

procedure PUT( ITEM : in ENUM;
               WIDTH : in FIELD := DEFAULT_WIDTH;
               SET : in TYPE_SET := DEFAULT_SETTING);

9
Outputs the value of the parameter ITEM as an enumeration literal (either an identifier or a character literal). The optional parameter SET indicates whether lower case or upper case is used for identifiers; it has no effect for character literals. If the sequence of characters produced has fewer than WIDTH characters, then trailing spaces are finally output to make up the difference.

10
procedure GET(FROM : in STRING; ITEM : out ENUM;
               LAST : out POSITIVE);

11
Reads an enumeration value from the beginning of the given string, following the same rule as the GET procedure that reads an enumeration value from a file, but treating the end of the string as a file terminator. Returns, in the parameter ITEM, the value of type ENUM that corresponds to the sequence input. Returns in LAST the index value such that FROM(LAST) is the last character read.

12
The exception DATA_ERROR is raised if the sequence input does not have the required syntax, or if the identifier or character literal does not correspond to a value of the subtype ENUM.

13
procedure PUT( TO : out STRING;
               ITEM : in ENUM;
               SET : in TYPE_SET := DEFAULT_SETTING);

14
Outputs the value of the parameter ITEM to the given string, following the same rule as for output to a file, using the length of the given string as the value for WIDTH.

15
Although the specification of the package ENUMERATION_IO would allow instantiation for an integer type, this is not the intended purpose of this generic package, and the effect of such instantiations is not defined by the language.

Notes:

16
There is a difference between PUT defined for characters, and for enumeration values. Thus

TEXT_IO.PUT(`A'); -- outputs the character A

package CHAR_IO is new TEXT_IO.ENUMERATION_IO(CHARACTER);
CHAR_IO.PUT(`A');
               -- outputs the character `A', between single quotes

17
The type BOOLEAN is an enumeration type, hence ENUMERATION_IO can be instantiated for this type.

18
References:

*
blank 14.3.5

*
data_error 14.3.5

*
enumeration_io package 14.3.10

*
field subtype 14.3.5

*
file_type 14.1

*
get procedure 14.3.5

*
line terminator 14.3.5

*
put procedure 14.3.5

*
skipping 14.3.5

*
width 14.3.5

14.3.10 Specification of the Package Text_IO

1
with IO_EXCEPTIONS;
package TEXT_IO is

     type FILE_TYPE is limited private;

     type FILE_MODE is (IN_FILE, OUT_FILE);

     type COUNT is range 0 .. implementation_defined;
     subtype POSITIVE_COUNT is COUNT range 1 .. COUNT'LAST;
     UNBOUNDED : constant COUNT := 0; -- line and page length

     subtype FIELD is INTEGER range 0 .. implementation_defined;
     subtype NUMBER_BASE is INTEGER range 2 .. 16;

     type TYPE_SET is (LOWER_CASE, UPPER_CASE);

     -- File Management

     procedure CREATE ( FILE : in out FILE_TYPE;
               MODE : in FILE_MODE := OUT_FILE;
               NAME : in STRING := "";
               FORM : in STRING := "");

     procedure OPEN ( FILE : in out FILE_TYPE;
               MODE : in FILE_MODE;
               NAME : in STRING;
               FORM : in STRING := "");

     procedure CLOSE (FILE : in out FILE_TYPE);
     procedure DELETE (FILE : in out FILE_TYPE);
     procedure RESET (FILE : in out FILE_TYPE; MODE : in FILE_MODE);
     procedure RESET (FILE : in out FILE_TYPE);

     function MODE (FILE : in FILE_TYPE) return FILE_MODE;
     function NAME (FILE : in FILE_TYPE) return STRING;
     function FORM (FILE : in FILE_TYPE) return STRING;

     function IS_OPEN(FILE : in FILE_TYPE) return BOOLEAN;

     -- Control of default input and output files

     procedure SET_INPUT (FILE : in FILE_TYPE);
     procedure SET_OUTPUT(FILE : in FILE_TYPE);

     function STANDARD_INPUT return FILE_TYPE;
     function STANDARD_OUTPUT return FILE_TYPE;

     function CURRENT_INPUT return FILE_TYPE;
     function CURRENT_OUTPUT return FILE_TYPE;

     -- Specification of line and page lengths

     procedure SET_LINE_LENGTH(FILE : in FILE_TYPE; TO : in COUNT);
     procedure SET_LINE_LENGTH(TO : in COUNT);

     procedure SET_PAGE_LENGTH(FILE : in FILE_TYPE; TO : in COUNT);
     procedure SET_PAGE_LENGTH(TO : in COUNT);

     function LINE_LENGTH(FILE : in FILE_TYPE) return COUNT;
     function LINE_LENGTH return COUNT;

     function PAGE_LENGTH(FILE : in FILE_TYPE) return COUNT;
     function PAGE_LENGTH return COUNT;

     -- Column, Line, and Page Control

     procedure NEW_LINE
               (FILE : in FILE_TYPE; SPACING : in POSITIVE_COUNT := 1);
     procedure NEW_LINE (SPACING : in POSITIVE_COUNT := 1);

     procedure SKIP_LINE
               (FILE : in FILE_TYPE; SPACING : in POSITIVE_COUNT := 1);
     procedure SKIP_LINE (SPACING : in POSITIVE_COUNT := 1);

     function END_OF_LINE(FILE : in FILE_TYPE) return BOOLEAN;
     function END_OF_LINE return BOOLEAN;

     procedure NEW_PAGE (FILE : in FILE_TYPE);
     procedure NEW_PAGE;

     procedure SKIP_PAGE (FILE : in FILE_TYPE);
     procedure SKIP_PAGE;

     function END_OF_PAGE(FILE : in FILE_TYPE) return BOOLEAN;
     function END_OF_PAGE return BOOLEAN;

     function END_OF_FILE(FILE : in FILE_TYPE) return BOOLEAN;
     function END_OF_FILE return BOOLEAN;

     procedure SET_COL (FILE : in FILE_TYPE; TO : in POSITIVE_COUNT);
     procedure SET_COL (TO : in POSITIVE_COUNT);

     procedure SET_LINE(FILE : in FILE_TYPE; TO : in POSITIVE_COUNT);
     procedure SET_LINE(TO : in POSITIVE_COUNT);

     function COL (FILE : in FILE_TYPE) return POSITIVE_COUNT;
     function COL return POSITIVE_COUNT;

     function LINE(FILE : in FILE_TYPE) return POSITIVE_COUNT;
     function LINE return POSITIVE_COUNT;

     function PAGE(FILE : in FILE_TYPE) return POSITIVE_COUNT;
     function PAGE return POSITIVE_COUNT;

     -- Character Input-Output

     procedure GET(FILE : in FILE_TYPE; ITEM : out CHARACTER);
     procedure GET(ITEM : out CHARACTER);
     procedure PUT(FILE : in FILE_TYPE; ITEM : in CHARACTER);
     procedure PUT(ITEM : CHARACTER);

     -- String Input-Output

     procedure GET(FILE : in FILE_TYPE; ITEM : out STRING);
     procedure GET(ITEM : out STRING);
     procedure PUT(FILE : in FILE_TYPE; ITEM : in STRING);
     procedure PUT(ITEM : in STRING);

     procedure GET_LINE(FILE : in FILE_TYPE;
               ITEM : out STRING; LAST : out NATURAL);
     procedure GET_LINE(ITEM : out STRING; LAST : out NATURAL);
     procedure PUT_LINE(FILE : in FILE_TYPE; ITEM : in STRING);
     procedure PUT_LINE(ITEM : in STRING);

     -- Generic package for Input-Output of Integer Types

     generic
          type NUM is range <>;
     package INTEGER_IO is

          DEFAULT_WIDTH : FIELD := NUM'WIDTH;
          DEFAULT_BASE : NUMBER_BASE := 10;

          procedure GET(FILE : in FILE_TYPE; ITEM : out NUM;
                    WIDTH : in FIELD := 0);
          procedure GET(ITEM : out NUM; WIDTH : in FIELD := 0);

          procedure PUT( FILE : in FILE_TYPE;
                    ITEM : in NUM;
                    WIDTH : in FIELD := DEFAULT_WIDTH;
                    BASE : in NUMBER_BASE := DEFAULT_BASE);
          procedure PUT( ITEM : in NUM;
                    WIDTH : in FIELD := DEFAULT_WIDTH;
                    BASE : in NUMBER_BASE := DEFAULT_BASE);

          procedure GET( FROM : in STRING;
                    ITEM : out NUM;
                    LAST : out POSITIVE);
          procedure PUT( TO : out STRING;
                    ITEM : in NUM;
                    BASE : in NUMBER_BASE := DEFAULT_BASE);

     end INTEGER_IO;

     -- Generic packages for Input-Output of Real Types

     generic
          type NUM is digits <>;
     package FLOAT_IO is

          DEFAULT_FORE : FIELD := 2;
          DEFAULT_AFT : FIELD := NUM'DIGITS-1;
          DEFAULT_EXP : FIELD := 3;

          procedure GET(FILE : in FILE_TYPE; ITEM : out NUM;
                    WIDTH : in FIELD := 0);
          procedure GET(ITEM : out NUM; WIDTH : in FIELD := 0);

          procedure PUT( FILE : in FILE_TYPE;
                    ITEM : in NUM;
                    FORE : in FIELD := DEFAULT_FORE;
                    AFT : in FIELD := DEFAULT_AFT;
                    EXP : in FIELD := DEFAULT_EXP);
          procedure PUT( ITEM : in NUM;
                    FORE : in FIELD := DEFAULT_FORE;
                    AFT : in FIELD := DEFAULT_AFT;
                    EXP : in FIELD := DEFAULT_EXP);

          procedure GET(FROM : in STRING; ITEM : out NUM;
                    LAST : out POSITIVE);

          procedure PUT( TO : out STRING;
                    ITEM : in NUM;
                    AFT : in FIELD := DEFAULT_AFT;
                    EXP : in FIELD := DEFAULT_EXP);
     end FLOAT_IO;

     generic
          type NUM is delta <>;
     package FIXED_IO is

                    DEFAULT_FORE : FIELD := NUM'FORE;
                    DEFAULT_AFT : FIELD := NUM'AFT;
                    DEFAULT_EXP : FIELD := 0;

          procedure GET(FILE : in FILE_TYPE; ITEM : out NUM;
                    WIDTH : in FIELD := 0);
          procedure GET(ITEM : out NUM; WIDTH : in FIELD := 0);

          procedure PUT( FILE : in FILE_TYPE;
                    ITEM : in NUM;
                    FORE : in FIELD := DEFAULT_FORE;
                    AFT : in FIELD := DEFAULT_AFT;
                    EXP : in FIELD := DEFAULT_EXP);
          procedure PUT( ITEM : in NUM;
                    FORE : in FIELD := DEFAULT_FORE;
                    AFT : in FIELD := DEFAULT_AFT;
                    EXP : in FIELD := DEFAULT_EXP);

          procedure GET(FROM : in STRING; ITEM : out NUM;
                    LAST : out POSITIVE);

          procedure PUT( TO : out STRING;
                    ITEM : in NUM;
                    AFT : in FIELD := DEFAULT_AFT;
                    EXP : in FIELD := DEFAULT_EXP);

     end FIXED_IO;

     -- Generic package for Input-Output of Enumeration Types

     generic
          type ENUM is (<>);
     package ENUMERATION_IO is

          DEFAULT_WIDTH : FIELD := 0;
          DEFAULT_SETTING : TYPE_SET := UPPER_CASE;

          procedure GET(FILE : in FILE_TYPE; ITEM : out ENUM);
          procedure GET(ITEM : out ENUM);

          procedure PUT( FILE : in FILE_TYPE;
                    ITEM : in ENUM;
                    WIDTH : in FIELD := DEFAULT_WIDTH;
                    SET : in TYPE_SET := DEFAULT_SETTING);
          procedure PUT( ITEM : in ENUM;
                    WIDTH : in FIELD := DEFAULT_WIDTH;
                    SET : in TYPE_SET := DEFAULT_SETTING);

          procedure GET(FROM : in STRING; ITEM : out ENUM;
                    LAST : out POSITIVE);

          procedure PUT( TO : out STRING;
                    ITEM : in ENUM;
                    SET : in TYPE_SET := DEFAULT_SETTING);

     end ENUMERATION_IO;

     -- Exceptions

     STATUS_ERROR : exception renames IO_EXCEPTIONS.STATUS_ERROR;
     MODE_ERROR : exception renames IO_EXCEPTIONS.MODE_ERROR;
     NAME_ERROR : exception renames IO_EXCEPTIONS.NAME_ERROR;
     USE_ERROR : exception renames IO_EXCEPTIONS.USE_ERROR;
     DEVICE_ERROR : exception renames IO_EXCEPTIONS.DEVICE_ERROR;
     END_ERROR : exception renames IO_EXCEPTIONS.END_ERROR;
     DATA_ERROR : exception renames IO_EXCEPTIONS.DATA_ERROR;
     LAYOUT_ERROR : exception renames IO_EXCEPTIONS.LAYOUT_ERROR;

private
     -- implementation-dependent
end TEXT_IO;



[Home] [Prev] [Next] [Index]

documentation@rational.com
Copyright © 1993-2000, Rational Software Corporation. All rights reserved.