bool LookAheadRegExp::check( ErrorMap& map, bool , bool last ) { if ( !last ) { map.lookAheadError(); } return true; }
/** * FIXME: This is a default implementation - derived classes should * reimplement it for efficiency. */ void ErrorEstimator::estimate_errors(const EquationSystems & equation_systems, ErrorMap & errors_per_cell, const std::map<const System *, const NumericVector<Number> *> * solution_vectors, bool estimate_parent_error) { SystemNorm old_error_norm = this->error_norm; // Find the requested error values from each system for (unsigned int s = 0; s != equation_systems.n_systems(); ++s) { const System & sys = equation_systems.get_system(s); unsigned int n_vars = sys.n_vars(); for (unsigned int v = 0; v != n_vars; ++v) { // Only fill in ErrorVectors the user asks for if (errors_per_cell.find(std::make_pair(&sys, v)) == errors_per_cell.end()) continue; // Calculate error in only one variable std::vector<Real> weights(n_vars, 0.0); weights[v] = 1.0; this->error_norm = SystemNorm(std::vector<FEMNormType>(n_vars, old_error_norm.type(v)), weights); const NumericVector<Number> * solution_vector = nullptr; if (solution_vectors && solution_vectors->find(&sys) != solution_vectors->end()) solution_vector = solution_vectors->find(&sys)->second; this->estimate_error (sys, *errors_per_cell[std::make_pair(&sys, v)], solution_vector, estimate_parent_error); } } // Restore our old state before returning this->error_norm = old_error_norm; }
int main(int argc, char **argv) { QCoreApplication app(argc, argv); QStringList args = app.arguments(); QFile vcf, xml; if (args.count() > 1) { vcf.setFileName(args[1]); if (not vcf.open(QFile::ReadOnly)) { qWarning("Cannot open %s for reading: %s", qPrintable(vcf.fileName()), qPrintable(vcf.errorString())); return 1; } } else { if (not vcf.open(stdin, QFile::ReadOnly)) { qWarning("Cannot open STDIN for reading: %s", qPrintable(vcf.errorString())); return 1; } } QVersitReader reader(&vcf); if (not reader.startReading() || not reader.waitForFinished() || QVersitReader::NoError != reader.error()) { qWarning("Cannot read vcard: rc=%d", reader.error()); return 1; } QVersitContactImporter importer; if (not importer.importDocuments(reader.results())) { typedef QMap<int, QVersitContactImporter::Error> ErrorMap; const ErrorMap errors = importer.errors(); for(ErrorMap::ConstIterator it = errors.constBegin(); it != errors.constEnd(); ++it) { qWarning("Cannot convert contact #%d: %d", it.key(), it.value()); } return 1; } if (args.count() > 2) { xml.setFileName(args[2]); if (not xml.open(QFile::WriteOnly)) { qWarning("Cannot open %s for writing: %s", qPrintable(xml.fileName()), qPrintable(xml.errorString())); return 1; } } else { if (not xml.open(stdout, QFile::WriteOnly)) { qWarning("Cannot open STDIN for writing: %s", qPrintable(xml.errorString())); return 1; } } QTextStream out(&xml); out << "<Contacts>\n"; foreach(const QContact &contact, importer.contacts()) { out << " <Contact id=\"" << makeIri(contact) << "\">\n"; foreach(const QContactDetail &detail, contact.details()) { QVariantMap fields = detail.variantValues(); out << " <" << detail.definitionName(); if (not detail.detailUri().isEmpty()) { out << " id=\"" << detail.detailUri() << "\""; } out << ">"; if (fields.count() > 1 || fields.keys().first() != detail.definitionName()) { QVariantMap::ConstIterator it; for(it = fields.constBegin(); it != fields.constEnd(); ++it) { out << "\n "; out << "<" << it.key() << ">"; out << toString(it.value()); out << "</" << it.key() << ">"; } out << "\n "; } else { out << toString(fields.values().first()); } out << "</" << detail.definitionName() << ">\n"; } out << " </Contact>\n"; } out << "</Contacts>\n"; return 0; }
void RegExp::check( ErrorMap& map ) { map.start(); check( map, true, true ); map.end(); }