Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
Msg.h
Go to the documentation of this file.
1 #ifndef QPID_MSG_H
2 #define QPID_MSG_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include <sstream>
26 #include <iostream>
28 
29 namespace qpid {
30 
41 struct Msg {
42  std::ostringstream os;
43  Msg() {}
44  Msg(const Msg& m) : os(m.str()) {}
45  std::string str() const { return os.str(); }
46  operator std::string() const { return str(); }
47 
48  Msg& operator<<(long n) { os << n; return *this; }
49  Msg& operator<<(unsigned long n) { os << n; return *this; }
50  Msg& operator<<(bool n) { os << n; return *this; }
51  Msg& operator<<(short n) { os << n; return *this; }
52  Msg& operator<<(unsigned short n) { os << n; return *this; }
53  Msg& operator<<(int n) { os << n; return *this; }
54  Msg& operator<<(unsigned int n) { os << n; return *this; }
55 #ifdef _GLIBCXX_USE_LONG_LONG
56  Msg& operator<<(long long n) { os << n; return *this; }
57  Msg& operator<<(unsigned long long n) { os << n; return *this; }
58 #endif
59  Msg& operator<<(double n) { os << n; return *this; }
60  Msg& operator<<(float n) { os << n; return *this; }
61  Msg& operator<<(long double n) { os << n; return *this; }
62 
63  template <class T> Msg& operator<<(const T& t) { os <<t; return *this; }
64 };
65 
66 
67 
68 inline std::ostream& operator<<(std::ostream& o, const Msg& m) {
69  return o << m.str();
70 }
71 
73 #define QUOTE_(x) #x
74 #define QUOTE(x) QUOTE_(x)
75 #define QPID_MSG(message) (::qpid::Msg() << message << " (" __FILE__ ":" QUOTE(__LINE__) ")")
76 
77 } // namespace qpid
78 
79 #endif
Msg & operator<<(long double n)
Definition: Msg.h:61
Msg & operator<<(unsigned short n)
Definition: Msg.h:52
Msg & operator<<(unsigned int n)
Definition: Msg.h:54
Msg & operator<<(float n)
Definition: Msg.h:60
Msg & operator<<(unsigned long n)
Definition: Msg.h:49
std::ostringstream os
Definition: Msg.h:42
Msg()
Definition: Msg.h:43
Msg & operator<<(const T &t)
Definition: Msg.h:63
std::string str() const
Definition: Msg.h:45
std::ostream & operator<<(std::ostream &os, const Address &addr)
Msg & operator<<(long n)
Definition: Msg.h:48
Msg & operator<<(short n)
Definition: Msg.h:51
Msg & operator<<(int n)
Definition: Msg.h:53
A simple wrapper for std::ostringstream that allows in place construction of a message and automatic ...
Definition: Msg.h:41
Msg & operator<<(double n)
Definition: Msg.h:59
Msg & operator<<(bool n)
Definition: Msg.h:50
Msg(const Msg &m)
Definition: Msg.h:44

Qpid C++ API Reference
Generated on Thu Aug 18 2016 for Qpid C++ Client API by doxygen 1.8.5