File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,13 @@ std::string strFormat(const std::string& format, Args... args)
6767 return std::string{ buf.get (), buf.get () + size - 1 }; // We don't want the '\0' inside
6868}
6969
70+ /* *
71+ * @brief Read in the contents of the file into a string
72+ * @param filepath The file to read
73+ * @return The contents of the file
74+ */
75+ std::string fileToString (const tesseract_common::fs::path& filepath);
76+
7077/* *
7178 * @brief Change the reference point of the provided Twist
7279 * @param twist The current Twist which gets modified in place
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3030#include < string>
3131#include < type_traits>
3232#include < console_bridge/console.h>
33+ #include < fstream>
3334TESSERACT_COMMON_IGNORE_WARNINGS_POP
3435
3536#include < tesseract_common/utils.h>
@@ -68,6 +69,20 @@ std::enable_if_t<std::is_polymorphic<E>::value> my_rethrow_if_nested(const E& e)
6869 p->rethrow_nested ();
6970}
7071
72+ std::string fileToString (const tesseract_common::fs::path& filepath)
73+ {
74+ std::ifstream ifs (filepath.c_str ());
75+ std::string contents;
76+
77+ ifs.seekg (0 , std::ios::end);
78+ contents.reserve (ifs.tellg ());
79+ ifs.seekg (0 , std::ios::beg);
80+
81+ contents.assign (std::istreambuf_iterator<char >(ifs), std::istreambuf_iterator<char >());
82+ ifs.close ();
83+ return contents;
84+ }
85+
7186// LCOV_EXCL_START
7287// These are tested in both tesseract_kinematics and tesseract_state_solver
7388void twistChangeRefPoint (Eigen::Ref<Eigen::VectorXd> twist, const Eigen::Ref<const Eigen::Vector3d>& ref_point)
You can’t perform that action at this time.
0 commit comments