]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/example/lex/example.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / example / lex / example.hpp
1 // Copyright (c) 2001-2010 Hartmut Kaiser
2 // Copyright (c) 2001-2007 Joel de Guzman
3 //
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)
6
7 #include <iostream>
8 #include <fstream>
9 #include <string>
10
11 ///////////////////////////////////////////////////////////////////////////////
12 // Helper function reading a file into a string
13 ///////////////////////////////////////////////////////////////////////////////
14 inline std::string
15 read_from_file(char const* infile)
16 {
17 std::ifstream instream(infile);
18 if (!instream.is_open()) {
19 std::cerr << "Couldn't open file: " << infile << std::endl;
20 exit(-1);
21 }
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>());
25 }
26