BYTE adopt(const boost::sub_match<TCHAR const*>& submatch) { int bt = 0; if (submatch.matched) _stscanf_s(submatch.str().c_str(),_T("%d"),&bt); return LOBYTE(bt); }
BYTE adopt_hex(const boost::sub_match<TCHAR const*>& submatch) { int bt = 0; if (submatch.matched) { if (submatch.length() == 1) { std::basic_string<TCHAR> str = submatch.str() + submatch.str(); _stscanf_s(str.c_str(),_T("%x"),&bt); } else { _stscanf_s(submatch.str().c_str(),_T("%x"),&bt); } } return LOBYTE(bt); }
Spreadsheet::CellAddress Spreadsheet::stringToAddress(const char * strAddress) { static const boost::regex e("\\${0,1}([A-Z]{1,2})\\${0,1}([0-9]{1,5})"); boost::cmatch cm; Q_ASSERT(strAddress != 0); if (boost::regex_match(strAddress, cm, e)) { const boost::sub_match<const char *> colstr = cm[1]; const boost::sub_match<const char *> rowstr = cm[2]; return CellAddress(Spreadsheet::decodeRow(rowstr.str()), Spreadsheet::decodeColumn(colstr.str())); } else throw Base::Exception("Invalid cell specifier."); }