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