0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / TopOpeBRep / TopOpeBRep_traceSIFF.cxx
1 // Created on: 1997-10-22
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifdef OCCT_DEBUG
18
19 #include <TopOpeBRep_traceSIFF.hxx>
20 #include <stdio.h>
21 TopOpeBRep_traceSIFF::TopOpeBRep_traceSIFF()
22
23   Reset();
24 }
25
26 void TopOpeBRep_traceSIFF::Reset()
27
28   mybrep1 = ""; 
29   mybrep2 = ""; 
30   myfilename = ""; 
31   myopen = Standard_False;
32 }
33
34 void TopOpeBRep_traceSIFF::Set(const Standard_Boolean b,
35                                Standard_Integer n,
36                                char**a)
37 {
38   if (n < 3 || !b || a == NULL) { 
39     Reset();
40     return;
41   }
42   mybrep1 = a[0];
43   mybrep2 = a[1];
44   myfilename = a[2];
45 }
46
47 void TopOpeBRep_traceSIFF::Set(const TCollection_AsciiString& brep1,
48                                const TCollection_AsciiString& brep2,
49                                const TCollection_AsciiString& filename)
50
51   mybrep1 = brep1; 
52   mybrep2 = brep2; 
53   myfilename = filename;
54 }
55
56 TCollection_AsciiString TopOpeBRep_traceSIFF::Name1(const Standard_Integer I) const
57 {
58   TCollection_AsciiString s = mybrep1 + "_" + I; 
59   return s;
60
61
62 TCollection_AsciiString TopOpeBRep_traceSIFF::Name2(const Standard_Integer I) const
63 {
64   TCollection_AsciiString s = mybrep2 + "_" + I; 
65   return s;
66
67
68 const TCollection_AsciiString& TopOpeBRep_traceSIFF::File() const 
69
70   return myfilename; 
71 }
72
73 Standard_Boolean TopOpeBRep_traceSIFF::Start(const TCollection_AsciiString& s,
74                                              Standard_OStream& OS) 
75 {
76   Standard_CString cs = myfilename.ToCString();
77   myopen = Standard_True;
78   if (!myfilebuf.open(cs,std::ios::out)) {
79     myopen = Standard_False;
80   }
81   if (!myopen) {
82     return myopen;
83   }
84   std::ostream osfic(&myfilebuf); osfic.precision(15);
85   if (s.Length()) {
86     OS<<s<<myfilename<<std::endl;
87   }
88   return myopen;
89 }
90
91 void TopOpeBRep_traceSIFF::Add(const Standard_Integer I1,
92                                const Standard_Integer I2)
93 {
94   if (!myopen) {
95     return;
96   }
97   TCollection_AsciiString n1 = Name1(I1);
98   TCollection_AsciiString n2 = Name2(I2);
99   std::ostream osfic(&myfilebuf);
100   osfic<<n1<<" "<<n2<<"\n";
101 }
102
103 void TopOpeBRep_traceSIFF::End(const TCollection_AsciiString& s,
104                                Standard_OStream& OS)
105 {
106   if (!myopen) {
107     return;
108   }
109   if (s.Length()) {
110     OS<<s<<myfilename<<std::endl;
111   }
112   myopen = Standard_False;
113 }  
114 //////////////////////////////////////////////////////////////////////////
115
116 TopOpeBRep_traceSIFF SIFF;
117
118 Standard_EXPORT void TopOpeBRep_SettraceSIFF(const Standard_Boolean b,
119                                              Standard_Integer n,char**a)
120 {
121   SIFF.Set(b,n,a);
122 }
123
124 Standard_EXPORT Standard_Boolean TopOpeBRep_GettraceSIFF()
125 {
126   Standard_Boolean b = (SIFF.File().Length() != 0);
127   return b;
128 }
129
130 // #ifdef OCCT_DEBUG
131 #endif