MySQL++ Reference Manual

MySQL++: stream2string.h Source File

MySQL++ 3.3.0

stream2string.h
Go to the documentation of this file.
1
5 /***********************************************************************
6 Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
7 (c) 2004-2007 by Educational Technology Resources, Inc. Others may
8 also hold copyrights on code in this file. See the CREDITS.txt file
9 in the top directory of the distribution for details.
10
11 This file is part of MySQL++.
12
13 MySQL++ is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published
15 by the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
17
18 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21 License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with MySQL++; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
26 USA
27 ***********************************************************************/
28
29 #if !defined(MYSQLPP_STREAM2STRING_H)
30 #define MYSQLPP_STREAM2STRING_H
31
32 #include <sstream>
33 #include <string>
34
35 namespace mysqlpp {
36
39
40 template <class T>
41 std::string stream2string(const T& object)
42 {
43 std::ostringstream str;
44 str << object;
45 return str.str();
46 }
47
48 } // end namespace mysqlpp
49
50 #endif // !defined(MYSQLPP_STREAM2STRING_H)
51
mysqlpp::stream2string
std::string stream2string(const T &object)
Converts anything you can insert into a C++ stream to a std::string via std::ostringstream.
Definition: stream2string.h:41