X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParametersPlugin%2FParametersPlugin_Validators.cpp;h=d751c36bae268a1369436ca1c95d3eacb03e4cfe;hb=09dabb6acd9664f589a0bd9415d804d7a37ab801;hp=8242713d8b579b9592bc8fdf027820988973c684;hpb=4ca3fd41634c37f840d0cbb3f896fa97c2d3c457;p=modules%2Fshaper.git diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index 8242713d8..d751c36ba 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -7,6 +7,8 @@ #include +#include + #include #include #include @@ -25,8 +27,24 @@ bool ParametersPlugin_VariableValidator::isValid(const AttributePtr& theAttribut std::string& theError) const { AttributeStringPtr aStrAttr = std::dynamic_pointer_cast(theAttribute); - bool result = isVariable(aStrAttr->value()) && isUnique(theAttribute, aStrAttr->value()); - return result; + if (!aStrAttr->isInitialized()) { + theError = "Attribute \"" + aStrAttr->id() + "\" is not initialized."; + return false; + } + bool isEmptyExpr = aStrAttr->value().empty(); + if (isEmptyExpr) { + theError = "Attribute \"" + aStrAttr->id() + "\" value is empty."; + return false; + } + if (!isVariable(aStrAttr->value())) { + theError = "Incorrect variable name."; + return false; + } + if (!isUnique(theAttribute, aStrAttr->value())) { + theError = "Variable name is not unique."; + return false; + } + return true; } bool ParametersPlugin_VariableValidator::isVariable(const std::string& theString) const @@ -45,7 +63,7 @@ bool ParametersPlugin_VariableValidator::isVariable(const std::string& theString return true; } -bool ParametersPlugin_VariableValidator::isUnique(const AttributePtr& theAttribute, +bool ParametersPlugin_VariableValidator::isUnique(const AttributePtr& theAttribute, const std::string& theString) const { DocumentPtr aDocument = theAttribute->owner()->document(); @@ -84,13 +102,22 @@ bool ParametersPlugin_ExpressionValidator::isValid(const AttributePtr& theAttrib std::dynamic_pointer_cast(aFeature->firstResult()); AttributeStringPtr aStrAttr = - std::dynamic_pointer_cast(theAttribute); + std::dynamic_pointer_cast(theAttribute); + if (!aStrAttr->isInitialized()) { + theError = "Attribute \"" + aStrAttr->id() + "\" is not initialized."; + return false; + } bool isEmptyExpr = aStrAttr->value().empty(); - if(isEmptyExpr) + if (isEmptyExpr) { + theError = "Expression is empty."; return false; + } - if(!aParam.get()) + if (!aParam.get()) { + theError = "Result is empty."; return false; + } - return aFeature->error().empty(); + theError = aFeature->string(ParametersPlugin_Parameter::EXPRESSION_ERROR_ID())->value(); + return theError.empty(); }