E-MailRelay

glogstream.cpp
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file glogstream.cpp
19///
20
21#include "gdef.h"
22#include "glogstream.h"
23#include <ostream>
24
25 G::LogStream & G::operator<<( LogStream & s , const std::string & value ) noexcept
26{
27 try
28 {
29 if( s.m_ostream ) *(s.m_ostream) << value ;
30 }
31 catch(...)
32 {
33 }
34 return s ;
35}
36
37 G::LogStream & G::operator<<( LogStream & s , const char * value ) noexcept
38{
39 try
40 {
41 if( s.m_ostream ) *(s.m_ostream) << value ;
42 }
43 catch(...)
44 {
45 }
46 return s ;
47}
48
49 G::LogStream & G::operator<<( LogStream & s , char value ) noexcept
50{
51 try
52 {
53 if( s.m_ostream ) *(s.m_ostream) << value ;
54 }
55 catch(...)
56 {
57 }
58 return s ;
59}
60
61#ifndef G_LIB_SMALL
62 G::LogStream & G::operator<<( LogStream & s , unsigned char value ) noexcept
63{
64 try
65 {
66 if( s.m_ostream ) *(s.m_ostream) << value ;
67 }
68 catch(...)
69 {
70 }
71 return s ;
72}
73#endif
74
75 G::LogStream & G::operator<<( LogStream & s , int value ) noexcept
76{
77 try
78 {
79 if( s.m_ostream ) *(s.m_ostream) << value ;
80 }
81 catch(...)
82 {
83 }
84 return s ;
85}
86
87 G::LogStream & G::operator<<( LogStream & s , unsigned int value ) noexcept
88{
89 try
90 {
91 if( s.m_ostream ) *(s.m_ostream) << value ;
92 }
93 catch(...)
94 {
95 }
96 return s ;
97}
98
99 G::LogStream & G::operator<<( LogStream & s , long value ) noexcept
100{
101 try
102 {
103 if( s.m_ostream ) *(s.m_ostream) << value ;
104 }
105 catch(...)
106 {
107 }
108 return s ;
109}
110
111 G::LogStream & G::operator<<( LogStream & s , unsigned long value ) noexcept
112{
113 try
114 {
115 if( s.m_ostream ) *(s.m_ostream) << value ;
116 }
117 catch(...)
118 {
119 }
120 return s ;
121}
122
123 G::LogStream & G::operator<<( LogStream & s , void * p ) noexcept // inc. HANDLE
124{
125 try
126 {
127 if( s.m_ostream ) *(s.m_ostream) << reinterpret_cast<g_uintptr_t>(p) ;
128 }
129 catch(...)
130 {
131 }
132 return s ;
133}
134
glogstream.h
G::LogStream
A non-throwing copyable wrapper for std::ostream, used by G::LogOutput and associated logging macros.
Definition: glogstream.h:38