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