X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FParametersPlugin%2FParametersPlugin_Validators.cpp;h=aaa647d9d124d502a4576e52fd2f3c9ae4ffbcdf;hb=f6bd0f4e080b833c0de7ef25822ebee641073445;hp=d0549db529e82fb0216d4d12574843e9b0faff0f;hpb=ba727bd58bc3166536229f47c363a14d5a126fa7;p=modules%2Fshaper.git diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index d0549db52..aaa647d9d 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -1,9 +1,22 @@ -/* - * Parameters_VariableValidator.cpp - * - * Created on: Apr 9, 2015 - * Author: sbh - */ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include @@ -15,6 +28,7 @@ #include #include #include +#include ParametersPlugin_VariableValidator::ParametersPlugin_VariableValidator() { @@ -40,10 +54,10 @@ bool ParametersPlugin_VariableValidator::isValid(const AttributePtr& theAttribut theError.arg(aStrAttr->id()); return false; } - if (!isVariable(aStrAttr->value())) { + if (!ModelAPI_Expression::isVariable(aStrAttr->value())) { theError = "Incorrect variable name."; return false; - } + } if (!isUnique(theAttribute, aStrAttr->value())) { theError = "Variable name is not unique."; return false; @@ -51,22 +65,6 @@ bool ParametersPlugin_VariableValidator::isValid(const AttributePtr& theAttribut return true; } -bool ParametersPlugin_VariableValidator::isVariable(const std::string& theString) const -{ - if (theString.empty()) - return false; - std::string::const_iterator it = theString.begin(); - if (!(isalpha(*it) || (*it) == '_') || it == theString.end()) - return false; - it++; - for ( ; it != theString.end(); ++it ) { - if(!(isalnum(*it) || (*it) == '_')) { - return false; - } - } - return true; -} - bool ParametersPlugin_VariableValidator::isUnique(const AttributePtr& theAttribute, const std::string& theString) const {