1 // Copyright (c) 2001-2010 Hartmut Kaiser
2 // Copyright (c) 2001-2007 Joel de Guzman
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 ///////////////////////////////////////////////////////////////////////////////
12 // Helper function reading a file into a string
13 ///////////////////////////////////////////////////////////////////////////////
15 read_from_file(char const* infile)
17 std::ifstream instream(infile);
18 if (!instream.is_open()) {
19 std::cerr << "Couldn't open file: " << infile << std::endl;
22 instream.unsetf(std::ios::skipws); // No white space skipping!
23 return std::string(std::istreambuf_iterator<char>(instream.rdbuf()),
24 std::istreambuf_iterator<char>());