/// Read rectangular masks from a config file string /// @param line :: line (string) from the config file void EQSANSLoad::readRectangularMasks(const std::string& line) { // Looking for rectangular mask // Rectangular mask = 7, 0; 7, 255 Poco::RegularExpression re_key("rectangular mask", Poco::RegularExpression::RE_CASELESS); Poco::RegularExpression re_key_alt("elliptical mask", Poco::RegularExpression::RE_CASELESS); Poco::RegularExpression::Match match; if (re_key.match(line, 0, match) || re_key_alt.match(line, 0, match)) { Poco::RegularExpression re_sig("=[ ]*([0-9]+)[ ]*[ ,][ ]*([0-9]+)[ ]*[ ;,][ ]*([0-9]+)[ ]*[ ,][ ]*([0-9]+)"); if (re_sig.match(line, 0, match)) { Poco::RegularExpression::MatchVec posVec; re_sig.match(line, 0, posVec); if (posVec.size()==5) { for (int i=0; i<4; i++) { std::string num_str = line.substr(posVec[i+1].offset, posVec[i+1].length); m_mask_as_string = m_mask_as_string + " " + num_str; } m_mask_as_string += ","; } } } }
/// Read rectangular masks from a config file string /// @param line :: line (string) from the config file void EQSANSLoad::readRectangularMasks(const std::string &line) { // Looking for rectangular mask // Rectangular mask = 7, 0; 7, 255 boost::regex re_key("rectangular mask", boost::regex::icase); boost::regex re_key_alt("elliptical mask", boost::regex::icase); if (boost::regex_search(line, re_key) || boost::regex_search(line, re_key_alt)) { boost::regex re_sig("=[ ]*([0-9]+)[ ]*[ ,][ ]*([0-9]+)[ ]*[ ;,][ " "]*([0-9]+)[ ]*[ ,][ ]*([0-9]+)"); boost::smatch posVec; if (boost::regex_search(line, posVec, re_sig)) { if (posVec.size() == 5) { for (int i = 0; i < 4; i++) { std::string num_str = posVec[i + 1]; m_mask_as_string = m_mask_as_string + " " + num_str; } m_mask_as_string += ","; } } } }