7fd59977 |
1 | #include <IFSelect_SignMultiple.ixx> |
2 | #include <TCollection_AsciiString.hxx> |
3 | |
4 | |
5 | static TCollection_AsciiString theval; // temporaire pour construire Value |
6 | |
7 | IFSelect_SignMultiple::IFSelect_SignMultiple (const Standard_CString name) |
8 | : IFSelect_Signature (name) { } |
9 | |
10 | void IFSelect_SignMultiple::Add |
11 | (const Handle(IFSelect_Signature)& subsign, |
12 | const Standard_Integer tabul, const Standard_Boolean maxi) |
13 | { |
14 | if (subsign.IsNull()) return; |
15 | thesubs.Append (subsign); |
16 | thetabs.Append (maxi ? -tabul : tabul); |
17 | } |
18 | |
19 | Standard_CString IFSelect_SignMultiple::Value |
20 | (const Handle(Standard_Transient)& ent, |
21 | const Handle(Interface_InterfaceModel)& model) const |
22 | { |
23 | theval.Clear(); |
24 | Standard_Integer i, nb = thesubs.Length(); |
25 | for (i = 1; i <= nb; i ++) { |
26 | Standard_Integer tabul = thetabs.Value(i); |
27 | Standard_Boolean maxi = (tabul < 0); |
28 | if (maxi) tabul = -tabul; |
29 | Handle(IFSelect_Signature) sign = Handle(IFSelect_Signature)::DownCast(thesubs.Value(i)); |
30 | Standard_CString val = sign->Value (ent,model); |
31 | TCollection_AsciiString str(val); |
32 | Standard_Integer sl = str.Length(); |
33 | str.LeftJustify (tabul,' '); |
34 | if (sl > tabul && maxi) { |
35 | str.Remove (sl+1,tabul-sl); |
36 | str.SetValue (sl,'.'); |
37 | } |
38 | str.AssignCat(" "); |
39 | theval.AssignCat (str); |
40 | } |
41 | return theval.ToCString(); |
42 | } |
43 | |
44 | |
45 | Standard_Boolean IFSelect_SignMultiple::Matches |
46 | (const Handle(Standard_Transient)& ent, |
47 | const Handle(Interface_InterfaceModel)& model, |
48 | const TCollection_AsciiString& text, const Standard_Boolean exact) const |
49 | { |
50 | if (exact) return IFSelect_Signature::Matches (ent,model,text,exact); |
51 | Standard_Integer i, nb = thesubs.Length(); |
52 | for (i = 1; i <= nb; i ++) { |
53 | Handle(IFSelect_Signature) sign = |
54 | Handle(IFSelect_Signature)::DownCast(thesubs.Value(i)); |
55 | if (sign->Matches (ent,model,text,exact)) return Standard_True; |
56 | } |
57 | return Standard_False; |
58 | } |