]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // | |
3 | // Copyright (c) 2010-2013 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland. | |
5 | // Use, modification and distribution is subject to the Boost Software License, | |
6 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | // | |
9 | // | |
10 | #ifndef FILE_TO_STRING_HPP | |
11 | #define FILE_TO_STRING_HPP | |
12 | ||
13 | ||
14 | #include <string> | |
15 | #include <fstream> | |
16 | ||
17 | ||
18 | inline std::string file_to_string(std::string const& filename) | |
19 | { | |
20 | std::string result; | |
21 | ||
22 | std::ifstream cpp_file(filename.c_str()); | |
23 | if (cpp_file.is_open()) | |
24 | { | |
25 | while (! cpp_file.eof() ) | |
26 | { | |
27 | std::string line; | |
28 | std::getline(cpp_file, line); | |
29 | result += line + "\n"; | |
30 | } | |
31 | } | |
32 | return result; | |
33 | } | |
34 | ||
35 | ||
36 | #endif // FILE_TO_STRING_HPP |