32#define SYNTAX_ERROR(line) yError() << "Syntax error while loading" << curr_filename << "at line" << line << "."
33#define SYNTAX_WARNING(line) yWarning() << "Invalid syntax while loading" << curr_filename << "at line" << line << "."
38#define TINYXML_UNSIGNED_INT_BUG 0
66 mPriv->verbose = verb;
71 mPriv->enable_deprecated = enab;
77 std::string filename = fileName;
79 std::replace(filename.begin(), filename.end(),
'/',
'\\');
81 std::string curr_filename = fileName;
84 yDebug() <<
"Reading file" << filename.c_str();
85 auto doc = std::make_unique< TiXmlDocument>(TiXmlDocument(filename.c_str()));
86 if (!doc->LoadFile()) {
91 if (!doc->RootElement()) {
98 for (TiXmlNode* childNode = doc->FirstChild(); childNode !=
nullptr; childNode = childNode->NextSibling()) {
99 if (childNode->Type() == TiXmlNode::TINYXML_UNKNOWN) {
100 if (dtd.
parse(childNode->ToUnknown(), curr_filename)) {
107 SYNTAX_WARNING(doc->Row()) <<
"No DTD found. Assuming version yarprobotinterfaceV3.0";
118 yError() <<
"DTD V1.x has been deprecated. Please update your configuration files to DTD v3.x";
119 if (mPriv->enable_deprecated) {
120 yWarning() <<
"yarprobotinterface: using DEPRECATED xml parser for DTD v1.x";
125 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);
143 std::string curr_filename =
" XML runtime string ";
144 std::unique_ptr<TiXmlDocument> doc = std::make_unique<TiXmlDocument>();
145 if (!doc->Parse(xmlString.data())) {
149 if (!doc->RootElement()) {
156 for (TiXmlNode* childNode = doc->FirstChild(); childNode !=
nullptr; childNode = childNode->NextSibling()) {
157 if (childNode->Type() == TiXmlNode::TINYXML_UNKNOWN) {
158 std::string curr_filename =
" XML runtime string ";
159 if (dtd.
parse(childNode->ToUnknown(), curr_filename)) {
166 SYNTAX_WARNING(doc->Row()) <<
"No DTD found. Assuming version yarprobotinterfaceV3.0";
177 yError() <<
"DTD V1.x has been deprecated. Please update your configuration files to DTD v3.x";
178 if (mPriv->enable_deprecated) {
179 yWarning() <<
"yarprobotinterface: using DEPRECATED xml parser for DTD v1.x";
183 yError(
"Invalid DTD version, execution stopped.");
187 yDebug() <<
"yarprobotinterface: using xml parser for DTD v3.x";
193 yError(
"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
static constexpr value_type preferred_separator
std::string DocTypeToString(RobotInterfaceDTD::DocType doctype)