0030286: Cover polygonal HLR algorithm by regression tests
[occt.git] / src / Message / Message_PrinterOStream.hxx
CommitLineData
42cf5bc1 1// Created on: 2001-01-06
2// Created by: OCC Team
3// Copyright (c) 2001-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _Message_PrinterOStream_HeaderFile
17#define _Message_PrinterOStream_HeaderFile
18
42cf5bc1 19#include <Message_Printer.hxx>
983fd6c0 20#include <Standard_Address.hxx>
42cf5bc1 21#include <Standard_OStream.hxx>
42cf5bc1 22
23class Message_PrinterOStream;
24DEFINE_STANDARD_HANDLE(Message_PrinterOStream, Message_Printer)
25
26//! Implementation of a message printer associated with an ostream
27//! The ostream may be either externally defined one (e.g. cout),
28//! or file stream maintained internally (depending on constructor).
29class Message_PrinterOStream : public Message_Printer
30{
983fd6c0 31 DEFINE_STANDARD_RTTIEXT(Message_PrinterOStream, Message_Printer)
42cf5bc1 32public:
42cf5bc1 33
34 //! Empty constructor, defaulting to cout
35 Standard_EXPORT Message_PrinterOStream(const Message_Gravity theTraceLevel = Message_Info);
36
37 //! Create printer for output to a specified file.
38 //! The option theDoAppend specifies whether file should be
39 //! appended or rewritten.
40 //! For specific file names (cout, cerr) standard streams are used
41 Standard_EXPORT Message_PrinterOStream(const Standard_CString theFileName, const Standard_Boolean theDoAppend, const Message_Gravity theTraceLevel = Message_Info);
42
43 //! Flushes the output stream and destroys it if it has been
44 //! specified externally with option doFree (or if it is internal
45 //! file stream)
46 Standard_EXPORT void Close();
47~Message_PrinterOStream()
48{
49 Close();
50}
983fd6c0 51
42cf5bc1 52 //! Returns option to convert non-Ascii symbols to UTF8 encoding
983fd6c0 53 Standard_Boolean GetUseUtf8() const { return myUseUtf8; }
42cf5bc1 54
55 //! Sets option to convert non-Ascii symbols to UTF8 encoding
983fd6c0 56 void SetUseUtf8 (const Standard_Boolean useUtf8) { myUseUtf8 = useUtf8; }
57
42cf5bc1 58 //! Returns reference to the output stream
983fd6c0 59 Standard_OStream& GetStream() const { return *(Standard_OStream*)myStream; }
42cf5bc1 60
61 //! Puts a message to the current stream
62 //! if its gravity is equal or greater
63 //! to the trace level set by SetTraceLevel()
64 Standard_EXPORT virtual void Send (const Standard_CString theString, const Message_Gravity theGravity, const Standard_Boolean putEndl = Standard_True) const Standard_OVERRIDE;
65
66 //! Puts a message to the current stream
67 //! if its gravity is equal or greater
68 //! to the trace level set by SetTraceLevel()
69 Standard_EXPORT virtual void Send (const TCollection_AsciiString& theString, const Message_Gravity theGravity, const Standard_Boolean putEndl = Standard_True) const Standard_OVERRIDE;
70
71 //! Puts a message to the current stream
72 //! if its gravity is equal or greater
73 //! to the trace level set by SetTraceLevel()
74 //! Non-Ascii symbols are converted to UTF-8 if UseUtf8
75 //! option is set, else replaced by symbols '?'
76 Standard_EXPORT virtual void Send (const TCollection_ExtendedString& theString, const Message_Gravity theGravity, const Standard_Boolean putEndl = Standard_True) const Standard_OVERRIDE;
77
42cf5bc1 78private:
79
42cf5bc1 80 Standard_Address myStream;
81 Standard_Boolean myIsFile;
82 Standard_Boolean myUseUtf8;
83
42cf5bc1 84};
85
42cf5bc1 86#endif // _Message_PrinterOStream_HeaderFile