0024947: Redesign OCCT legacy type system -- automatic
[occt.git] / src / IFSelect / IFSelect_SignMultiple.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 <IFSelect_SignMultiple.ixx>
15#include <TCollection_AsciiString.hxx>
ec357c5c 16#include <IFSelect_Signature.hxx>
7fd59977 17
18
19static TCollection_AsciiString theval; // temporaire pour construire Value
20
21 IFSelect_SignMultiple::IFSelect_SignMultiple (const Standard_CString name)
22 : IFSelect_Signature (name) { }
23
24 void IFSelect_SignMultiple::Add
25 (const Handle(IFSelect_Signature)& subsign,
26 const Standard_Integer tabul, const Standard_Boolean maxi)
27{
28 if (subsign.IsNull()) return;
29 thesubs.Append (subsign);
30 thetabs.Append (maxi ? -tabul : tabul);
31}
32
33 Standard_CString IFSelect_SignMultiple::Value
34 (const Handle(Standard_Transient)& ent,
35 const Handle(Interface_InterfaceModel)& model) const
36{
37 theval.Clear();
38 Standard_Integer i, nb = thesubs.Length();
39 for (i = 1; i <= nb; i ++) {
40 Standard_Integer tabul = thetabs.Value(i);
41 Standard_Boolean maxi = (tabul < 0);
42 if (maxi) tabul = -tabul;
43 Handle(IFSelect_Signature) sign = Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
44 Standard_CString val = sign->Value (ent,model);
45 TCollection_AsciiString str(val);
46 Standard_Integer sl = str.Length();
47 str.LeftJustify (tabul,' ');
48 if (sl > tabul && maxi) {
49 str.Remove (sl+1,tabul-sl);
50 str.SetValue (sl,'.');
51 }
52 str.AssignCat(" ");
53 theval.AssignCat (str);
54 }
55 return theval.ToCString();
56}
57
58
59 Standard_Boolean IFSelect_SignMultiple::Matches
60 (const Handle(Standard_Transient)& ent,
61 const Handle(Interface_InterfaceModel)& model,
62 const TCollection_AsciiString& text, const Standard_Boolean exact) const
63{
64 if (exact) return IFSelect_Signature::Matches (ent,model,text,exact);
65 Standard_Integer i, nb = thesubs.Length();
66 for (i = 1; i <= nb; i ++) {
67 Handle(IFSelect_Signature) sign =
68 Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
69 if (sign->Matches (ent,model,text,exact)) return Standard_True;
70 }
71 return Standard_False;
72}