File: AA-13-13-2.html

package info (click to toggle)
ada-reference-manual 20021112web-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 18,652 kB
  • ctags: 8,921
  • sloc: makefile: 52; sh: 20
file content (378 lines) | stat: -rw-r--r-- 27,615 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
    <TITLE>AARM95 - Stream-Oriented Attributes</TITLE>
    <META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
    <META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
    <STYLE type="text/css">
    DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
    TT {font-family: "Courier New", monospace}
    DT {display: compact}
    DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
    DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
    DIV.Index {font-family: "Times New Roman", Times, serif}
    DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
    DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
    DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
    DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
    DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left:  10.0em; margin-bottom: 0.6em}
    DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
    DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
    DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
    DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left:  15.0em; margin-bottom: 0.6em}
    UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
    DD.Hanging {margin-left: 6.0em}
    DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.IndentedHanging {margin-left: 2.0em}
    DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.HangingInBulleted {margin-left: 4.0em}
    DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallHanging {margin-left: 7.5em}
    DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
    DD.SmallIndentedHanging {margin-left: 2.0em}
    DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallHangingInBulleted {margin-left: 5.0em}
    DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.Enumerated {margin-left: 2.0em}
    DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
    DD.SmallEnumerated {margin-left: 2.5em}
    DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
    DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
    </STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-13-13-1.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-13-14.html">Next</A></P>
