0024624: Lost word in license statement in source files
[occt.git] / src / IFSelect / IFSelect_SignMultiple.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <IFSelect_SignMultiple.ixx>
15 #include <TCollection_AsciiString.hxx>
16
17
18 static TCollection_AsciiString theval;    // temporaire pour construire Value
19
20     IFSelect_SignMultiple::IFSelect_SignMultiple (const Standard_CString name)
21     : IFSelect_Signature (name)    {  }
22
23     void  IFSelect_SignMultiple::Add
24   (const Handle(IFSelect_Signature)& subsign,
25    const Standard_Integer tabul, const Standard_Boolean maxi)
26 {
27   if (subsign.IsNull()) return;
28   thesubs.Append (subsign);
29   thetabs.Append (maxi ? -tabul : tabul);
30 }
31
32     Standard_CString  IFSelect_SignMultiple::Value
33   (const Handle(Standard_Transient)& ent,
34    const Handle(Interface_InterfaceModel)& model) const
35 {
36   theval.Clear();
37   Standard_Integer i, nb = thesubs.Length();
38   for (i = 1; i <= nb; i ++) {
39     Standard_Integer tabul = thetabs.Value(i);
40     Standard_Boolean maxi  = (tabul < 0);
41     if (maxi) tabul = -tabul;
42     Handle(IFSelect_Signature) sign = Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
43     Standard_CString val = sign->Value (ent,model);
44     TCollection_AsciiString str(val);
45     Standard_Integer sl = str.Length();
46     str.LeftJustify (tabul,' ');
47     if (sl > tabul && maxi) {
48       str.Remove (sl+1,tabul-sl);
49       str.SetValue (sl,'.');
50     }
51     str.AssignCat("   ");
52     theval.AssignCat (str);
53   }
54   return theval.ToCString();
55 }
56
57
58     Standard_Boolean  IFSelect_SignMultiple::Matches
59   (const Handle(Standard_Transient)& ent,
60    const Handle(Interface_InterfaceModel)& model,
61    const TCollection_AsciiString& text, const Standard_Boolean exact) const
62 {
63   if (exact) return IFSelect_Signature::Matches (ent,model,text,exact);
64   Standard_Integer i, nb = thesubs.Length();
65   for (i = 1; i <= nb; i ++) {
66     Handle(IFSelect_Signature) sign =
67       Handle(IFSelect_Signature)::DownCast(thesubs.Value(i));
68     if (sign->Matches (ent,model,text,exact)) return Standard_True;
69   }
70   return Standard_False;
71 }