Odil
A C++11 library for the DICOM standard
Loading...
Searching...
No Matches
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
18namespace odil
19{
20
22typedef boost::iostreams::stream<boost::iostreams::array_source> IStringStream;
23
24template<typename T>
25T as(std::string const & string)
26{
27 T result;
28 IStringStream stream(&string[0], string.size());
29 stream >> result;
30 return result;
31}
32
34typedef boost::iostreams::stream<
35 boost::iostreams::back_insert_device<std::string>
37
38}
39
40#endif // _dadc5c51_56d9_417e_9a96_100ed2838c2a
Definition Association.h:25
boost::iostreams::stream< boost::iostreams::array_source > IStringStream
Source stringstream which does not copy its buffer.
Definition StringStream.h:22
boost::iostreams::stream< boost::iostreams::back_insert_device< std::string > > OStringStream
Sink stringstream which does not copy its buffer.
Definition StringStream.h:36
T as(std::string const &string)
Definition StringStream.h:25