43 QFile file(filename_h.c_str());
48 if (!doc.setContent(device,
true, &errorStr, &errorLine, &errorColumn)) {
49 string message =
"XML error on file "+ filename_h +
" at line ";
50 message.append(
i2s(errorLine));
51 message.append(
" column ");
52 message = message.c_str() +
i2s(errorColumn);
53 message = message +
": ";
54 message = message + errorStr.toStdString();
80 string content =
domElement.text().toStdString();
81 if (content ==
"false" || content ==
"falso" || content ==
"FALSE" || content ==
"0")
83 else if (content ==
"true" || content ==
"vero" || content ==
"TRUE" || content ==
"1")
85 msgOut(
MSG_WARNING,
"Sorry, I don't know how to convert "+content+
" to a bool value. I return true... hope for the best");
91 if (
domElement.hasAttribute(attributeName_h.c_str())){
92 return domElement.attribute(attributeName_h.c_str()).toInt();
94 msgOut(
MSG_ERROR,
"Element doens't have attribute " + attributeName_h );
101 if (
domElement.hasAttribute(attributeName_h.c_str())){
102 return domElement.attribute(attributeName_h.c_str()).toDouble();
104 msgOut(
MSG_ERROR,
"Element doens't have attribute " + attributeName_h );
111 if (
domElement.hasAttribute(attributeName_h.c_str())){
112 return domElement.attribute(attributeName_h.c_str()).toStdString();
114 msgOut(
MSG_ERROR,
"Element doens't have attribute " + attributeName_h );
121 if (
domElement.hasAttribute(attributeName_h.c_str())){
141 vector<InputNode> myNodes =
getNodesByName(nodeName_h, debugLevel, childFlag);
142 if (myNodes.size()>1){
143 msgOut(debugLevel,
"Too many elements. Expected only one of type "+nodeName_h);
146 if (myNodes.size() == 0){
147 msgOut(debugLevel,
"No elements in the XML file. Expected 1 of type "+nodeName_h+
". Returning emty node!!");
156 vector <InputNode> myNodeVector;
158 QDomNodeList myElementList =
domElement.elementsByTagName ( nodeName_h.c_str() );
159 for (
int i=0;i<myElementList.size();i++){
160 InputNode myInputNode(myElementList.item(i).toElement());
161 myNodeVector.push_back(myInputNode);
166 QDomNodeList myElementList =
domElement.childNodes();
167 for (
int i=0;i<myElementList.size();i++){
168 if ( myElementList.item(i).nodeType() == QDomNode::ElementNode
169 && myElementList.item(i).toElement().tagName().toStdString() == nodeName_h){
170 InputNode myInputNode(myElementList.item(i).toElement());
171 myNodeVector.push_back(myInputNode);
175 if (myNodeVector.size()==0){
176 msgOut(debugLevel,
"No elements in the XML file. Expected at least one of type "+nodeName_h);
236 vector <InputNode> myNodeVector;
237 QDomNodeList myElementList =
domElement.childNodes();
238 for (
int i=0;i<myElementList.size();i++){
239 if (myElementList.item(i).nodeType() == QDomNode::ElementNode ){
240 InputNode myInputNode(myElementList.item(i).toElement());
241 myNodeVector.push_back(myInputNode);
249 bool toReturn =
false;
250 QDomNodeList myElementList =
domElement.childNodes();
251 for (
int i=0;i<myElementList.size();i++){
252 if (myElementList.item(i).nodeType() == QDomNode::ElementNode ){
253 if(myElementList.item(i).toElement().tagName().toStdString() == name_h)
return true;
261 int myElementListCountInt = 0;
262 QDomNodeList myElementList =
domElement.childNodes();
263 for (
int i=0;i<myElementList.size();i++){
264 if (myElementList.item(i).nodeType() == QDomNode::ElementNode ){
265 myElementListCountInt++ ;
268 return myElementListCountInt;
Print an ERROR message, but don't stop the model.
string i2s(const int &int_h) const
integer to string conversion
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.