0026586: Eliminate compile warnings obtained by building occt with vc14: declaration...
[occt.git] / src / StepData / StepData_StepReaderData.hxx
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 #ifndef _StepData_StepReaderData_HeaderFile
18 #define _StepData_StepReaderData_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TColStd_Array1OfInteger.hxx>
24 #include <Interface_IndexedMapOfAsciiString.hxx>
25 #include <TColStd_DataMapOfIntegerInteger.hxx>
26 #include <Standard_Integer.hxx>
27 #include <Interface_FileReaderData.hxx>
28 #include <Standard_CString.hxx>
29 #include <Interface_ParamType.hxx>
30 #include <Standard_Boolean.hxx>
31 #include <TColStd_SequenceOfAsciiString.hxx>
32 #include <Standard_Real.hxx>
33 #include <Standard_Type.hxx>
34 #include <StepData_Logical.hxx>
35 class Interface_Check;
36 class TCollection_AsciiString;
37 class StepData_PDescr;
38 class Standard_Transient;
39 class StepData_SelectMember;
40 class StepData_Field;
41 class StepData_ESDescr;
42 class StepData_FieldList;
43 class StepData_SelectType;
44 class TCollection_HAsciiString;
45 class StepData_EnumTool;
46
47
48 class StepData_StepReaderData;
49 DEFINE_STANDARD_HANDLE(StepData_StepReaderData, Interface_FileReaderData)
50
51 //! Specific FileReaderData for Step
52 //! Contains litteral description of entities (for each one : type
53 //! as a string, ident, parameter list)
54 //! provides references evaluation, plus access to litteral data
55 //! and specific access methods (Boolean, XY, XYZ)
56 class StepData_StepReaderData : public Interface_FileReaderData
57 {
58
59 public:
60
61   
62   //! creates StepReaderData correctly dimensionned (necessary at
63   //! creation time, because it contains arrays)
64   //! nbheader is nb of records for Header, nbtotal for Header+Data
65   //! and nbpar gives the total count of parameters
66   Standard_EXPORT StepData_StepReaderData(const Standard_Integer nbheader, const Standard_Integer nbtotal, const Standard_Integer nbpar);
67   
68   //! Fills the fields of a record
69   Standard_EXPORT void SetRecord (const Standard_Integer num, const Standard_CString ident, const Standard_CString type, const Standard_Integer nbpar);
70   
71   //! Fills the fields of a parameter of a record. This is a variant
72   //! of AddParam, Adapted to STEP (optimized for specific values)
73   Standard_EXPORT void AddStepParam (const Standard_Integer num, const Standard_CString aval, const Interface_ParamType atype, const Standard_Integer nument = 0);
74   
75   //! Returns Record Type
76   Standard_EXPORT const TCollection_AsciiString& RecordType (const Standard_Integer num) const;
77   
78   //! Returns Record Type as a CString
79   //! was C++ : return const
80   Standard_EXPORT Standard_CString CType (const Standard_Integer num) const;
81   
82   //! Returns record identifier (Positive number)
83   //! If returned ident is not positive : Sub-List or Scope mark
84   Standard_EXPORT Standard_Integer RecordIdent (const Standard_Integer num) const;
85   
86   //! Returns SubList numero designated by a parameter (nump) in a
87   //! record (num), or zero if the parameter does not exist or is
88   //! not a SubList address. Zero too If aslast is True and nump
89   //! is not for the last parameter
90   Standard_EXPORT Standard_Integer SubListNumber (const Standard_Integer num, const Standard_Integer nump, const Standard_Boolean aslast) const;
91   
92   //! Returns True if <num> corresponds to a Complex Type Entity
93   //! (as can be defined by ANDOR Express clause)
94   Standard_EXPORT Standard_Boolean IsComplex (const Standard_Integer num) const;
95   
96   //! Returns the List of Types which correspond to a Complex Type
97   //! Entity. If not Complex, there is just one Type in it
98   //! For a SubList or a Scope mark, <types> remains empty
99   Standard_EXPORT void ComplexType (const Standard_Integer num, TColStd_SequenceOfAsciiString& types) const;
100   
101   //! Returns the Next "Componant" for a Complex Type Entity, of
102   //! which <num> is already a Componant (the first one or a next one)
103   //! Returns 0 for a Simple Type or for the last Componant
104   Standard_EXPORT Standard_Integer NextForComplex (const Standard_Integer num) const;
105   
106   //! Determines the first component which brings a given name, for
107   //! a Complex Type Entity
108   //! <num0> is the very first record of this entity
109   //! <num> is given the last NextNamedForComplex, starts at zero
110   //! it is returned as the newly found number
111   //! Hence, in the normal case, NextNamedForComplex starts by num0
112   //! if <num> is zero, else by NextForComplex(num)
113   //! If the alphabetic order is not respected, it restarts from
114   //! num0 and loops on NextForComplex until finding <name>
115   //! In case of "non-alphabetic order", <ach> is filled with a
116   //! Warning for this name
117   //! In case of "not-found at all", <ach> is filled with a Fail,
118   //! and <num> is returned as zero
119   //!
120   //! Returns True if alphabetic order, False else
121   Standard_EXPORT Standard_Boolean NamedForComplex (const Standard_CString name, const Standard_Integer num0, Standard_Integer& num, Handle(Interface_Check)& ach) const;
122   
123   //! Checks Count of Parameters of record <num> to equate <nbreq>
124   //! If this Check is successful, returns True
125   //! Else, fills <ach> with an Error Message then returns False
126   //! <mess> is included in the Error message if given non empty
127   Standard_EXPORT Standard_Boolean CheckNbParams (const Standard_Integer num, const Standard_Integer nbreq, Handle(Interface_Check)& ach, const Standard_CString mess = "") const;
128   
129   //! reads parameter <nump> of record <num> as a sub-list (may be
130   //! typed, see ReadTypedParameter in this case)
131   //! Returns True if OK. Else (not a LIST), returns false and
132   //! feeds Check with appropriate check
133   //! If <optional> is True and Param is not defined, returns True
134   //! with <ach> not filled and <numsub> returned as 0
135   //! Works with SubListNumber with <aslast> false (no specific case
136   //! for last parameter)
137   Standard_EXPORT Standard_Boolean ReadSubList (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Integer& numsub, const Standard_Boolean optional = Standard_False, const Standard_Integer lenmin = 0, const Standard_Integer lenmax = 0) const;
138   
139   //! reads the content of a sub-list into a transient :
140   //! SelectNamed, or HArray1 of Integer,Real,String,Transient ...
141   //! recursive call if list of list ...
142   //! If a sub-list has mixed types, an HArray1OfTransient is
143   //! produced, it may contain SelectMember
144   //! Intended to be called by ReadField
145   //! The returned status is : negative if failed, 0 if empty.
146   //! Else the kind to be recorded in the field
147   Standard_EXPORT Standard_Integer ReadSub (const Standard_Integer numsub, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(StepData_PDescr)& descr, Handle(Standard_Transient)& val) const;
148   
149   //! Reads parameter <nump> of record <num> into a SelectMember,
150   //! self-sufficient (no Description needed)
151   //! If <val> is already created, it will be filled, as possible
152   //! And if reading does not match its own description, the result
153   //! will be False
154   //! If <val> is not it not yet created, it will be (SelectNamed)
155   //! Usefull if a field is defined as a SelectMember, directly
156   //! (SELECT with no Entity as member)
157   //! But SelectType also manages SelectMember (for SELECT with
158   //! some members as Entity, some other not)
159   Standard_EXPORT Standard_Boolean ReadMember (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Handle(StepData_SelectMember)& val) const;
160   
161   //! reads parameter <nump> of record <num> into a Field,
162   //! controlled by a Parameter Descriptor (PDescr), which controls
163   //! its allowed type(s) and value
164   //! <ach> is filled if the read parameter does not match its
165   //! description (but the field is read anyway)
166   //! If the description is not defined, no control is done
167   //! Returns True when done
168   Standard_EXPORT Standard_Boolean ReadField (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(StepData_PDescr)& descr, StepData_Field& fild) const;
169   
170   //! reads a list of fields controlled by an ESDescr
171   Standard_EXPORT Standard_Boolean ReadList (const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepData_ESDescr)& descr, StepData_FieldList& list) const;
172   
173   //! Reads parameter <nump> of record <num> into a Transient Value
174   //! according to the type of the parameter :
175   //! Named for Integer,Boolean,Logical,Enum,Real : SelectNamed
176   //! Immediate Integer,Boolean,Logical,Enum,Real : SelectInt/Real
177   //! Text  : HAsciiString
178   //! Ident : the referenced Entity
179   //! Sub-List not processed, see ReadSub
180   //! This value is controlled by a Parameter Descriptor (PDescr),
181   //! which controls its allowed type and value
182   //! <ach> is filled if the read parameter does not match its
183   //! description (the select is nevertheless created if possible)
184   //!
185   //! Warning : val is in out, hence it is possible to predefine a specific
186   //! SelectMember then to fill it. If <val> is Null or if the
187   //! result is not a SelectMember, val itself is returned a new ref
188   //! For a Select with a Name, <val> must then be a SelectNamed
189   Standard_EXPORT Standard_Boolean ReadAny (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(StepData_PDescr)& descr, Handle(Standard_Transient)& val) const;
190   
191   //! reads parameter <nump> of record <num> as a sub-list of
192   //! two Reals X,Y. Returns True if OK. Else, returns false and
193   //! feeds Check with appropriate Fails (parameter not a sub-list,
194   //! not two Reals in the sub-list) composed with "mess" which
195   //! gives the name of the parameter
196   Standard_EXPORT Standard_Boolean ReadXY (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Real& X, Standard_Real& Y) const;
197   
198   //! reads parameter <nump> of record <num> as a sub-list of
199   //! three Reals X,Y,Z. Return value and Check managed as by
200   //! ReadXY (demands a sub-list of three Reals)
201   Standard_EXPORT Standard_Boolean ReadXYZ (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const;
202   
203   //! reads parameter <nump> of record <num> as a single Real value.
204   //! Return value and Check managed as by ReadXY (demands a Real)
205   Standard_EXPORT Standard_Boolean ReadReal (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Real& val) const;
206   
207   //! Reads parameter <nump> of record <num> as a single Entity.
208   //! Return value and Check managed as by ReadReal (demands a
209   //! reference to an Entity). In Addition, demands read Entity
210   //! to be Kind of a required Type <atype>.
211   //! Remark that returned status is False and <ent> is Null if
212   //! parameter is not an Entity, <ent> remains Not Null is parameter
213   //! is an Entity but is not Kind of required type
214   Standard_EXPORT Standard_Boolean ReadEntity (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Handle(Standard_Type)& atype, Handle(Standard_Transient)& ent) const;
215   
216   //! Same as above, but a SelectType checks Type Matching, and
217   //! records the read Entity (see method Value from SelectType)
218   Standard_EXPORT Standard_Boolean ReadEntity (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, StepData_SelectType& sel) const;
219   
220   //! reads parameter <nump> of record <num> as a single Integer.
221   //! Return value & Check managed as by ReadXY (demands an Integer)
222   Standard_EXPORT Standard_Boolean ReadInteger (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Integer& val) const;
223   
224   //! reads parameter <nump> of record <num> as a Boolean
225   //! Return value and Check managed as by ReadReal (demands a
226   //! Boolean enum, i.e. text ".T." for True or ".F." for False)
227   Standard_EXPORT Standard_Boolean ReadBoolean (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Boolean& flag) const;
228   
229   //! reads parameter <nump> of record <num> as a Logical
230   //! Return value and Check managed as by ReadBoolean (demands a
231   //! Logical enum, i.e. text ".T.", ".F.", or ".U.")
232   Standard_EXPORT Standard_Boolean ReadLogical (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, StepData_Logical& flag) const;
233   
234   //! reads parameter <nump> of record <num> as a String (text
235   //! between quotes, quotes are removed by the Read operation)
236   //! Return value and Check managed as by ReadXY (demands a String)
237   Standard_EXPORT Standard_Boolean ReadString (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Handle(TCollection_HAsciiString)& val) const;
238   
239   Standard_EXPORT Standard_Boolean ReadEnumParam (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_CString& text) const;
240   
241   //! Fills a check with a fail message if enumeration value does
242   //! match parameter definition
243   //! Just a help to centralize message definitions
244   Standard_EXPORT void FailEnumValue (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach) const;
245   
246   //! Reads parameter <nump> of record <num> as an Enumeration (text
247   //! between dots) and converts it to an integer value, by an
248   //! EnumTool. Returns True if OK, false if : this parameter is not
249   //! enumeration, or is not recognized by the EnumTool (with fail)
250   Standard_EXPORT Standard_Boolean ReadEnum (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const StepData_EnumTool& enumtool, Standard_Integer& val) const;
251   
252   //! Resolves a parameter which can be enclosed in a type def., as
253   //! TYPE(val). The parameter must then be read normally according
254   //! its type.  Parameter to be resolved is <nump> of record <num>
255   //! <mustbetyped> True  demands a typed parameter
256   //! <mustbetyped> False accepts a non-typed parameter as option
257   //! mess and ach as usual
258   //! <numr>,<numrp> are the resolved record and parameter numbers
259   //! = num,nump if no type,  else numrp=1
260   //! <typ> returns the recorded type, or empty string
261   //! Remark : a non-typed list is considered as "non-typed"
262   Standard_EXPORT Standard_Boolean ReadTypedParam (const Standard_Integer num, const Standard_Integer nump, const Standard_Boolean mustbetyped, const Standard_CString mess, Handle(Interface_Check)& ach, Standard_Integer& numr, Standard_Integer& numrp, TCollection_AsciiString& typ) const;
263   
264   //! Checks if parameter <nump> of record <num> is given as Derived
265   //! If this Check is successful (i.e. Param = "*"), returns True
266   //! Else, fills <ach> with a Message which contains <mess> and
267   //! returns False. According to <errstat>, this message is Warning
268   //! if errstat is False (Default), Fail if errstat is True
269   Standard_EXPORT Standard_Boolean CheckDerived (const Standard_Integer num, const Standard_Integer nump, const Standard_CString mess, Handle(Interface_Check)& ach, const Standard_Boolean errstat = Standard_False) const;
270   
271   //! Returns total count of Entities (including Header)
272   Standard_EXPORT virtual Standard_Integer NbEntities() const Standard_OVERRIDE;
273   
274   //! determines the first suitable record following a given one
275   //! that is, skips SCOPE,ENDSCOPE and SUBLIST records
276   //! Note : skips Header records, which are accessed separately
277   Standard_EXPORT Standard_Integer FindNextRecord (const Standard_Integer num) const;
278   
279   //! determines reference numbers in EntityNumber fields
280   //! called by Prepare from StepReaderTool to prepare later using
281   //! by a StepModel. This method is attached to StepReaderData
282   //! because it needs a massive amount of data accesses to work
283   //!
284   //! If <withmap> is given False, the basic exploration algorithm
285   //! is activated, otherwise a map is used as far as it is possible
286   //! this option can be used only to test this algorithm
287   Standard_EXPORT void SetEntityNumbers (const Standard_Boolean withmap = Standard_True);
288   
289   //! determine first suitable record of Header
290   //! works as FindNextRecord, but treats only Header records
291   Standard_EXPORT Standard_Integer FindNextHeaderRecord (const Standard_Integer num) const;
292   
293   //! Works as SetEntityNumbers but for Header : more simple because
294   //! there are no Reference, only Sub-Lists
295   Standard_EXPORT void PrepareHeader();
296   
297   //! Returns the Global Check. It can record Fail messages about
298   //! Undefined References (detected by SetEntityNumbers)
299   Standard_EXPORT const Handle(Interface_Check) GlobalCheck() const;
300
301
302
303
304   DEFINE_STANDARD_RTTI(StepData_StepReaderData,Interface_FileReaderData)
305
306 protected:
307
308
309
310
311 private:
312
313   
314   //! Searches for a Parameter of the record <num>, which refers to
315   //! the Ident <id> (form #nnn). [Used by SetEntityNumbers]
316   //! If found, returns its EntityNumber, else returns Zero.
317   Standard_EXPORT Standard_Integer FindEntityNumber (const Standard_Integer num, const Standard_Integer id) const;
318
319   TColStd_Array1OfInteger theidents;
320   TColStd_Array1OfInteger thetypes;
321   Interface_IndexedMapOfAsciiString thenametypes;
322   TColStd_DataMapOfIntegerInteger themults;
323   Standard_Integer thenbents;
324   Standard_Integer thelastn;
325   Standard_Integer thenbhead;
326   Standard_Integer thenbscop;
327   Handle(Interface_Check) thecheck;
328
329
330 };
331
332
333
334
335
336
337
338 #endif // _StepData_StepReaderData_HeaderFile