0025367: IGES and BRep persistence - support unicode file names on Windows
[occt.git] / src / StepSelect / StepSelect_StepType.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <StepSelect_StepType.ixx>
15#include <TColStd_SequenceOfAsciiString.hxx>
16#include <StepData_ReadWriteModule.hxx>
17#include <StepData_UndefinedEntity.hxx>
18#include <Interface_InterfaceError.hxx>
19#include <Interface_Macros.hxx>
20
21
22static TCollection_AsciiString lastvalue;
23
24
25 StepSelect_StepType::StepSelect_StepType ()
26 : IFSelect_Signature ("Step Type") { }
27
28 void StepSelect_StepType::SetProtocol
29 (const Handle(Interface_Protocol)& proto)
30{
31 DeclareAndCast(StepData_Protocol,newproto,proto);
32 if (newproto.IsNull()) Interface_InterfaceError::Raise("StepSelect_StepType");
33 theproto = newproto;
34 thelib.Clear();
35 thelib.AddProtocol (theproto);
36 thename.Clear();
37 thename.AssignCat ("Step Type (Schema ");
38 thename.AssignCat (theproto->SchemaName());
39 thename.AssignCat (")");
40}
41
42 Standard_CString StepSelect_StepType::Value
43 (const Handle(Standard_Transient)& ent,
35e08fe8 44 const Handle(Interface_InterfaceModel)& /*model*/) const
7fd59977 45{
46 lastvalue.Clear();
47 Handle(StepData_ReadWriteModule) module;
48 Standard_Integer CN;
49 Standard_Boolean ok = thelib.Select (ent,module,CN);
50 if (!ok) {
51 lastvalue.AssignCat ("..NOT FROM SCHEMA ");
52 lastvalue.AssignCat (theproto->SchemaName());
53 lastvalue.AssignCat ("..");
54 } else {
55 Standard_Boolean plex = module->IsComplex(CN);
56 if (!plex) lastvalue = module->StepType(CN);
57 else {
58 lastvalue.AssignCat ("(");
59 TColStd_SequenceOfAsciiString list;
60 module->ComplexType (CN,list);
61 Standard_Integer nb = list.Length();
62 if (nb == 0) lastvalue.AssignCat ("..COMPLEX TYPE..");
63 for (Standard_Integer i = 1; i <= nb; i ++) {
64 if (i > 1) lastvalue.AssignCat (",");
65 lastvalue.AssignCat (list.Value(i).ToCString());
66 }
67 lastvalue.AssignCat (")");
68 }
69 }
70 if (lastvalue.Length() > 0) return lastvalue.ToCString();
71
72 DeclareAndCast(StepData_UndefinedEntity,und,ent);
73 if (und.IsNull()) return lastvalue.ToCString();
74 if (und->IsComplex()) {
75 lastvalue.AssignCat("(");
76 while (!und.IsNull()) {
77 lastvalue.AssignCat (und->StepType());
78 und = und->Next();
79 if (!und.IsNull()) lastvalue.AssignCat(",");
80 }
81 lastvalue.AssignCat(")");
82 }
83 else return und->StepType();
84 return lastvalue.ToCString();
85}