/Src/Dependencies/Boost/libs/geometry/doc/src/docutils/tools/doxygen_xml2qbk/file_to_string.hpp

http://hadesmem.googlecode.com/ · C++ Header · 35 lines · 20 code · 7 blank · 8 comment · 2 complexity · f09bf3bb2ee04f8e7280b2d45751e2e0 MD5 · raw file

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