15#ifndef DUMUX_IO_CONTAINER_HH
16#define DUMUX_IO_CONTAINER_HH
24#include <dune/common/exceptions.hh>
37template<
typename Container>
39 const std::string& filename,
40 int floatPrecision = 6)
42 std::ofstream outfile(filename, std::ios::out);
43 outfile << std::scientific << std::setprecision(floatPrecision);
44 std::ostream_iterator<typename Container::value_type> it(outfile,
"\n");
45 std::copy(v.begin(),v.end(), it);
54template<
typename Container>
58 std::istream_iterator<typename Container::value_type> it(stream);
59 std::copy(it, std::istream_iterator<typename Container::value_type>(), std::back_inserter(v));
71template<
typename Container>
74 std::ifstream infile(filename, std::ios::in);
76 DUNE_THROW(Dune::IOError,
"Could not open file: " << filename);
77 return readStreamToContainer<Container>(infile);
Container readFileToContainer(const std::string &filename)
Read a simple text file into a container.
Definition: container.hh:72
Container readStreamToContainer(std::istream &stream)
Read an input stream into a container.
Definition: container.hh:55