0024947: Redesign OCCT legacy type system -- final corrections
[occt.git] / src / IGESSelect / IGESSelect_SelectName.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 <IGESSelect_SelectName.ixx>
15#include <IGESData_IGESEntity.hxx>
16#include <Interface_Macros.hxx>
17#include <stdio.h>
18
19
b311480e 20IGESSelect_SelectName::IGESSelect_SelectName () { }
7fd59977 21
22
23 void IGESSelect_SelectName::SetName
24 (const Handle(TCollection_HAsciiString)& levnum)
25 { thename = levnum; }
26
27 Handle(TCollection_HAsciiString) IGESSelect_SelectName::Name () const
28 { return thename; }
29
30
31 Standard_Boolean IGESSelect_SelectName::Sort
35e08fe8 32 (const Standard_Integer /*rank*/,
33 const Handle(Standard_Transient)& ent,
34 const Handle(Interface_InterfaceModel)& /*model*/) const
7fd59977 35{
36 DeclareAndCast(IGESData_IGESEntity,igesent,ent);
37 if (igesent.IsNull()) return Standard_False;
38 if (!igesent->HasName()) return Standard_False;
39 if (thename.IsNull()) return Standard_False;
40 Handle(TCollection_HAsciiString) name = igesent->NameValue();
41// cout<<"SelectName:"<<thename->ToCString()<<",with:"<<name->ToCString()<<",IsSameString="<<thename->IsSameString (name,Standard_False)<<endl;
42 Standard_Integer nb0 = thename->Length();
43 Standard_Integer nb1 = name->Length();
44 Standard_Integer nbf = (nb1 <= nb0 ? nb1 : nb0);
45 Standard_Integer nbt = (nb1 >= nb0 ? nb1 : nb0);
46 Standard_Integer i; // svv Jan11 2000 : porting on DEC
47 for (i = 1; i <= nbf; i ++) {
48 if (name->Value(i) != thename->Value(i)) return Standard_False;
49 }
50 if (nb0 > nb1) name = thename;
51 for (i = nbf+1; i <= nbt; i ++) {
52 if (name->Value(i) != ' ') return Standard_False;
53 }
54 return Standard_True;
55}
56
57
58 TCollection_AsciiString IGESSelect_SelectName::ExtractLabel () const
59{
60 char labl [50];
61 if (!thename.IsNull()) {
62 sprintf (labl,"IGES Entity, Name : %s",thename->ToCString());
63 return TCollection_AsciiString(labl);
64 }
65 else return TCollection_AsciiString ("IGES Entity, Name : (undefined)");
66}