1 /***************************************************************************
3 * Copyright 2010 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
19 #ifndef _LOGMESSAGEBUFFER_H_
20 #define _LOGMESSAGEBUFFER_H_
23 class LogMessageBuffer {
24 typedef std::ios_base& (*ios_base_manip)(std::ios_base&);
27 * Creates a new instance.
36 LogMessageBuffer& operator<<(const std::basic_string<char>& msg);
38 LogMessageBuffer& operator<<(const char* msg);
40 LogMessageBuffer& operator<<(char* msg);
42 LogMessageBuffer& operator<<(const char msg);
44 std::ostream& operator<<(ios_base_manip manip);
46 std::ostream& operator<<(bool val);
48 std::ostream& operator<<(short val);
50 std::ostream& operator<<(int val);
52 std::ostream& operator<<(unsigned int val);
54 std::ostream& operator<<(long val);
56 std::ostream& operator<<(unsigned long val);
58 std::ostream& operator<<(float val);
60 std::ostream& operator<<(double val);
62 std::ostream& operator<<(long double val);
64 std::ostream& operator<<(void* val);
69 operator std::basic_ostream<char>&();
71 const std::basic_string<char>& str(std::basic_ostream<char>& os);
73 const std::basic_string<char>& str();
75 bool hasStream() const;
79 * No default copy constructor.
81 LogMessageBuffer(const LogMessageBuffer&);
83 * No assignment operator.
85 LogMessageBuffer& operator=(const LogMessageBuffer&);
88 * Encapsulated std::string.
90 std::basic_string<char> buf;
93 * Encapsulated stream, created on demand.
95 std::basic_ostringstream<char>* stream;
98 std::basic_ostream<char>& operator<<(LogMessageBuffer& os, const V& val) {
99 return ((std::basic_ostream<char>&) os) << val;
102 #endif /* _LOGMESSAGEBUFFER_H_ */