0030380: Exception while reading Step-file
[occt.git] / src / StepData / StepData_PDescr.hxx
CommitLineData
42cf5bc1 1// Created on: 1997-01-03
2// Created by: Christian CAILLET
3// Copyright (c) 1997-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_PDescr_HeaderFile
18#define _StepData_PDescr_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TCollection_AsciiString.hxx>
24#include <Standard_Integer.hxx>
25#include <StepData_EnumTool.hxx>
26#include <Standard_Type.hxx>
27#include <Standard_Boolean.hxx>
25e59720 28#include <Standard_Transient.hxx>
42cf5bc1 29#include <Standard_CString.hxx>
30class StepData_EDescr;
31class StepData_Field;
32class Interface_Check;
33
34
35class StepData_PDescr;
25e59720 36DEFINE_STANDARD_HANDLE(StepData_PDescr, Standard_Transient)
42cf5bc1 37
38//! This class is intended to describe the authorized form for a
39//! parameter, as a type or a value for a field
40//!
41//! A PDescr firstly describes a type, which can be SELECT, i.e.
42//! have several members
25e59720 43class StepData_PDescr : public Standard_Transient
42cf5bc1 44{
45
46public:
47
48
49 Standard_EXPORT StepData_PDescr();
50
51 Standard_EXPORT void SetName (const Standard_CString name);
52
53 Standard_EXPORT Standard_CString Name() const;
54
55 //! Declares this PDescr to be a Select, hence to have members
56 //! <me> itself can be the first member
57 Standard_EXPORT void SetSelect();
58
59 //! Adds a member to a SELECT description
60 Standard_EXPORT void AddMember (const Handle(StepData_PDescr)& member);
61
62 //! Sets a name for SELECT member. To be used if a member is for
63 //! an immediate type
64 Standard_EXPORT void SetMemberName (const Standard_CString memname);
65
66 //! Sets <me> for an Integer value
67 Standard_EXPORT void SetInteger();
68
69 //! Sets <me> for a Real value
70 Standard_EXPORT void SetReal();
71
72 //! Sets <me> for a String value
73 Standard_EXPORT void SetString();
74
75 //! Sets <me> for a Boolean value (false,true)
76 Standard_EXPORT void SetBoolean();
77
78 //! Sets <me> for a Logical value (false,true,unknown)
79 Standard_EXPORT void SetLogical();
80
81 //! Sets <me> for an Enum value
82 //! Then, call AddEnumDef ordered from the first one (value 0)
83 Standard_EXPORT void SetEnum();
84
85 //! Adds an enum value as a string
86 Standard_EXPORT void AddEnumDef (const Standard_CString enumdef);
87
88 //! Sets <me> for an Entity which must match a Type (early-bound)
89 Standard_EXPORT void SetType (const Handle(Standard_Type)& atype);
90
91 //! Sets <me> for a Described Entity, whose Description must match
92 //! the type name <dscnam>
93 Standard_EXPORT void SetDescr (const Standard_CString dscnam);
94
95 //! Adds an arity count to <me>, by default 1
96 //! 1 : a simple field passes to a LIST/ARRAY etc
97 //! or a LIST to a LIST OF LIST
98 //! 2 : a simple field passes to a LIST OF LIST
99 Standard_EXPORT void AddArity (const Standard_Integer arity = 1);
100
101 //! Directly sets the arity count
102 //! 0 : simple field
103 //! 1 : LIST or ARRAY etc
104 //! 2 : LIST OF LIST
105 Standard_EXPORT void SetArity (const Standard_Integer arity = 1);
106
107 //! Sets <me> as <other> but duplicated
108 //! Hence, some definition may be changed
109 Standard_EXPORT void SetFrom (const Handle(StepData_PDescr)& other);
110
111 //! Sets/Unsets <me> to accept undefined values
112 Standard_EXPORT void SetOptional (const Standard_Boolean opt = Standard_True);
113
114 //! Sets/Unsets <me> to be for a derived field
115 Standard_EXPORT void SetDerived (const Standard_Boolean der = Standard_True);
116
117 //! Sets <me> to describe a field of an entity
118 //! With a name and a rank
119 Standard_EXPORT void SetField (const Standard_CString name, const Standard_Integer rank);
120
121 //! Tells if <me> is for a SELECT
122 Standard_EXPORT Standard_Boolean IsSelect() const;
123
124 //! For a SELECT, returns the member whose name matches <name>
125 //! To this member, the following question can then be asked
126 //! Null Handle if <name> not matched or <me> not a SELECT
127 //!
128 //! Remark : not to be asked for an entity type
129 //! Hence, following IsInteger .. Enum* only apply on <me> and
130 //! require Member
131 //! While IsType applies on <me> and all Select Members
132 Standard_EXPORT Handle(StepData_PDescr) Member (const Standard_CString name) const;
133
134 //! Tells if <me> is for an Integer
135 Standard_EXPORT Standard_Boolean IsInteger() const;
136
137 //! Tells if <me> is for a Real value
138 Standard_EXPORT Standard_Boolean IsReal() const;
139
140 //! Tells if <me> is for a String value
141 Standard_EXPORT Standard_Boolean IsString() const;
142
143 //! Tells if <me> is for a Boolean value (false,true)
144 Standard_EXPORT Standard_Boolean IsBoolean() const;
145
146 //! Tells if <me> is for a Logical value (false,true,unknown)
147 Standard_EXPORT Standard_Boolean IsLogical() const;
148
149 //! Tells if <me> is for an Enum value
150 //! Then, call AddEnumDef ordered from the first one (value 0)
151 //! Managed by an EnumTool
152 Standard_EXPORT Standard_Boolean IsEnum() const;
153
154 //! Returns the maximum integer for a suitable value (count - 1)
155 Standard_EXPORT Standard_Integer EnumMax() const;
156
157 //! Returns the numeric value found for an enum text
158 //! The text must be in capitals and limited by dots
159 //! A non-suitable text gives a negative value to be returned
160 Standard_EXPORT Standard_Integer EnumValue (const Standard_CString name) const;
161
162 //! Returns the text which corresponds to a numeric value,
163 //! between 0 and EnumMax. It is limited by dots
164 Standard_EXPORT Standard_CString EnumText (const Standard_Integer val) const;
165
166 //! Tells if <me> is for an Entity, either Described or CDL Type
167 Standard_EXPORT Standard_Boolean IsEntity() const;
168
169 //! Tells if <me> is for an entity of a given CDL type (early-bnd)
170 //! (works for <me> + nexts if <me> is a Select)
171 Standard_EXPORT Standard_Boolean IsType (const Handle(Standard_Type)& atype) const;
172
173 //! Returns the type to match (IsKind), for a CDL Entity
174 //! (else, null handle)
175 Standard_EXPORT Handle(Standard_Type) Type() const;
176
177 //! Tells if <me> is for a Described entity of a given EDescr
178 //! (does this EDescr match description name ?). For late-bnd
179 //! (works for <me> + nexts if <me> is a Select)
180 Standard_EXPORT Standard_Boolean IsDescr (const Handle(StepData_EDescr)& descr) const;
181
182 //! Returns the description (type name) to match, for a Described
183 //! (else, empty string)
184 Standard_EXPORT Standard_CString DescrName() const;
185
186 //! Returns the arity of <me>
187 Standard_EXPORT Standard_Integer Arity() const;
188
189 //! For a LIST or LIST OF LIST, Returns the PDescr for the simpler
190 //! PDescr. Else, returns <me>
191 //! This allows to have different attributes for Optional for
192 //! instance, on a field, and on the parameter of a LIST :
193 //! [OPTIONAL] LIST OF [OPTIONAL] ...
194 Standard_EXPORT Handle(StepData_PDescr) Simple() const;
195
196 //! Tells if <me> is Optional
197 Standard_EXPORT Standard_Boolean IsOptional() const;
198
199 //! Tells if <me> is Derived
200 Standard_EXPORT Standard_Boolean IsDerived() const;
201
202 //! Tells if <me> is a Field. Else it is a Type
203 Standard_EXPORT Standard_Boolean IsField() const;
204
205 Standard_EXPORT Standard_CString FieldName() const;
206
207 Standard_EXPORT Standard_Integer FieldRank() const;
208
209 //! Semantic Check of a Field : does it complies with the given
210 //! description ?
211 Standard_EXPORT virtual void Check (const StepData_Field& afild, Handle(Interface_Check)& ach) const;
212
213
214
215
25e59720 216 DEFINE_STANDARD_RTTIEXT(StepData_PDescr,Standard_Transient)
42cf5bc1 217
218protected:
219
220
221
222
223private:
224
225
226 Standard_EXPORT Standard_Integer Kind() const;
227
228 TCollection_AsciiString thename;
229 Standard_Integer thesel;
230 TCollection_AsciiString thesnam;
231 Handle(StepData_PDescr) thenext;
232 Standard_Integer thekind;
233 StepData_EnumTool theenum;
234 Handle(Standard_Type) thetype;
235 TCollection_AsciiString thednam;
236 Standard_Integer thearit;
237 Handle(StepData_PDescr) thefrom;
238 Standard_Boolean theopt;
239 Standard_Boolean theder;
240 TCollection_AsciiString thefnam;
241 Standard_Integer thefnum;
242
243
244};
245
246
247
248
249
250
251
252#endif // _StepData_PDescr_HeaderFile