34 #include <boost/algorithm/string/split.hpp>
35 #include <boost/algorithm/string/join.hpp>
36 #include <boost/algorithm/string/classification.hpp>
37 #include <boost/thread/mutex.hpp>
47 std::string
command(
const std::string& _cmd)
60 std::cerr <<
"ROSPack::run returned non-zero." << std::endl;
63 catch(std::runtime_error &e)
66 std::cerr <<
"[rospack] " << e.what() << std::endl;
68 return std::string(
"");
73 std::string out_string =
command(cmd);
75 boost::split(full_list, out_string, boost::is_any_of(
"\r\n"));
78 V_string::iterator it = full_list.begin();
79 V_string::iterator end = full_list.end();
80 for (; it != end; ++it)
84 output.push_back(*it);
89 std::string
getPath(
const std::string& package_name)
91 std::string path =
command(
"find " + package_name);
94 for (
size_t newline = path.find(
'\n'); newline != std::string::npos;
95 newline = path.find(
'\n'))
97 path.erase(newline, 1);
105 command(
"list-names", packages);
120 V_string::iterator it = lines.begin();
121 V_string::iterator end = lines.end();
122 for (; it != end; ++it)
125 boost::split(tokens, *it, boost::is_any_of(
" "));
127 if (tokens.size() >= 2)
129 std::string
package = tokens[0];
130 std::string rest = boost::join(
V_string(tokens.begin() + 1, tokens.end()),
" ");
132 plugins.push_back(rest);
138 const std::string& name,
139 const std::string& attribute,
140 std::vector<std::pair<std::string, std::string> >& exports,
145 getPlugins(name, attribute, packages, plugins, force_recrawl);
147 for (std::size_t i = 0; i < packages.size(); ++i ) {
148 exports.push_back(std::pair<std::string, std::string>(packages[i], plugins[i]));
152 void getPlugins(
const std::string& package,
const std::string& attribute,
V_string& plugins,
bool force_recrawl)
158 void getPlugins(
const std::string& package,
const std::string& attribute,
M_string& plugins,
bool force_recrawl)
162 for (std::size_t i = 0 ; i < packages.size() ; ++i)
163 plugins[packages[i]] = plugins_v[i];