42 setTag(
"EditorFileOpener");
43 using namespace boost::property_tree;
48 if (configFile.empty())
61 xml_parser::read_xml(configFile, pt);
63 catch (xml_parser::xml_parser_error& e)
66 ARMARX_WARNING <<
"Could not load state-configfile '" << configFile
67 <<
"'. Required parameters may be unset.\nReason at " << e.filename()
68 <<
":" << e.line() <<
":\n"
69 << e.message() <<
flush;
73 for (ptree::value_type
const& v : pt.get_child(
"editors"))
75 if (v.first ==
"editor")
77 std::string editorName = v.second.get<std::string>(
"name");
78 std::string openCommandLine = v.second.get<std::string>(
"opencommandline");
79 editors[editorName] = openCommandLine;
86 const std::string& filepath,
89 std::string openCommandLine = editors[editorName];
91 if (openCommandLine.empty())
93 ARMARX_WARNING <<
"Cannot find editor named '" << editorName <<
"'";
97 std::string::size_type lenFile = std::string(
FILE_VARIABLE).size();
98 std::string::size_type posFile = openCommandLine.find(
FILE_VARIABLE);
100 if (posFile != std::string::npos)
102 openCommandLine.replace(posFile, lenFile, filepath);
105 std::string::size_type lenLine = std::string(
LINE_VARIABLE).size();
106 std::string::size_type posLine = openCommandLine.find(
LINE_VARIABLE);
107 std::stringstream lineStr;
108 lineStr << lineNumber;
110 if (posLine != std::string::npos)
112 openCommandLine.replace(posLine, lenLine, lineStr.str());
115 simox::alg::trim(openCommandLine);
117 if (*openCommandLine.rbegin() !=
'&')
119 openCommandLine +=
" &";
124 if (std::system(openCommandLine.c_str()))