xref: /aoo41x/main/soltools/testSHL/inc/tlog.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _SOLTOOLS_TESTSHL_TLOG_HXX__
28 #define _SOLTOOLS_TESTSHL_TLOG_HXX__
29 
30 #include    <osl/file.hxx>
31 #include <rtl/tres.hxx>
32 
33 #ifndef _SOLTOOLS_TESTSHL_TUTIL_HXX_
34 #include "tutil.hxx"
35 #endif
36 
37 #include <iostream>
38 
39 using namespace std;
40 
41 // <namespace_tstutl>
42 namespace tstutl {
43 
44 // <class_tLog>
45 class tLog {
46 
47     // <private_members>
48     ::osl::File*    m_logfile;              // fileobject
49     ::rtl::OUString m_logname;              // name of log
50     // </private_members>
51 
52     // <private_methods>
53     void initialize( const ::rtl::OString& name );
54     // </private_methods>
55 
56 public:
57 
58     // <public_ctors>
59     tLog() : m_logfile( 0 ) {
60     }
61 
62     tLog( const sal_Char* name ) {
63         if( name ) {
64             initialize( name );
65         }
66         else  {
67             m_logfile = 0;
68         }
69 
70     }
71     // </public_ctors>
72 
73     // <dtor>
74     virtual ~tLog() {
75         if ( m_logfile ) {
76             m_logfile->close();
77             delete( m_logfile );
78         }
79     } // </dtor>
80 
81     // <public_methods>
82     inline ::rtl::OUString& getName() { return m_logname; }
83     inline ::osl::File* getFile() { return m_logfile; }
84 
85 	// open logfile for overwrite (default) or append
86 	::osl::FileBase::RC open( sal_Bool append = sal_False );
87     ::osl::FileBase::RC close();
88 
89     ::osl::FileBase::RC writeRes( ::rtl::TestResult& oRes, sal_Bool v = sal_False ,
90                                                   sal_Bool xml = sal_False );
91 
92 	// write methods without (default) or with echo on display
93     ::osl::FileBase::RC write( const sal_Char* buf, sal_Bool v = sal_False );
94     // </public_methods>
95 
96 }; // </class_tLog>
97 
98 } // </namespace_tstutl>
99 
100 #endif
101