<HR>
<H1> 13.13.2 Stream-Oriented Attributes</H1>
<DIV Class="Paranum"><FONT SIZE=-2>1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0009">8652/0009</A></I>}
The <U>operational attributes </U>Write, Read, Output, and Input <S>attributes
</S>convert values to a stream of elements and reconstruct values from
a stream. </DIV>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;For every subtype S of a specific type <I>T</I>,
the following attributes are defined. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;S'Write<DD Class="Hanging">
<A NAME="I4722"></A><A NAME="I4723"></A>S'Write denotes a procedure with
the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>procedure</B>&nbsp;S'Write(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class;<BR>
&nbsp;&nbsp;&nbsp;<I>Item</I>&nbsp;:&nbsp;<B>in</B>&nbsp;<I>T</I>)</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">S'Write writes the value of <I>Item</I> to <I>Stream</I>.</DL>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;S'Read<DD Class="Hanging">
<A NAME="I4724"></A><A NAME="I4725"></A>S'Read denotes a procedure with
the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>procedure</B>&nbsp;S'Read(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class;<BR>
&nbsp;&nbsp;&nbsp;<I>Item</I>&nbsp;:&nbsp;<B>out</B>&nbsp;<I>T</I>)</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">S'Read reads the value of <I>Item</I> from <I>Stream</I>.
</DL>
<DIV Class="Paranum"><FONT SIZE=-2>8.1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0040">8652/0040</A></I>}
<U>For untagged derived types, the Write and Read attributes of the parent
type are inherited as specified in <A HREF="AA-13-1.html">13.1</A>; otherwise,
the default implementations of these attributes are used. The default
implementations of Write and Read attributes execute as follows:</U></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0040">8652/0040</A></I>}
For elementary types, the representation in terms of stream elements
is implementation defined. For composite types, the Write or Read attribute
for each component is called in <S>a </S>canonical order<U>, which</U><S>.
The canonical order of components</S> is last dimension varying fastest
for an array, and positional aggregate order for a record. Bounds are
not included in the stream if <I>T</I> is an array type. If <I>T</I>
is a discriminated type, discriminants are included only if they have
defaults. If <I>T</I> is a tagged type, the tag is not included. <U>For
type extensions, the Write or Read attribute for the parent type is called,
followed by the Write or Read attribute of each component of the extension
part, in canonical order. For a limited type extension, if the attribute
of any ancestor type of <I>T</I> has been directly specified and the
attribute of any ancestor type of the type of any of the extension components
which are of a limited type has not been specified, the attribute of
<I>T</I> shall be directly specified.</U></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Implementation defined: </B>The
representation used by the Read and Write attributes of elementary types
in terms of stream elements.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.b</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>A discriminant
with a default value is treated simply as a component of the object.
On the other hand, an array bound or a discriminant without a default
value, is treated as ``descriptor'' or ``dope'' that must be provided
in order to create the object and thus is logically separate from the
regular components. Such ``descriptor'' data are written by 'Output and
produced as part of the delivered result by the 'Input function, but
they are not written by 'Write nor read by 'Read. A tag is like a discriminant
without a default.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.b.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>{<I><A HREF="defect1.html#8652/0040">8652/0040</A></I>}
<U>For limited type extensions, we must have a definition of 'Read and
'Write if the parent type has one, as it is possible to make a dispatching
call through the attributes. The rule is designed to automatically do
the right thing in as many cases as possible.</U> </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9.c</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>For a composite
object, the subprogram denoted by the Write or Read attribute of each
component is called, whether it is the default or is user-specified.
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;For every subtype
S'Class of a class-wide type <I>T</I>'Class: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;&nbsp;S'Class'Write<DD Class="Hanging">
<A NAME="I4726"></A><A NAME="I4727"></A>S'Class'Write denotes a procedure
with the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>procedure</B>&nbsp;S'Class'Write(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class;<BR>
&nbsp;&nbsp;&nbsp;<I>Item</I>&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;<I>T</I>'Class)</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">Dispatches to the subprogram denoted by the Write
attribute of the specific type identified by the tag of Item.</DL>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;&nbsp;S'Class'Read<DD Class="Hanging">
<A NAME="I4728"></A><A NAME="I4729"></A>S'Class'Read denotes a procedure
with the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>procedure</B>&nbsp;S'Class'Read(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class;<BR>
&nbsp;&nbsp;&nbsp;<I>Item</I>&nbsp;:&nbsp;<B>out</B>&nbsp;<I>T</I>'Class)</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">Dispatches to the subprogram denoted by the Read
attribute of the specific type identified by the tag of Item. </DL>
<DIV Class="Paranum"><FONT SIZE=-2>16.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>It is necessary
to have class-wide versions of Read and Write in order to avoid generic
contract model violations; in a generic, we don't necessarily know at
compile time whether a given type is specific or class-wide. </FONT></DIV>

<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;If a stream element is the same size as a storage
element, then the normal in-memory representation should be used by Read
and Write for scalar objects. Otherwise, Read and Write should use the
smallest number of stream elements needed to represent all values in
the base range of the scalar type.</DIV>

<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>18</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;For every subtype S of a specific type <I>T</I>,
the following attributes are defined. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;&nbsp;S'Output<DD Class="Hanging">
<A NAME="I4730"></A><A NAME="I4731"></A>S'Output denotes a procedure
with the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>procedure</B>&nbsp;S'Output(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class;<BR>
&nbsp;&nbsp;&nbsp;<I>Item</I>&nbsp;:&nbsp;<B>in</B>&nbsp;<I>T</I>)</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">S'Output writes the value of <I>Item</I> to <I>Stream</I>,
including any bounds or discriminants. </DL>
<DIV Class="Paranum"><FONT SIZE=-2>21.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Note that
the bounds are included even for an array type whose first subtype is
constrained. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;&nbsp;S'Input<DD Class="Hanging">
<A NAME="I4732"></A><A NAME="I4733"></A>S'Input denotes a function with
the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>function</B>&nbsp;S'Input(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class)<BR>
&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;<I>T</I></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">S'Input reads and returns one value from <I>Stream</I>,
using any bounds or discriminants written by a corresponding S'Output
to determine how much to read. </DL>
<DIV Class="Paranum"><FONT SIZE=-2>25/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0040">8652/0040</A></I>}
<U>For untagged derived types, the Output and Input attributes of the
parent type are inherited as specified in <A HREF="AA-13-1.html">13.1</A>;
otherwise, the default implementations of these attributes are used.
The default implementations of Output and Input attributes execute as
follows:</U><S>Unless overridden by an <FONT FACE="Arial, Helvetica">attribute_definition_clause</FONT>,
these subprograms execute as follows:</S></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<UL Class="Bulleted" Style="margin-bottom: 0.3em"><LI TYPE=DISC>If <I>T</I> is an array type, S'Output first writes the
bounds, and S'Input first reads the bounds. If <I>T</I> has discriminants
without defaults, S'Output first writes the discriminants (using S'Write
for each), and S'Input first reads the discriminants (using S'Read for
each).</LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<UL Class="Bulleted"><LI TYPE=DISC>S'Output then calls S'Write to write the value of <I>Item</I>
to the stream. S'Input then creates an object (with the bounds or discriminants,
if any, taken from the stream), initializes it with S'Read, and returns
the value of the object. </LI></UL>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;For every subtype
S'Class of a class-wide type <I>T</I>'Class: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>29</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;&nbsp;S'Class'Output<DD Class="Hanging">
<A NAME="I4734"></A><A NAME="I4735"></A>S'Class'Output denotes a procedure
with the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>30</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>procedure</B>&nbsp;S'Class'Output(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class;<BR>
&nbsp;&nbsp;&nbsp;<I>Item</I>&nbsp;&nbsp;&nbsp;:&nbsp;<B>in</B>&nbsp;<I>T</I>'Class)</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>31</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">First writes the external tag of <I>Item</I> to
<I>Stream</I> (by calling String'Output(Tags.External_Tag(<I>Item</I>'Tag)
-- see <A HREF="AA-3-9.html">3.9</A>) and then dispatches to the subprogram
denoted by the Output attribute of the specific type identified by the
tag.</DL>
<DIV Class="Paranum"><FONT SIZE=-2>32</FONT></DIV>
<DL Class="Hanging" Style="margin-bottom: 0.4em"><DT>&nbsp;&nbsp;&nbsp;&nbsp;S'Class'Input<DD Class="Hanging">
<A NAME="I4736"></A><A NAME="I4737"></A>S'Class'Input denotes a function
with the following specification: </DL>
<DIV Class="Paranum"><FONT SIZE=-2>33</FONT></DIV>
<DIV Class="IndentedExamples"><TT><B>function</B>&nbsp;S'Class'Input(<BR>
&nbsp;&nbsp;&nbsp;<I>Stream</I>&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class)<BR>
&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;<I>T</I>'Class</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>34</FONT></DIV>
<DL Class="Hanging"><DD Class ="Hanging">First reads the external tag from <I>Stream</I>
and determines the corresponding internal tag (by calling Tags.Internal_Tag(String'Input(<I>Stream</I>))
-- see <A HREF="AA-3-9.html">3.9</A>) and then dispatches to the subprogram
denoted by the Input attribute of the specific type identified by the
internal tag; returns that result. </DL>
<DIV Class="Paranum"><FONT SIZE=-2>35</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;<A NAME="I4738"></A><A NAME="I4739"></A>In the
default implementation of Read and Input for a composite type, for each
scalar component that is a discriminant or whose <FONT FACE="Arial, Helvetica">component_declaration</FONT>
includes a <FONT FACE="Arial, Helvetica">default_expression</FONT>, a
check is made that the value returned by Read for the component belongs
to its subtype. <A NAME="I4740"></A>Constraint_Error is raised if this
check fails. For other scalar components, no check is made. For each
component that is of an access type, if the implementation can detect
that the value returned by Read for the component is not a value of its
subtype, Constraint_Error is raised. If the value is not a value of its
subtype and this error is not detected, the component has an abnormal
value, and erroneous execution can result (see <A HREF="AA-13-9-1.html">13.9.1</A>).</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>35.1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0045">8652/0045</A></I>}
<U><A NAME="I4741"></A>In the default implementation of Read and Input
for a type, End_Error is raised if the end of the stream is reached before
the reading of a value of the type is completed.</U></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0040">8652/0040</A></I>}
<A NAME="I4742"></A><A NAME="I4743"></A><A NAME="I4744"></A><A NAME="I4745"></A><A NAME="I4746"></A><A NAME="I4747"></A><A NAME="I4748"></A><A NAME="I4749"></A>The
stream-oriented attributes may be specified for any type via an <FONT FACE="Arial, Helvetica">attribute_definition_clause</FONT>.
All nonlimited types have default implementations for these operations.
An <FONT FACE="Arial, Helvetica">attribute_reference</FONT> for one of
these attributes is illegal if the type is limited, unless the attribute
has been specified by an <FONT FACE="Arial, Helvetica">attribute_definition_clause</FONT><U>
or [(for a type extension)] the attribute has been specified for an ancestor
type</U>. For an <FONT FACE="Arial, Helvetica">attribute_definition_clause</FONT>
specifying one of these attributes, the subtype of the Item parameter
shall be the base subtype if scalar, and the first subtype otherwise.
The same rule applies to the result of the Input function. </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Reason: </B>This is to simplify
implementation. </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>36.a.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Discussion: </B>{<I><A HREF="defect1.html#8652/0040">8652/0040</A></I>}
<U>``Specified'' includes inherited attributes, and default implementations
are never inherited. So, for untagged limited types, the second part
of the <FONT FACE="Arial, Helvetica">attribute_reference</FONT> rule
has the same meaning as the first part. However, tagged types never inherit
attributes, so the second rule is needed so that the default implementations
for the attributes can be called when those are constructed from a directly
specified ancestor.</U> </FONT></DIV>

<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>36.1/1</FONT></DIV>
<DIV Class="Normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<I><A HREF="defect1.html#8652/0040">8652/0040</A></I>}
<U>For every subtype <I>S</I> of a language-defined nonlimited specific
type <I>T</I>, the output generated by S'Output or S'Write shall be readable
by S'Input or S'Read, respectively. This rule applies across partitions
if the implementation conforms to the Distributed Systems Annex.</U>
</DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>37</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>31&nbsp;&nbsp;For a definite subtype
S of a type <I>T</I>, only <I>T</I>'Write and <I>T</I>'Read are needed
to pass an arbitrary value of the subtype through a stream. For an indefinite
subtype S of a type <I>T</I>, <I>T</I>'Output and <I>T</I>'Input will
normally be needed, since <I>T</I>'Write and <I>T</I>'Read do not pass
bounds, discriminants, or tags.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>38</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>32&nbsp;&nbsp;User-specified attributes
of S'Class are not inherited by other class-wide types descended from
S. </FONT></DIV>

<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>39</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em">&nbsp;&nbsp;&nbsp;&nbsp;<I>Example of user-defined
Write attribute:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40</FONT></DIV>
<DIV Class="Examples"><TT><B>procedure</B>&nbsp;My_Write(<BR>
&nbsp;&nbsp;Stream&nbsp;:&nbsp;<B>access</B>&nbsp;Ada.Streams.Root_Stream_Type'Class;&nbsp;Item&nbsp;:&nbsp;My_Integer'Base);<BR>
<B>for</B>&nbsp;My_Integer'Write&nbsp;<B>use</B>&nbsp;My_Write;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.a</FONT></DIV>
<DIV Class="Annotations" Style="margin-bottom: 0.4em"><FONT SIZE=-1><B>Discussion:
</B><I>Example of network input/output using input output attributes:</I>
</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.b</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>with</B>&nbsp;Ada.Streams;&nbsp;<B>use</B>&nbsp;Ada.Streams;<BR>
<B>generic</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Msg_Type(&lt;&gt;)&nbsp;<B>is&nbsp;private</B>;<BR>
<B>package</B>&nbsp;Network_IO&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<I>--&nbsp;Connect/Disconnect&nbsp;are&nbsp;used&nbsp;to&nbsp;establish&nbsp;the&nbsp;stream</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Connect(...);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Disconnect(...);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.c</FONT></DIV>
<DIV Class="SmallExamples"><TT>&nbsp;&nbsp;&nbsp;&nbsp;<I>--&nbsp;Send/Receive&nbsp;transfer&nbsp;messages&nbsp;across&nbsp;the&nbsp;network</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Send(X&nbsp;:&nbsp;<B>in</B>&nbsp;Msg_Type);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;Receive&nbsp;<B>return</B>&nbsp;Msg_Type;<BR>
<B>private</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>type</B>&nbsp;Network_Stream&nbsp;<B>is&nbsp;new</B>&nbsp;Root_Stream_Type&nbsp;<B>with</B>&nbsp;...<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Read(...);&nbsp;&nbsp;<I>--&nbsp;define&nbsp;Read/Write&nbsp;for&nbsp;Network_Stream</I><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Write(...);<BR>
<B>end</B>&nbsp;Network_IO;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.d</FONT></DIV>
<DIV Class="SmallExamples"><TT><B>with</B>&nbsp;Ada.Streams;&nbsp;<B>use</B>&nbsp;Ada.Streams;<BR>
<B>package&nbsp;body</B>&nbsp;Network_IO&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;Current_Stream&nbsp;:&nbsp;<B>aliased</B>&nbsp;Network_Stream;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;.&nbsp;.&nbsp;.<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Connect(...)&nbsp;<B>is</B>&nbsp;...;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Disconnect(...)&nbsp;<B>is</B>&nbsp;...;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.e</FONT></DIV>
<DIV Class="SmallExamples"><TT>&nbsp;&nbsp;&nbsp;&nbsp;<B>procedure</B>&nbsp;Send(X&nbsp;:&nbsp;<B>in</B>&nbsp;Msg_Type)&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>begin</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Msg_Type'Output(Current_Stream'Access,&nbsp;X);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;Send;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>40.f</FONT></DIV>
<DIV Class="SmallExamples"><TT>&nbsp;&nbsp;&nbsp;&nbsp;<B>function</B>&nbsp;Receive&nbsp;<B>return</B>&nbsp;Msg_Type&nbsp;<B>is</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>begin</B><BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>return</B>&nbsp;Msg_Type'Input(Current_Stream'Access);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;<B>end</B>&nbsp;Receive;<BR>
<B>end</B>&nbsp;Network_IO;</TT></DIV>

<HR>
<P><A HREF="AA-TOC.html">Contents</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-0-29.html">Index</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-13-13-1.html">Previous</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-13-14.html">Next</A>&nbsp;&nbsp;&nbsp;<A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>