// Search for element named 'query' in the list of known elements int ElementMap::find(const char* query, ElementMap::ZMapType zmt) const { // Get the element number from the element name provided. Messenger::enter("ElementMap::find"); int result = -1; if (query[0] == '\0') { Messenger::print("Warning: Element search requested on blank string.\n"); Messenger::exit("ElementMap::find"); return 0; } // Convert the query string according to the specified rule switch (zmt == ElementMap::nZMapTypes ? prefs.zMapType() : zmt) { // Automatic determination case (ElementMap::AutoZMap): // First, try pure numeric conversion result = numberToZ(query); if (result != -1) break; // Then, try alpha conversion result = alphaToZ(query); if (result != -1) break; // Then, try name conversion result = nameToZ(query); if (result != -1) break; // Finally, try FF conversion result = ffToZ(query); break; // Name search case (ElementMap::NameZMap): result = nameToZ(query); break; // Search loaded forcefields for atom names case (ElementMap::ForcefieldZMap): result = ffToZ(query); // Attempt an alpha conversion if the FF conversion failed if (result == -1) result = alphaToZ(query); break; // Convert based on alpha-part of atom name only case (ElementMap::AlphaZMap): result = alphaToZ(query); break; // Convert based on first alpha-part of atom name only case (ElementMap::FirstAlphaZMap): result = firstAlphaToZ(query); break; // Convert based on first alpha-character of atom name only case (ElementMap::SingleAlphaZMap): result = singleAlphaToZ(query); break; // Convert based on numeric part only case (ElementMap::NumericZMap): result = numberToZ(query); break; default: break; } Messenger::exit("ElementMap::find"); return ((result == -1) ? 0 : result); }
// Search for element named 'query' in the list of known elements int ElementMap::find(QString query, ElementMap::ZMapType zmt) { // Get the element number from the element name provided. Messenger::enter("ElementMap::find"); int result = -1; if (query.isEmpty()) { Messenger::print("Warning: Element search requested on blank string."); Messenger::exit("ElementMap::find"); return 0; } // Attempt conversion of the string first from any defined mappings result = mappings_.data(query); if (result != -1) return result; // Convert the query string according to the specified rule switch (zmt) { // Automatic determination case (ElementMap::AutoZMap): // First, try pure numeric conversion result = numberToZ(query); if (result != -1) break; // Then, try alpha conversion result = alphaToZ(query); if (result != -1) break; // Conversion to atomtype name in loaded FF result = ffToZ(query); if (result != -1) break; // Single alpha character conversion result = singleAlphaToZ(query); if (result != -1) break; // Finally, try name conversion result = nameToZ(query); if (result != -1) break; break; // Name search case (ElementMap::NameZMap): result = nameToZ(query); break; // Search loaded forcefields for atom names case (ElementMap::ForcefieldZMap): result = ffToZ(query); // Attempt an alpha conversion if the FF conversion failed if (result == -1) result = alphaToZ(query); break; // Convert based on alpha-part of atom name only case (ElementMap::AlphaZMap): result = alphaToZ(query); break; // Convert based on first alpha-part of atom name only case (ElementMap::FirstAlphaZMap): result = firstAlphaToZ(query); break; // Convert based on first alpha-character of atom name only case (ElementMap::SingleAlphaZMap): result = singleAlphaToZ(query); break; // Convert based on numeric part only case (ElementMap::NumericZMap): result = numberToZ(query); break; default: break; } Messenger::exit("ElementMap::find"); return ((result == -1) ? 0 : result); }