1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file include/util/StreamAsString.h
10 #ifndef AesalonUtil_StreamAsString_H
11 #define AesalonUtil_StreamAsString_H
17 class StreamAsString
{
19 /** Automatic conversion to a std::string.
20 @return The internal stringstream, converted to a std::string.
22 operator std::string() const {
23 return get_stream().str();
25 /** Add something onto the internal std::stringstream.
26 @param data The data to add.
27 @return The new stringstream, with the data added.
29 template<typename Type
>
30 StreamAsString
&operator<<(const Type
&data
) {
36 /** Get the internal stringstream.
37 @return The internal stringstream, in non-const form.
39 std::ostringstream
&get_stream() { return stream
; }
40 /** Get the internal stringstream.
41 @return The internal stringstream, in const form.
43 const std::ostringstream
&get_stream() const { return stream
; }
45 /** The internal stringstream. */
46 std::ostringstream stream
;