Salome HOME
Upgrade of export feature tests
[modules/shaper.git] / src / ExchangePlugin / ExchangePlugin_Validators.cpp
index 052140b8136f963bfb02118b346d0a8a06e4de56..8b3bcf587fb89bf4c761d6c714482e1236dcbda9 100644 (file)
@@ -8,6 +8,8 @@
 
 #include <ExchangePlugin_Tools.h>
 
+#include <Events_InfoMessage.h>
+
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Session.h>
@@ -24,7 +26,7 @@ bool ExchangePlugin_FormatValidator::parseFormats(const std::list<std::string>&
   bool result = true;
   for (; it != theArguments.end(); ++it) {
     std::string anArg = *it;
-    int aSepPos = anArg.find(":");
+    size_t aSepPos = anArg.find(":");
     if (aSepPos == std::string::npos) {
       result = false;
       continue;
@@ -38,19 +40,28 @@ bool ExchangePlugin_FormatValidator::parseFormats(const std::list<std::string>&
 }
 
 bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute,
-                                             const std::list<std::string>& theArguments) const
+                                             const std::list<std::string>& theArguments,
+                                             Events_InfoMessage& theError) const
 {
-  if (!theAttribute->isInitialized())
+  if (!theAttribute->isInitialized()) {
+    theError = "%1 is not initialized.";
+    theError.arg(theAttribute->id());
     return false;
+  }
 
   const AttributeStringPtr aStrAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
-  if (!aStrAttr)
+  if (!aStrAttr) {
+    theError = "%1 is not a string attribute.";
+    theError.arg(theAttribute->id());
     return false;
+  }
 
   std::string aFileName = aStrAttr->value();
-  if (aFileName.empty())
+  if (aFileName.empty()) {
+    theError = "File name is empty.";
     return false;
+  }
 
   std::list<std::string> aFormats;
   ExchangePlugin_FormatValidator::parseFormats(theArguments, aFormats);
@@ -66,5 +77,6 @@ bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute,
       }
     }
   }
+  theError = "File name does not end with any available format.";
   return false;
 }