0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / StepData / StepData_StepWriter.cdl
1 -- Created on: 1992-02-11
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1992-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
5 --
6 -- This file is part of Open CASCADE Technology software library.
7 --
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
13 --
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
16
17 class StepWriter  from StepData
18
19     ---Purpose : manages atomic file writing, under control of StepModel (for
20     --           general organisation of file) and each class of Transient
21     --           (for its own parameters) : prepares text to be written then
22     --           writes it
23     --           A stream cannot be used because Step limits line length at 72
24     --           In more, a specific object offers more appropriate functions
25
26 uses Integer, Boolean, Real, Character, Transient, Logical from StepData,     -- OStream,
27      AsciiString from TCollection,  HAsciiString from TCollection,
28      HSequenceOfHAsciiString,  HArray1OfInteger,
29      LineBuffer, FloatWriter, CheckIterator,
30      StepModel, WriterLib, Protocol from StepData,
31      SelectMember from StepData, Field from StepData, PDescr from StepData,
32      FieldList from StepData, ESDescr from StepData,
33      HArray1OfReal from TColStd
34
35 raises InterfaceMismatch
36
37 is
38
39     Create (amodel : StepModel) returns StepWriter;
40     ---Purpose : Creates an empty StepWriter from a StepModel. The StepModel
41     --           provides the Number of Entities, as identifiers for File
42
43         --  Options for Sending Forms  --
44
45     LabelMode (me : in out) returns Integer;
46     ---Purpose : ModeLabel controls how to display entity ids :
47     --           0 (D) gives entity number in the model
48     --           1 gives the already recorded label (else, its number)
49     --  Warning : conflicts are not controlled
50     ---C++ : return &
51
52     TypeMode  (me : in out) returns Integer;
53     ---Purpose : TypeMode  controls the type form to use :
54     --           0 (D) for normal long form
55     --           1 for short form (if a type name has no short form, normal
56     --             long form is then used)
57     ---C++ : return &
58
59     FloatWriter (me : in out) returns FloatWriter;
60     ---Purpose : Returns the embedded FloatWriter, which controls sending Reals
61     --           Use this method to access FloatWriter in order to consult or
62     --           change its options (MainFormat, FormatForRange,ZeroSuppress),
63     --           because it is returned as the address of its field
64     ---C++ : return &
65
66         -- --  Description of Scopes  -- --   (to be done before sending)
67
68     SetScope (me : in out; numscope,numin : Integer)
69     ---Purpose : Declares the Entity Number <numscope> to correspond to a Scope
70     --           which contains the Entity Number <numin>. Several calls to the
71     --           same <numscope> add Entities in this Scope, in this order.
72         raises InterfaceMismatch;
73     ---Purpose:           Error if <numin> is already declared in the Scope
74     --  Warning : the declaration of the Scopes is assumed to be consistent,
75     --           i.e. <numin> is not referenced from outside this Scope
76     --           (not checked here)
77
78     IsInScope (me; num : Integer) returns Boolean;
79     ---Purpose : Returns True if an Entity identified by its Number is in a Scope
80
81         -- --  Sending Parts of a Model  -- --
82
83     SendModel  (me : in out; protocol : Protocol from StepData;
84                              headeronly : Boolean = Standard_False)
85     ---Purpose : Sends the complete Model, included HEADER and DATA Sections
86     --           Works with a WriterLib defined through a Protocol
87     --           If <headeronly> is given True, only the HEADER Section is sent
88     --           (used to Dump the Header of a StepModel)
89       raises InterfaceMismatch;
90     --           Error if any of the called Send's falls in Error
91
92     SendHeader (me : in out);
93     ---Purpose : Begins model header
94
95     SendData (me : in out) raises InterfaceMismatch;
96     ---Purpose : Begins data section; error if EndSec was not set
97
98     SendEntity (me : in out; nument : Integer; lib : WriterLib)
99     ---Purpose : Send an Entity of the Data Section. If it corresponds to a
100     --           Scope, also Sends the Scope informations and contained Items
101       raises InterfaceMismatch;
102     --           Error if any of the called Send's falls in Error
103
104     EndSec (me : in out);
105     ---Purpose : sets end of section; to be done before passing to next one
106
107     EndFile (me : in out)  raises InterfaceMismatch;
108     ---Purpose : sets end of file; error is EndSec was not set
109
110         -- --   Managing line   -- --
111
112     AddString (me : in out; str : AsciiString from TCollection; more : Integer = 0)
113         is private;
114     ---Purpose : adds a string to current line; first flushes it if full
115     --           (72 char); more allows to ask a reserve at end of line : flush
116     --           is done if remaining length (to 72) is less than <more>
117
118     AddString (me : in out; str : CString; lnstr : Integer; more : Integer = 0)
119         is private;
120     ---Purpose : Same as above, but the string is given by CString + Length
121
122
123     NewLine (me : in out; evenempty : Boolean);
124     ---Purpose : flushes current line; if empty, flushes it (defines a new
125     --           empty line) if evenempty is True; else, skips it
126
127     JoinLast (me : in out; newline : Boolean);
128     ---Purpose : joins current line to last one, only if new length is 72 max
129     --           if newline is True, a new current line begins; else, current
130     --           line is set to the last line (once joined) itself an can be
131     --           completed
132
133     Indent (me : in out; onent : Boolean);
134     ---Purpose : asks that further indentations will begin at position of
135     --           entity first opening bracket; else they begin at zero (def)
136     --           for each sublist level, two more blancks are added at beginning
137     --           (except for text continuation, which must begin at true zero)
138
139         -- --   Sending entities   -- --
140
141     SendIdent (me : in out; ident : Integer);
142     ---Purpose : begins an entity with an ident plus '=' (at beginning of line)
143     --           entity ident is its Number given by the containing Model
144     --  Warning : <ident> must be, either Number or Label, according LabelMode
145
146     SendScope (me : in out);
147     ---Purpose : sets a begin of Scope (ends this line)
148
149     SendEndscope (me : in out);
150     ---Purpose : sets an end of Scope  (on a separate line)
151
152     Comment (me : in out; mode : Boolean);
153     ---Purpose : sets a comment mark : if mode is True, begins Comment zone,
154     --           if mode is False, ends Comment zone (if one is begun)
155
156     SendComment (me : in out; text : HAsciiString from TCollection)
157       raises InterfaceMismatch;
158     ---Purpose : sends a comment. Error if we are not inside a comment zone
159
160     SendComment (me : in out; text : CString)  raises InterfaceMismatch;
161     ---Purpose : same as above but accepts a CString (ex.: "..." directly)
162
163     StartEntity (me : in out; atype : AsciiString from TCollection);
164     ---Purpose : sets entity's StepType, opens brakets, starts param no to 0
165     --           params are separated by comma
166     --           Remark : for a Multiple Type Entity (see Express ANDOR clause)
167     --           StartComplex must be called before sending componants, then
168     --           each "Componant" must be send separately (one call to
169     --           StartEntity for each one) : the Type which preceeds is then
170     --           automaticaly closed. Once all the componants have been sent,
171     --           EndComplex must be called, then and only then EndEntity
172
173     StartComplex (me : in out);
174     ---Purpose : sends the start of a complex entity, which is a simple open
175     --           bracket (without increasing braket level)
176     --           It must be called JUST AFTER SendEntity and BEFORE sending
177     --           componants, each one begins by StartEntity
178
179     EndComplex   (me : in out);
180     ---Purpose : sends the end of a complex entity : a simple closed bracket
181     --           It must be called AFTER sending all the componants and BEFORE
182     --           the final call to EndEntity
183
184         -- --   Sending Parameters   -- --
185
186     SendField  (me : in out; fild : Field; descr : PDescr);
187     ---Purpose : Sends the content of a field, controlled by its descriptor
188     --           If the descriptor is not defined, follows the description
189     --           detained by the field itself
190
191     SendSelect (me : in out; sm : SelectMember; descr : PDescr);
192     ---Purpose : Sends a SelectMember, which cab be named or not
193
194     SendList   (me : in out; list : FieldList; descr : ESDescr);
195     ---Purpose : Send the content of an entity as being a FieldList controlled
196     --           by its descriptor. This includes start and end brackets but
197     --           not the entity type
198
199     OpenSub (me : in out);
200     ---Purpose : open a sublist by a '('
201
202     OpenTypedSub (me : in out; subtype : CString);
203     ---Purpose : open a sublist with its type then a '('
204
205     CloseSub (me : in out);
206     ---Purpose : closes a sublist by a ')'
207
208     AddParam (me : in out);
209     ---Purpose : prepares adding a parameter (that is, adds ',' except for
210     --           first one); normally for internal use; can be used to send
211     --           a totally empty parameter (with no litteral value)
212
213     Send (me : in out; val : Integer);
214     ---Purpose : sends an integer parameter
215
216     Send (me : in out; val : Real);
217     ---Purpose : sends a real parameter (wroks with FloatWriter)
218
219     Send (me : in out; val : AsciiString from TCollection);
220     ---Purpose : sends a text given as string (it will be set between '...')
221
222     Send (me : in out; val : Transient);
223     ---Purpose : sends a reference to an entity (its identifier with '#')
224     --           REMARK 1 : a Null <val> is interpreted as "Undefined"
225     --           REMARK 2 : for an HAsciiString which is not recorded in the
226     --           Model, it is send as its String Content, between quotes
227
228     SendBoolean (me : in out; val : Boolean);
229     ---Purpose : sends a Boolean as .T. for True or .F. for False
230     --           (it is an useful case of Enum, which is built-in)
231
232     SendLogical (me : in out; val : Logical from StepData);
233     ---Purpose : sends a Logical as .T. or .F. or .U. according its Value
234     --           (it is a standard case of Enum for Step, and is built-in)
235
236     SendString (me : in out; val : AsciiString from TCollection);
237     ---Purpose : sends a string exactly as it is given
238
239     SendString (me : in out; val : CString);
240     ---Purpose : sends a string exactly as it is given
241
242     SendEnum (me : in out; val : AsciiString from TCollection);
243     ---Purpose : sends an enum given by String (litteral expression)
244     --           adds '.' around it if not done
245     --           Remark : val can be computed by class EnumTool from StepData:
246     --             StepWriter.SendEnum (myenum.Text(enumval));
247
248     SendEnum (me : in out; val : CString);
249     ---Purpose : sends an enum given by String (litteral expression)
250     --           adds '.' around it if not done
251
252     SendArrReal(me : in out; anArr : HArray1OfReal from TColStd);
253     ---Purpose : sends an array of real
254
255     SendUndef (me : in out);
256     ---Purpose : sends an undefined (optionnal absent) parameter (by '$')
257
258     SendDerived (me : in out);
259     ---Purpose : sends a "Derived" parameter (by '*'). A Derived Parameter has
260     --           been inherited from a Super-Type then redefined as being
261     --           computed by a function. Hence its value in file is senseless.
262
263     EndEntity (me : in out) raises InterfaceMismatch;
264     ---Purpose : sends end of entity (closing bracket plus ';')
265     --           Error if count of opened-closed brackets is not null
266
267         -- --   Printing on an output   -- --
268
269     CheckList (me) returns CheckIterator;
270     ---Purpose : Returns the check-list, which has received possible checks :
271     --           for unknown entities, badly loaded ones, null or unknown
272     --           references
273
274     NbLines (me) returns Integer;
275     ---Purpose : Returns count of Lines
276
277     Line (me; num : Integer) returns HAsciiString from TCollection;
278     ---Purpose : Returns a Line given its rank in the File
279
280     Print (me : in out; S : in out OStream) returns Boolean;
281     ---Purpose : writes result on an output defined as an OStream
282     --           then clears it
283
284 fields
285
286     themodel  : StepModel;
287     thefile   : HSequenceOfHAsciiString;
288     thecurr   : LineBuffer;
289     thesect   : Boolean;  -- False at very start or after EndSec
290     thecomm   : Boolean;  -- are we in inside a comment
291     thefirst  : Boolean;  -- True on first parameter, False on following ones
292     themult   : Boolean;  -- True after sending first type (for Multiple Type)
293     thelevel  : Integer;  -- current sublist level
294     theindent : Boolean;  -- True to indent at entity opening bracket
295     theindval : Integer;  -- position of entity opening bracket
296
297     thetypmode   : Integer;
298     thefloatw : FloatWriter;  -- control of sending Reals
299
300     thechecks    : CheckIterator;
301     thenum       : Integer;
302
303     thelabmode   : Integer;
304     thescopebeg  : HArray1OfInteger;
305     thescopeend  : HArray1OfInteger;
306     thescopenext : HArray1OfInteger;
307
308 end StepWriter;