summaryrefslogtreecommitdiff
path: root/src/IFSelect/IFSelect_SignMultiple.cxx
blob: 97bf585be013866721202e03dfc277568678ea28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <IFSelect_SignMultiple.ixx>
#include <TCollection_AsciiString.hxx>


static TCollection_AsciiString theval;    // temporaire pour construire Value

    IFSelect_SignMultiple::IFSelect_SignMultiple (const Standard_CString name)
    : IFSelect_Signature (name)    {  }

    void  IFSelect_SignMultiple::Add
  (const Handle(IFSelect_Signature)& subsign,
   const Standard_Integer tabul, const Standard_Boolean maxi)
{
  if (subsign.IsNull()) return;
  thesubs.Append (subsign);
  thetabs.Append (maxi ? -tabul : tabul);
}

    Standard_CString  IFSelect_SignMultiple::Value
  (const Handle(Standard_Transient)& ent,
   const Handle(Interface_InterfaceModel)& model) const
{
  theval.Clear();
  Standard_Integer i, nb = thesubs.Length();
  for (i = 1; i <= nb; i ++) {
    Standard_Integer tabul = thetabs.Value(i);
    Standard_Boolean maxi  = (tabul < 0);
    if (maxi) tabul = -tabul;
    Handle(IFSelect_Signature) sign = Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
    Standard_CString val = sign->Value (ent,model);
    TCollection_AsciiString str(val);
    Standard_Integer sl = str.Length();
    str.LeftJustify (tabul,' ');
    if (sl > tabul && maxi) {
      str.Remove (sl+1,tabul-sl);
      str.SetValue (sl,'.');
    }
    str.AssignCat("   ");
    theval.AssignCat (str);
  }
  return theval.ToCString();
}


    Standard_Boolean  IFSelect_SignMultiple::Matches
  (const Handle(Standard_Transient)& ent,
   const Handle(Interface_InterfaceModel)& model,
   const TCollection_AsciiString& text, const Standard_Boolean exact) const
{
  if (exact) return IFSelect_Signature::Matches (ent,model,text,exact);
  Standard_Integer i, nb = thesubs.Length();
  for (i = 1; i <= nb; i ++) {
    Handle(IFSelect_Signature) sign =
      Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
    if (sign->Matches (ent,model,text,exact)) return Standard_True;
  }
  return Standard_False;
}