Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/converter/webpricequote.cpp
Context not available. | |||||
1051 | QRegularExpression formatrex("%([mdy]+)(\\W+)%([mdy]+)(\\W+)%([mdy]+)", QRegularExpression::CaseInsensitiveOption); | 1051 | QRegularExpression formatrex("%([mdy]+)(\\W+)%([mdy]+)(\\W+)%([mdy]+)", QRegularExpression::CaseInsensitiveOption); | ||
---|---|---|---|---|---|
1052 | QRegularExpressionMatch match; | 1052 | QRegularExpressionMatch match; | ||
1053 | if (m_format.indexOf(formatrex, 0, &match) == -1) { | 1053 | if (m_format.indexOf(formatrex, 0, &match) == -1) { | ||
1054 | throw MYMONEYEXCEPTION("Invalid format string"); | 1054 | throw MYMONEYEXCEPTION_CSTRING("Invalid format string"); | ||
1055 | } | 1055 | } | ||
1056 | 1056 | | |||
1057 | QStringList formatParts; | 1057 | QStringList formatParts; | ||
Context not available. | |||||
1080 | inputrex.setPattern("(\\w+)\\W+(\\w+)\\W+(\\w+)"); | 1080 | inputrex.setPattern("(\\w+)\\W+(\\w+)\\W+(\\w+)"); | ||
1081 | 1081 | | |||
1082 | if (_in.indexOf(inputrex, 0, &match) == -1) { | 1082 | if (_in.indexOf(inputrex, 0, &match) == -1) { | ||
1083 | throw MYMONEYEXCEPTION("Invalid input string"); | 1083 | throw MYMONEYEXCEPTION_CSTRING("Invalid input string"); | ||
1084 | } | 1084 | } | ||
1085 | 1085 | | |||
1086 | QStringList scannedParts; | 1086 | QStringList scannedParts; | ||
Context not available. | |||||
1106 | if ((*it_scanned).indexOf(digitrex, 0, &match) != -1) | 1106 | if ((*it_scanned).indexOf(digitrex, 0, &match) != -1) | ||
1107 | day = match.captured(1).toUInt(&ok); | 1107 | day = match.captured(1).toUInt(&ok); | ||
1108 | if (!ok || day > 31) | 1108 | if (!ok || day > 31) | ||
1109 | throw MYMONEYEXCEPTION(QString("Invalid day entry: %1").arg(*it_scanned)); | 1109 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid day entry: %1").arg(*it_scanned)); | ||
1110 | break; | 1110 | break; | ||
1111 | case 'm': | 1111 | case 'm': | ||
1112 | month = (*it_scanned).toUInt(&ok); | 1112 | month = (*it_scanned).toUInt(&ok); | ||
Context not available. | |||||
1143 | } | 1143 | } | ||
1144 | 1144 | | |||
1145 | if (month < 1 || month > 12) | 1145 | if (month < 1 || month > 12) | ||
1146 | throw MYMONEYEXCEPTION(QString("Invalid month entry: %1").arg(*it_scanned)); | 1146 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid month entry: %1").arg(*it_scanned)); | ||
1147 | 1147 | | |||
1148 | break; | 1148 | break; | ||
1149 | case 'y': | 1149 | case 'y': | ||
1150 | if (_strict && (*it_scanned).length() != (*it_format).length()) | 1150 | if (_strict && (*it_scanned).length() != (*it_format).length()) | ||
1151 | throw MYMONEYEXCEPTION(QString("Length of year (%1) does not match expected length (%2).") | 1151 | throw MYMONEYEXCEPTION(QString::fromLatin1("Length of year (%1) does not match expected length (%2).") | ||
1152 | .arg(*it_scanned, *it_format)); | 1152 | .arg(*it_scanned, *it_format)); | ||
1153 | 1153 | | |||
1154 | year = (*it_scanned).toUInt(&ok); | 1154 | year = (*it_scanned).toUInt(&ok); | ||
1155 | 1155 | | |||
1156 | if (!ok) | 1156 | if (!ok) | ||
1157 | throw MYMONEYEXCEPTION(QString("Invalid year entry: %1").arg(*it_scanned)); | 1157 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid year entry: %1").arg(*it_scanned)); | ||
1158 | 1158 | | |||
1159 | // | 1159 | // | ||
1160 | // 2-digit year case | 1160 | // 2-digit year case | ||
Context not available. | |||||
1172 | } | 1172 | } | ||
1173 | 1173 | | |||
1174 | if (year < 1900) | 1174 | if (year < 1900) | ||
1175 | throw MYMONEYEXCEPTION(QString("Invalid year (%1)").arg(year)); | 1175 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid year (%1)").arg(year)); | ||
1176 | 1176 | | |||
1177 | break; | 1177 | break; | ||
1178 | default: | 1178 | default: | ||
1179 | throw MYMONEYEXCEPTION("Invalid format character"); | 1179 | throw MYMONEYEXCEPTION_CSTRING("Invalid format character"); | ||
1180 | } | 1180 | } | ||
1181 | 1181 | | |||
1182 | ++it_scanned; | 1182 | ++it_scanned; | ||
Context not available. | |||||
1184 | } | 1184 | } | ||
1185 | QDate result(year, month, day); | 1185 | QDate result(year, month, day); | ||
1186 | if (! result.isValid()) | 1186 | if (! result.isValid()) | ||
1187 | throw MYMONEYEXCEPTION(QString("Invalid date (yr%1 mo%2 dy%3)").arg(year).arg(month).arg(day)); | 1187 | throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid date (yr%1 mo%2 dy%3)").arg(year).arg(month).arg(day)); | ||
1188 | 1188 | | |||
1189 | return result; | 1189 | return result; | ||
1190 | } | 1190 | } | ||
Context not available. |