1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <StepData_PDescr.ixx>
24 StepData_PDescr::StepData_PDescr ()
25 : thesel (0), thekind (0), thearit (0),
26 theopt (Standard_False), theder (Standard_False), thefnum (0)
29 void StepData_PDescr::SetName (const Standard_CString name)
30 { thename.Clear(); thename.AssignCat (name); }
32 Standard_CString StepData_PDescr::Name () const
33 { return thename.ToCString(); }
35 Standard_Integer StepData_PDescr::Kind () const
38 void StepData_PDescr::SetSelect ()
41 void StepData_PDescr::AddMember (const Handle(StepData_PDescr)& member)
43 if (member.IsNull()) return;
44 if (thenext.IsNull()) thenext = member;
45 else thenext->AddMember (member);
46 if (thesel == 3) return;
47 if (thekind < KindEntity && thenext->Kind() >= KindEntity) thesel = 3;
48 else if (thekind < KindEntity && (thesel == 2 || thesel == 4)) thesel = 3;
49 else if (thekind >= KindEntity && (thesel == 1 || thesel == 4)) thesel = 2;
52 void StepData_PDescr::SetMemberName (const Standard_CString memname)
53 { thesnam.Clear(); thesnam.AssignCat (memname); }
55 void StepData_PDescr::SetInteger ()
56 { thekind = KindInteger; }
58 void StepData_PDescr::SetReal ()
59 { thekind = KindReal; }
61 void StepData_PDescr::SetString ()
62 { thekind = KindString; }
64 void StepData_PDescr::SetBoolean ()
65 { thekind = KindBoolean; }
67 void StepData_PDescr::SetLogical ()
68 { thekind = KindLogical; }
70 void StepData_PDescr::SetEnum ()
71 { thekind = KindEnum; }
73 void StepData_PDescr::AddEnumDef (const Standard_CString enumdef)
74 { theenum.AddDefinition (enumdef); }
76 void StepData_PDescr::SetType (const Handle(Standard_Type)& atype)
77 { thekind = KindEntity; thetype = atype; thednam.Clear(); }
79 void StepData_PDescr::SetDescr (const Standard_CString dscnam)
80 { thekind = KindEntity; thetype.Nullify();
81 thednam.Clear(); thednam.AssignCat(dscnam); }
83 void StepData_PDescr::AddArity (const Standard_Integer arity)
86 void StepData_PDescr::SetArity (const Standard_Integer arity)
90 void StepData_PDescr::SetFrom (const Handle(StepData_PDescr)& other)
92 if (other.IsNull()) return;
93 thekind = other->Kind();
94 Standard_Integer i, maxenum = other->EnumMax ();
95 for (i = 0; i <= maxenum; i ++) AddEnumDef (other->EnumText(i));
96 // ne sont pas reprises : les SELECT
97 thetype = other->Type();
98 thearit = other->Arity();
100 theopt = other->IsOptional ();
101 theder = other->IsDerived ();
102 thefnam.Clear(); thefnam.AssignCat (other->FieldName());
103 thefnum = other->FieldRank ();
106 void StepData_PDescr::SetOptional (const Standard_Boolean opt)
109 void StepData_PDescr::SetDerived (const Standard_Boolean der)
112 void StepData_PDescr::SetField
113 (const Standard_CString name, const Standard_Integer rank)
115 thefnam.Clear(); thefnam.AssignCat (name);
119 // ###### INTERRO ######
121 Standard_Boolean StepData_PDescr::IsSelect () const
123 if (!thefrom.IsNull()) return thefrom->IsSelect();
127 Handle(StepData_PDescr) StepData_PDescr::Member (const Standard_CString name) const
129 if (!thefrom.IsNull()) return thefrom->Member (name);
130 Handle(StepData_PDescr) descr;
131 if (thesnam.IsEqual (name)) return this;
132 if (thenext.IsNull()) return descr; // null
133 return thenext->Member (name);
136 Standard_Boolean StepData_PDescr::IsInteger () const
137 { return (thekind == KindInteger); }
139 Standard_Boolean StepData_PDescr::IsReal () const
140 { return (thekind == KindReal); }
142 Standard_Boolean StepData_PDescr::IsString () const
143 { return (thekind == KindString); }
145 Standard_Boolean StepData_PDescr::IsBoolean () const
146 { return (thekind == KindBoolean || thekind == KindLogical); }
148 Standard_Boolean StepData_PDescr::IsLogical () const
149 { return (thekind == KindLogical); }
151 Standard_Boolean StepData_PDescr::IsEnum () const
152 { return (thekind == KindEnum); }
154 Standard_Integer StepData_PDescr::EnumMax () const
155 { return theenum.MaxValue(); }
157 Standard_Integer StepData_PDescr::EnumValue (const Standard_CString name) const
158 { return theenum.Value (name); }
160 Standard_CString StepData_PDescr::EnumText (const Standard_Integer val) const
161 { return theenum.Text (val).ToCString(); }
163 Standard_Boolean StepData_PDescr::IsEntity () const
164 { return (thekind == KindEntity); }
166 Standard_Boolean StepData_PDescr::IsType (const Handle(Standard_Type)& atype) const
168 if (atype.IsNull()) return Standard_False;
169 if (!thetype.IsNull()) {
170 if (atype->SubType(thetype)) return Standard_True;
172 if (!thenext.IsNull()) return thenext->IsType(atype);
173 if (!thefrom.IsNull()) return thefrom->IsType(atype);
174 return Standard_False;
177 Handle(Standard_Type) StepData_PDescr::Type () const
180 Standard_Boolean StepData_PDescr::IsDescr
181 (const Handle(StepData_EDescr)& descr) const
183 if (descr.IsNull()) return Standard_False;
184 if (thednam.Length() > 0) {
185 if (descr->Matches (thednam.ToCString())) return Standard_True;
187 if (!thenext.IsNull()) return thenext->IsDescr (descr);
188 if (!thefrom.IsNull()) return thefrom->IsDescr (descr);
189 return Standard_False;
192 Standard_CString StepData_PDescr::DescrName () const
193 { return thednam.ToCString(); }
196 Standard_Integer StepData_PDescr::Arity () const
199 Handle(StepData_PDescr) StepData_PDescr::Simple () const
201 if (thearit == 0) return this;
202 if (thefrom.IsNull()) return this;
206 Standard_Boolean StepData_PDescr::IsOptional () const
209 Standard_Boolean StepData_PDescr::IsDerived () const
212 Standard_Boolean StepData_PDescr::IsField () const
213 { return (thefnum > 0); }
215 Standard_CString StepData_PDescr::FieldName () const
216 { return thefnam.ToCString (); }
218 Standard_Integer StepData_PDescr::FieldRank () const
222 void StepData_PDescr::Check(const StepData_Field& /*afild*/,
223 Handle(Interface_Check)& /*ach*/) const
225 // pour l instant ...