+ if (!theAttribute->isInitialized()) {
+ theError = "Is not initialized.";
+ return false;
+ }
+
+ const AttributeStringPtr aStrAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
+ if (!aStrAttr) {
+ theError = "Is not a string attribute.";
+ return false;
+ }
+
+ std::string aFileName = aStrAttr->value();
+ if (aFileName.empty()) {
+ theError = "File name is empty.";
+ return false;
+ }
+
+ std::list<std::string> aFormats;
+ ExchangePlugin_FormatValidator::parseFormats(theArguments, aFormats);
+ std::list<std::string>::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) {
+ if (aFileNameLen > (*itFormats).length()) {
+ size_t aFormatBeginPos = aFileNameLen - (*itFormats).length();
+ if (aFileName.compare(aFormatBeginPos, std::string::npos, *itFormats) == 0) {
+ return true;
+ }
+ }
+ }
+ theError = "File name does not end with any available format.";