36#define SYNTAX_ERROR(line) yCError(YRI_XMLDREADER) << "Syntax error while loading" << curr_filename << "at line" << line << "."
37#define SYNTAX_WARNING(line) yCWarning(YRI_XMLDREADER) << "Invalid syntax while loading" << curr_filename << "at line" << line << "."
42#define TINYXML_UNSIGNED_INT_BUG 0
70 mPriv->verbose = verb;
75 mPriv->enable_deprecated = enab;
81 std::string filename = fileName;
83 std::replace(filename.begin(), filename.end(),
'/',
'\\');
85 std::string curr_filename = fileName;
88 yCDebug(YRI_XMLDREADER) <<
"Reading file" << filename.c_str();
89 auto doc = std::make_unique< TiXmlDocument>(TiXmlDocument(filename.c_str()));
90 if (!doc->LoadFile()) {
95 if (!doc->RootElement()) {
102 for (TiXmlNode* childNode = doc->FirstChild(); childNode !=
nullptr; childNode = childNode->NextSibling()) {
103 if (childNode->Type() == TiXmlNode::TINYXML_UNKNOWN) {
104 if (dtd.
parse(childNode->ToUnknown(), curr_filename)) {
111 SYNTAX_WARNING(doc->Row()) <<
"No DTD found. Assuming version yarprobotinterfaceV3.0";
122 yCError(YRI_XMLDREADER) <<
"DTD V1.x has been deprecated. Please update your configuration files to DTD v3.x";
123 if (mPriv->enable_deprecated) {
124 yCWarning(YRI_XMLDREADER) <<
"yarprobotinterface: using DEPRECATED xml parser for DTD v1.x";
129 yCError(YRI_XMLDREADER,
"Invalid DTD version, execution stopped.");
134 yCDebug(YRI_XMLDREADER) <<
"yarprobotinterface: using xml parser for DTD v3.x";
140 yCError(YRI_XMLDREADER,
"Invalid DTD version. Unable to choose parser for DTD.major: %d", dtd.
majorVersion);
147 std::string curr_filename =
" XML runtime string ";
148 std::unique_ptr<TiXmlDocument> doc = std::make_unique<TiXmlDocument>();
149 if (!doc->Parse(xmlString.data())) {
153 if (!doc->RootElement()) {
160 for (TiXmlNode* childNode = doc->FirstChild(); childNode !=
nullptr; childNode = childNode->NextSibling()) {
161 if (childNode->Type() == TiXmlNode::TINYXML_UNKNOWN) {
162 std::string curr_filename =
" XML runtime string ";
163 if (dtd.
parse(childNode->ToUnknown(), curr_filename)) {
170 SYNTAX_WARNING(doc->Row()) <<
"No DTD found. Assuming version yarprobotinterfaceV3.0";
181 yCError(YRI_XMLDREADER) <<
"DTD V1.x has been deprecated. Please update your configuration files to DTD v3.x";
182 if (mPriv->enable_deprecated) {
183 yCWarning(YRI_XMLDREADER) <<
"yarprobotinterface: using DEPRECATED xml parser for DTD v1.x";
187 yCError(YRI_XMLDREADER,
"Invalid DTD version, execution stopped.");
191 yCDebug(YRI_XMLDREADER) <<
"yarprobotinterface: using xml parser for DTD v3.x";
197 yCError(YRI_XMLDREADER,
"Invalid DTD version. Unable to choose parser for DTD.major: %d", dtd.
majorVersion);
#define SYNTAX_ERROR(line)
#define SYNTAX_WARNING(line)
A base class for nested structures that can be searched.
unsigned int majorVersion
bool parse(TiXmlUnknown *unknownNode, const std::string &curr_filename)
Result of the parsing of yarp::robotinterface::XMLReader.
static XMLReaderResult ParsingFailed()
yarp::robotinterface::impl::XMLReaderFileVx * mReader
XMLReaderResult getRobotFromFile(const std::string &filename, const yarp::os::Searchable &config=yarp::os::Property())
Parse the XML description of a robotinterface from a file.
void setEnableDeprecated(bool enab)
void setVerbose(bool verbose)
XMLReaderResult getRobotFromString(const std::string &filename, const yarp::os::Searchable &config=yarp::os::Property())
Parse the XML description of a robotinterface from a string.
yarp::robotinterface::XMLReaderResult getRobotFromString(const std::string &xmlString, const yarp::os::Searchable &config, bool verbose=false) override
yarp::robotinterface::XMLReaderResult getRobotFromFile(const std::string &filename, const yarp::os::Searchable &config, bool verbose=false) override
yarp::robotinterface::XMLReaderResult getRobotFromString(const std::string &xmlString, const yarp::os::Searchable &config, bool verbose=false) override
yarp::robotinterface::XMLReaderResult getRobotFromFile(const std::string &filename, const yarp::os::Searchable &config, bool verbose=false) override
#define yCError(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
static constexpr value_type preferred_separator
std::string DocTypeToString(RobotInterfaceDTD::DocType doctype)