Odil
A C++11 library for the DICOM standard
StringStream.h
Go to the documentation of this file.
1 /*************************************************************************
2  * odil - Copyright (C) Universite de Strasbourg
3  * Distributed under the terms of the CeCILL-B license, as published by
4  * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5  * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6  * for details.
7  ************************************************************************/
8 
9 #ifndef _dadc5c51_56d9_417e_9a96_100ed2838c2a
10 #define _dadc5c51_56d9_417e_9a96_100ed2838c2a
11 
12 #include <string>
13 
14 #include <boost/iostreams/device/array.hpp>
15 #include <boost/iostreams/stream.hpp>
16 #include <boost/iostreams/device/back_inserter.hpp>
17 
18 namespace odil
19 {
20 
22 typedef boost::iostreams::stream<boost::iostreams::array_source> IStringStream;
23 
24 template<typename T>
25 T as(std::string const & string)
26 {
27  T result;
28  IStringStream stream(&string[0], string.size());
29  stream >> result;
30  return result;
31 }
32 
34 typedef boost::iostreams::stream<
35  boost::iostreams::back_insert_device<std::string>
37 
38 }
39 
40 #endif // _dadc5c51_56d9_417e_9a96_100ed2838c2a
boost::iostreams::stream< boost::iostreams::back_insert_device< std::string > > OStringStream
Sink stringstream which does not copy its buffer.
Definition: StringStream.h:36
boost::iostreams::stream< boost::iostreams::array_source > IStringStream
Source stringstream which does not copy its buffer.
Definition: StringStream.h:22
Definition: Association.h:24
T as(std::string const &string)
Definition: StringStream.h:25