35 #define SYNTAX_ERROR(line) yError() << "Syntax error while loading" << curr_filename << "at line" << line << "."
36 #define SYNTAX_WARNING(line) yWarning() << "Invalid syntax while loading" << curr_filename << "at line" << line << "."
41 #define TINYXML_UNSIGNED_INT_BUG 0
69 mPriv->verbose = verb;
74 mPriv->enable_deprecated = enab;
79 std::string filename = fileName;
81 std::replace(filename.begin(), filename.end(),
'/',
'\\');
83 std::string curr_filename = fileName;
86 yDebug() <<
"Reading file" << filename.c_str();
87 auto* doc =
new TiXmlDocument(filename.c_str());
88 if (!doc->LoadFile()) {
93 if (!doc->RootElement()) {
100 for (TiXmlNode* childNode = doc->FirstChild(); childNode !=
nullptr; childNode = childNode->NextSibling()) {
101 if (childNode->Type() == TiXmlNode::TINYXML_UNKNOWN) {
102 if (dtd.
parse(childNode->ToUnknown(), curr_filename)) {
109 SYNTAX_WARNING(doc->Row()) <<
"No DTD found. Assuming version yarprobotinterfaceV3.0";
120 yError() <<
"DTD V1.x has been deprecated. Please update your configuration files to DTD v3.x";
121 if (mPriv->enable_deprecated) {
122 yWarning() <<
"yarprobotinterface: using DEPRECATED xml parser for DTD v1.x";
126 yError(
"Invalid DTD version, execution stopped.");
130 yDebug() <<
"yarprobotinterface: using xml parser for DTD v3.x";
136 yError(
"Invalid DTD version. Unable to choose parser for DTD.major: %d", dtd.
majorVersion);
142 std::string curr_filename =
" XML runtime string ";
143 std::unique_ptr<TiXmlDocument> doc = std::make_unique<TiXmlDocument>();
144 if (!doc->Parse(xmlString.data())) {
148 if (!doc->RootElement()) {
155 for (TiXmlNode* childNode = doc->FirstChild(); childNode !=
nullptr; childNode = childNode->NextSibling()) {
156 if (childNode->Type() == TiXmlNode::TINYXML_UNKNOWN) {
157 std::string curr_filename =
" XML runtime string ";
158 if (dtd.
parse(childNode->ToUnknown(), curr_filename)) {
165 SYNTAX_WARNING(doc->Row()) <<
"No DTD found. Assuming version yarprobotinterfaceV3.0";
176 yError() <<
"DTD V1.x has been deprecated. Please update your configuration files to DTD v3.x";
177 if (mPriv->enable_deprecated) {
178 yWarning() <<
"yarprobotinterface: using DEPRECATED xml parser for DTD v1.x";
182 yError(
"Invalid DTD version, execution stopped.");
186 yDebug() <<
"yarprobotinterface: using xml parser for DTD v3.x";
192 yError(
"Invalid DTD version. Unable to choose parser for DTD.major: %d", dtd.
majorVersion);
#define SYNTAX_ERROR(line)
#define SYNTAX_WARNING(line)
unsigned int majorVersion
bool parse(TiXmlUnknown *unknownNode, const std::string &curr_filename)
Result of the parsing of XMLReader.
static XMLReaderResult ParsingFailed()
yarp::robotinterface::impl::XMLReaderFileVx * mReader
void setEnableDeprecated(bool enab)
void setVerbose(bool verbose)
XMLReaderResult getRobotFromString(const std::string &xmlString)
Parse the XML description of a robotinterface from a string.
XMLReaderResult getRobotFromFile(const std::string &filename)
Parse the XML description of a robotinterface from a file.
yarp::robotinterface::experimental::XMLReaderResult getRobotFromFile(const std::string &filename, bool verbose=false) override
yarp::robotinterface::experimental::XMLReaderResult getRobotFromString(const std::string &xmlString, bool verbose=false) override
yarp::robotinterface::experimental::XMLReaderResult getRobotFromFile(const std::string &filename, bool verbose=false) override
yarp::robotinterface::experimental::XMLReaderResult getRobotFromString(const std::string &xmlString, bool verbose=false) override
static constexpr value_type preferred_separator
std::string DocTypeToString(RobotInterfaceDTD::DocType doctype)