xref: /trunk/main/soltools/testSHL/inc/tlog.hxx (revision 38268e38)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SOLTOOLS_TESTSHL_TLOG_HXX__
24 #define _SOLTOOLS_TESTSHL_TLOG_HXX__
25 
26 #include    <osl/file.hxx>
27 #include <rtl/tres.hxx>
28 
29 #ifndef _SOLTOOLS_TESTSHL_TUTIL_HXX_
30 #include "tutil.hxx"
31 #endif
32 
33 #include <iostream>
34 
35 using namespace std;
36 
37 // <namespace_tstutl>
38 namespace tstutl {
39 
40 // <class_tLog>
41 class tLog {
42 
43     // <private_members>
44     ::osl::File*    m_logfile;              // fileobject
45     ::rtl::OUString m_logname;              // name of log
46     // </private_members>
47 
48     // <private_methods>
49     void initialize( const ::rtl::OString& name );
50     // </private_methods>
51 
52 public:
53 
54     // <public_ctors>
tLog()55     tLog() : m_logfile( 0 ) {
56     }
57 
tLog(const sal_Char * name)58     tLog( const sal_Char* name ) {
59         if( name ) {
60             initialize( name );
61         }
62         else  {
63             m_logfile = 0;
64         }
65 
66     }
67     // </public_ctors>
68 
69     // <dtor>
~tLog()70     virtual ~tLog() {
71         if ( m_logfile ) {
72             m_logfile->close();
73             delete( m_logfile );
74         }
75     } // </dtor>
76 
77     // <public_methods>
getName()78     inline ::rtl::OUString& getName() { return m_logname; }
getFile()79     inline ::osl::File* getFile() { return m_logfile; }
80 
81 	// open logfile for overwrite (default) or append
82 	::osl::FileBase::RC open( sal_Bool append = sal_False );
83     ::osl::FileBase::RC close();
84 
85     ::osl::FileBase::RC writeRes( ::rtl::TestResult& oRes, sal_Bool v = sal_False ,
86                                                   sal_Bool xml = sal_False );
87 
88 	// write methods without (default) or with echo on display
89     ::osl::FileBase::RC write( const sal_Char* buf, sal_Bool v = sal_False );
90     // </public_methods>
91 
92 }; // </class_tLog>
93 
94 } // </namespace_tstutl>
95 
96 #endif
97