X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FExchangePlugin_Validators.cpp;h=5a62fea8f048dd260110e69fc81d83bc46547948;hb=eaa34d7803a364b8da51b6dde8b0ee3c469ae27a;hp=e708041a8f7e034bc342fa8ddb0706b56ec85e91;hpb=38afbd899a8645c83e17f2c24a17a2b7414911b4;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/ExchangePlugin_Validators.cpp b/src/ExchangePlugin/ExchangePlugin_Validators.cpp index e708041a8..5a62fea8f 100644 --- a/src/ExchangePlugin/ExchangePlugin_Validators.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Validators.cpp @@ -12,10 +12,11 @@ #include #include +#include #include -bool ExchangePlugin_ImportFormatValidator::parseFormats(const std::list& theArguments, - std::list& outFormats) +bool ExchangePlugin_FormatValidator::parseFormats(const std::list& theArguments, + std::list& outFormats) { std::list::const_iterator it = theArguments.begin(); bool result = true; @@ -26,56 +27,42 @@ bool ExchangePlugin_ImportFormatValidator::parseFormats(const std::list& theArguments, - std::list& outPlugins) +bool ExchangePlugin_FormatValidator::isValid(const AttributePtr& theAttribute, + const std::list& theArguments) const { - std::list::const_iterator it = theArguments.begin(); - bool result = true; - for (; it != theArguments.end(); ++it) { - std::string anArg = *it; - int aSepPos = anArg.find(":"); - if (aSepPos == std::string::npos) { - result = false; - continue; - } - outPlugins.push_back(anArg.substr(aSepPos + 1)); - } - return result; -} + if (!theAttribute->isInitialized()) + return false; -bool ExchangePlugin_ImportFormatValidator::isValid(const AttributePtr& theAttribute, - const std::list& theArguments) const -{ - SessionPtr aMgr = ModelAPI_Session::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - if (theAttribute->isInitialized()) { - const AttributeStringPtr aStrAttr = - std::dynamic_pointer_cast(theAttribute); - if(!aStrAttr) - return false; - std::string aFileName = aStrAttr->value(); - if (!aFileName.empty()) { - std::list aFormats; - ExchangePlugin_ImportFormatValidator::parseFormats(theArguments, aFormats); - std::list::const_iterator itFormats = aFormats.begin(); - size_t aFileNameLen = aFileName.length(); - std::transform(aFileName.begin(), aFileName.end(), aFileName.begin(), toupper); - // Is file name ends with the format - for (; itFormats != aFormats.end(); ++itFormats) { - size_t aFormatBeginPos = aFileNameLen - (*itFormats).length(); - if (aFileName.compare(aFormatBeginPos, std::string::npos, *itFormats) == 0) { - return true; - } - } + const AttributeStringPtr aStrAttr = + std::dynamic_pointer_cast(theAttribute); + if (!aStrAttr) + return false; + + std::string aFileName = aStrAttr->value(); + if (aFileName.empty()) + return false; + + std::list aFormats; + ExchangePlugin_FormatValidator::parseFormats(theArguments, aFormats); + std::list::const_iterator itFormats = aFormats.begin(); + size_t aFileNameLen = aFileName.length(); + std::transform(aFileName.begin(), aFileName.end(), aFileName.begin(), toupper); + // Is file name ends with the format + for (; itFormats != aFormats.end(); ++itFormats) { + size_t aFormatBeginPos = aFileNameLen - (*itFormats).length(); + if (aFileName.compare(aFormatBeginPos, std::string::npos, *itFormats) == 0) { + return true; } } return false; } -