MCPcopy Create free account
hub / github.com/SICKAG/sick_scan_xd / parseFile

Method parseFile

roswrap/src/launchparser/launchparser.cpp:209–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209bool LaunchParser::parseFile(std::string launchFileFullName, std::vector<std::string>& nameVec,
210 std::vector<std::string>& typeVec, std::vector<std::string>& valVec)
211{
212 bool ret = false;
213 ROS_INFO_STREAM("Try loading launchfile : " << launchFileFullName);
214 TiXmlDocument doc;
215 doc.LoadFile(launchFileFullName.c_str());
216
217 if (doc.Error() == true)
218 {
219 ROS_ERROR_STREAM("## ERROR parsing launch file " << doc.ErrorDesc() << "\nRow: " << doc.ErrorRow() << "\nCol: " << doc.ErrorCol() << "");
220 return(ret);
221 }
222 TiXmlNode *node = doc.FirstChild("launch");
223 if (node != NULL)
224 {
225 std::map<std::string, std::string> default_args;
226 TiXmlElement *arg_node = (TiXmlElement *)node->FirstChild("arg");
227 while(arg_node)
228 {
229 if(strcmp(arg_node->Value(), "arg") == 0 && arg_node->Type() == TiXmlNode::TINYXML_ELEMENT)
230 {
231 // parse default arguments, f.e. <arg name="hostname" default="192.168.0.1"/>
232 const char* p_attr_name = arg_node->Attribute("name");
233 const char* p_attr_default = arg_node->Attribute("default");
234 if(p_attr_name && p_attr_default)
235 {
236 std::string attr_name(p_attr_name), attr_default(p_attr_default);
237 default_args[attr_name] = attr_default;
238 ROS_INFO_STREAM("LaunchParser::parseFile(" << launchFileFullName << "): default_args[\"" << attr_name << "\"]=\"" << default_args[attr_name] << "\"");
239 }
240 }
241 arg_node = (TiXmlElement *)arg_node->NextSibling(); // go to next sibling
242 }
243
244 // Parse optional group for param "scanner_type"
245 bool node_with_scanner_type_found = false;
246 TiXmlNode * group_node = node->FirstChild("group");
247 if (group_node)
248 {
249 group_node = group_node->FirstChild("node");
250 if (group_node)
251 {
252 std::vector<paramEntryAscii> paramOrgList = getParamList(group_node);
253 for (size_t j = 0; j < paramOrgList.size(); j++)
254 {
255 if (paramOrgList[j].getName() == "scanner_type")
256 {
257 node_with_scanner_type_found = true;
258 ROS_INFO_STREAM("LaunchParser::parseFile(" << launchFileFullName << "): group node found with param scanner_type");
259 node = group_node;
260 break;
261 }
262 }
263 }
264 }
265 if (!node_with_scanner_type_found)
266 {

Callers 1

Calls 13

LoadFileMethod · 0.80
FirstChildMethod · 0.80
AttributeMethod · 0.80
NextSiblingMethod · 0.80
getNameMethod · 0.80
push_backMethod · 0.80
findMethod · 0.80
getParamListFunction · 0.70
ValueMethod · 0.45
sizeMethod · 0.45
getValueMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected