这篇教程C++ validator函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中validator函数的典型用法代码示例。如果您正苦于以下问题:C++ validator函数的具体用法?C++ validator怎么用?C++ validator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了validator函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: validatorQDomDocument TestLanguageFiles::loadDomDocument(const QUrl &path, const QXmlSchema &schema) const{ QDomDocument document; QXmlSchemaValidator validator(schema); if (!validator.validate(path)) { qWarning() << "Schema is not valid, aborting loading of XML document:" << path.toLocalFile(); return document; } QString errorMsg; QFile file(path.toLocalFile()); if (file.open(QIODevice::ReadOnly)) { if (!document.setContent(&file, &errorMsg)) { qWarning() << errorMsg; } } else { qWarning() << "Could not open XML document " << path.toLocalFile() << " for reading, aborting."; } return document;}
开发者ID:KDE,项目名称:artikulate,代码行数:20,
示例2: snprintfvoidRestRollupsUri::handle_delete(http_request request){ std::cout << request.method() << " : " << request.absolute_uri().path() << std::endl; int rc = 0; std::string resultstr; std::pair<bool, std::string> result {true, std::string()}; char json[1024]; // extract json from request snprintf(json, sizeof(json), "%s", request.extract_string(true).get().c_str()); std::cout << "JSON:/n" << json << std::endl; rapidjson::Document document; if (document.Parse(json).HasParseError()) { rc = 1; resultstr += "document invalid"; } rapidjson::SchemaValidator validator(*_schema); if (!document.Accept(validator)) { rc = 1; resultstr += get_schema_validation_error(&validator); } Value::MemberIterator name = document.FindMember("name"); // Execute Ivy Engine command if (rc == 0) { std::unique_lock<std::mutex> u_lk(goStatementMutex); std::pair<int, std::string> rslt = m_s.delete_rollup(name->value.GetString()); } http_response response(status_codes::OK); make_response(response, resultstr, result); request.reply(response);}
开发者ID:Hitachi-Data-Systems,项目名称:ivy,代码行数:41,
示例3: validateResult validate(const Tag &tag) { Result result_base = validate_entity_with_sources(tag); Result result = validator({ must(tag, &Tag::position, notEmpty(), "position is not set!"), could(tag, &Tag::references, notEmpty(), { must(tag, &Tag::position, positionsMatchRefs(tag.references()), "number of entries in position does not match number of dimensions in all referenced DataArrays!"), could(tag, &Tag::extent, notEmpty(), { must(tag, &Tag::position, extentsMatchPositions(tag.extent()), "Number of entries in position and extent do not match!"), must(tag, &Tag::extent, extentsMatchRefs(tag.references()), "number of entries in extent does not match number of dimensions in all referenced DataArrays!") }) }), // check units for validity could(tag, &Tag::units, notEmpty(), { must(tag, &Tag::units, isValidUnit(), "Unit is invalid: not an atomic SI. Note: So far composite units are not supported!"), must(tag, &Tag::references, tagRefsHaveUnits(tag.units()), "Some of the referenced DataArrays' dimensions don't have units where the tag has. Make sure that all references have the same number of dimensions as the tag has units and that each dimension has a unit set."), must(tag, &Tag::references, tagUnitsMatchRefsUnits(tag.units()), "Some of the referenced DataArrays' dimensions have units that are not convertible to the units set in tag. Note: So far composite SI units are not supported!")}), }); return result.concat(result_base);}
开发者ID:G-Node,项目名称:nix,代码行数:21,
示例4: ASSERT_UNUSEDvoid AssociatedURLLoader::ClientAdapter::didReceiveResponse(unsigned long, const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle){ ASSERT_UNUSED(handle, !handle); if (!m_client) return; // Try to use the original ResourceResponse if possible. WebURLResponse validatedResponse = WrappedResourceResponse(response); HTTPResponseHeaderValidator validator(m_options.crossOriginRequestPolicy == WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl); if (!m_options.exposeAllResponseHeaders) validatedResponse.visitHTTPHeaderFields(&validator); // If there are blocked headers, copy the response so we can remove them. const HTTPHeaderSet& blockedHeaders = validator.blockedHeaders(); if (!blockedHeaders.isEmpty()) { validatedResponse = WebURLResponse(validatedResponse); HTTPHeaderSet::const_iterator end = blockedHeaders.end(); for (HTTPHeaderSet::const_iterator it = blockedHeaders.begin(); it != end; ++it) validatedResponse.clearHTTPHeaderField(*it); } m_client->didReceiveResponse(m_loader, validatedResponse);}
开发者ID:howardroark2018,项目名称:chromium,代码行数:22,
示例5: getFieldIdvoid URLFormWidget::validateData(){ bool valid; QString editMetadata = MetadataEngine::getInstance().getFieldProperties( MetadataEngine::EditProperty, getFieldId()); FormWidgetValidator validator(editMetadata, MetadataEngine::URLTextType); QString errorMessage; valid = validator.validate(getData(), errorMessage); if (valid) { emit dataEdited(); } else { //restore last valid value m_lineEdit->undo(); //inform FormView that the widget needs attention //by animating the widget emit requiresAttention(errorMessage); }}
开发者ID:giowck,项目名称:symphytum,代码行数:22,
示例6: rntmExtension::Validity Extension::validate(){ // Skips the validation if already done. if( m_validity != UnknownValidity ) { return m_validity; } // Retrieves the extension point. Runtime * rntm( Runtime::getDefault() ); ::boost::shared_ptr< ExtensionPoint > point( rntm->findExtensionPoint(m_point) ); // Checks that the point exists. if( !point ) { throw RuntimeException(m_point + " : invalid point reference."); } // Validates the extension. ::boost::shared_ptr< io::Validator > validator( point->getExtensionValidator() ); OSLM_ASSERT("Sorry, validator creation failed for point "<<point->getIdentifier(), validator ); // Check extension XML Node <extension id="xxx" implements="yyy" >...</extension> validator->clearErrorLog(); if( validator->validate( m_xmlNode ) == true ) { m_validity = Valid; } else { m_validity = Invalid; const std::string identifier = m_id.empty() ? "anonymous" : m_id; OSLM_ERROR("In bundle " << getBundle()->getIdentifier() << ". " << identifier << ": invalid extension XML element node does not respect schema. Verification error log is : " << std::endl << validator->getErrorLog() ); } return m_validity;}
开发者ID:corentindesfarges,项目名称:fw4spl,代码行数:39,
示例7: namevoid tst_QXmlSchemaValidator::constructorQXmlNamePool() const{ // test that the name pool from the schema is used by // the schema validator as well QXmlSchema schema; QXmlNamePool np = schema.namePool(); const QXmlName name(np, QLatin1String("localName"), QLatin1String("http://example.com/"), QLatin1String("prefix")); QXmlSchemaValidator validator(schema); QXmlNamePool np2(validator.namePool()); QCOMPARE(name.namespaceUri(np2), QString::fromLatin1("http://example.com/")); QCOMPARE(name.localName(np2), QString::fromLatin1("localName")); QCOMPARE(name.prefix(np2), QString::fromLatin1("prefix")); // make sure namePool() is const const QXmlSchemaValidator constValidator(schema); np = constValidator.namePool();}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:23,
示例8: validatorvoid tst_QXmlSchemaValidator::defaultConstructor() const{ /* Allocate instance in different orders. */ { QXmlSchema schema; QXmlSchemaValidator validator(schema); } { QXmlSchema schema1; QXmlSchema schema2; QXmlSchemaValidator validator1(schema1); QXmlSchemaValidator validator2(schema2); } { QXmlSchema schema; QXmlSchemaValidator validator1(schema); QXmlSchemaValidator validator2(schema); }}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:23,
示例9: validatorint Parser::evaluator(Token op, int value1, int value2){ // validator!! validator(value1, value2,op); switch (op) { case T_PLUS: return value1 + value2; case T_MINUS: return value1 - value2; case T_MULTIPLY: return value1 * value2; case T_DIVIDE: return value1 / value2; case T_EXP: return int(std::pow(value1 ,value2)); case T_MODULO: return value1 % value2; default: std::cout << "Error in Operation/n"; return -1; }}
开发者ID:arminak89,项目名称:CLI-Calculator,代码行数:23,
示例10: fileFileReader::FileReader(QString fileName, QAbstractItemModel* d, MyWidget* p) : file(fileName), model(d), parent(p) { QByteArray data("<?xml version=/"1.0/" encoding=/"UTF-8/" ?>" "<xsd:schema xmlns:xsd=/"http://www.w3.org/2001/XMLSchema/">" "<xsd:element name=/"chart/" type=/"chartType/"/>" " <xsd:complexType name=/"chartType/">" " <xsd:sequence>" " <xsd:element name=/"title/" type=/"xsd:string/"/>" " <xsd:element name=/"xlabel/" type=/"xsd:string/" minOccurs=/"0/"/>" " <xsd:element name=/"ylabel/" type=/"xsd:string/" minOccurs=/"0/"/>" " <xsd:element name=/"point/" type=/"pointType/" maxOccurs=/"unbounded/"/>" " </xsd:sequence>" " </xsd:complexType>" " <xsd:complexType name=/"pointType/">" " <xsd:sequence>" " <xsd:element name=/"x/" type=/"xsd:string/"/>" " <xsd:element name=/"y/" type=/"xsd:string/"/>" " </xsd:sequence>" " </xsd:complexType>" "</xsd:schema>"); if(!file.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::warning(parent, tr("qCharts"), tr("Cannot read file %1:/n%2.").arg(fileName).arg(file.errorString())); return; } QXmlSchema schema; schema.load(data); if(schema.isValid()) { QXmlSchemaValidator validator(schema); if(validator.validate(&file, QUrl::fromLocalFile(file.fileName()))){ isReadable=true; } else { isReadable=false; QMessageBox::warning(this, tr("qCharts"), tr("The file that you are trying to open isn't valid.")); } } file.close();}
开发者ID:mzilio,项目名称:qCharts,代码行数:37,
示例11: Validatorvoid UserVariableOptionsWidget::newClicked(){ class Validator : public QValidator { public: Validator(KoVariableManager *variableManager) : m_variableManager(variableManager) {} virtual State validate(QString &input, int &) const { QString s = input.trimmed(); return s.isEmpty() || m_variableManager->userVariables().contains(s) ? Intermediate : Acceptable; } private: KoVariableManager *m_variableManager; }; Validator validator(variableManager()); QString name = KInputDialog::getText(i18n("New Variable"), i18n("Name for new variable:"), QString(), 0, this, &validator).trimmed(); if (name.isEmpty()) { return; } userVariable->setName(name); variableManager()->setValue(userVariable->name(), QString(), QLatin1String("string")); updateNameEdit(); valueEdit->setFocus();}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:24,
示例12: easyvoid Feed::CheckFeed() { m_lastChecked = boost::posix_time::microsec_clock::universal_time(); cURL::EasyInterface easy(m_url, m_etag); switch (easy.PerformRequest()) { case 200: { m_etag = easy.GetResponseEtag(); FeedValidator validator(easy.GetResponseData(), *this); validator.Validate(m_feedData); m_valid = true; if (m_valid) { CreateEntries(m_feedData); } return; } case 304: { m_valid = true; return; } default: { m_entries.clear(); m_valid = false; } }}
开发者ID:purcaro,项目名称:feed-reader-lib,代码行数:24,
示例13: url bool MainWindow::validate() { QUrl url("qrc:/resources/peach.xsd"); const QByteArray instanceData = completingTextEdit->toPlainText().toUtf8(); MessageHandler messageHandler; QXmlSchema schema; schema.setMessageHandler(&messageHandler); schema.load(url); bool errorOccurred = false; if (!schema.isValid()) { errorOccurred = true; } else { QXmlSchemaValidator validator(schema); if (!validator.validate(instanceData)) errorOccurred = true; } if (errorOccurred) { statusLabel->setText(messageHandler.statusMessage()); moveCursor(messageHandler.line(), messageHandler.column()); return false; } else { statusLabel->setText(tr("Validation successful")); return true; } const QString styleSheet = QString("QstatusLabel {background: %1; padding: 3px}") .arg(errorOccurred ? QColor(Qt::red).lighter(160).name() : QColor(Qt::green).lighter(160).name()); statusLabel->setStyleSheet(styleSheet); }
开发者ID:remyjaspers,项目名称:PeachEDT,代码行数:36,
示例14: positionvoid peanoclaw::tests::StatisticsTest::testGetNeighborPositionOnDifferentLevel() { tarch::la::Vector<DIMENSIONS, double> position(1.0/3.0); tarch::la::Vector<DIMENSIONS, double> size(1.0/3.0); int level = 2; tarch::la::Vector<DIMENSIONS, double> expectedNeighborPosition; assignList(expectedNeighborPosition) = 2.0/3.0 ,0.0 #ifdef Dim3 ,0.0 #endif ; tarch::la::Vector<DIMENSIONS, int> discreteNeighborPosition; assignList(discreteNeighborPosition) = 1 ,-1 #ifdef Dim3 ,-1 #endif ; tarch::la::Vector<DIMENSIONS, double> domainOffset(0.0); tarch::la::Vector<DIMENSIONS, double> domainSize(1.0); peanoclaw::statistics::ParallelGridValidator validator(domainOffset, domainSize, false); tarch::la::Vector<DIMENSIONS, double> neighborPosition = validator.getNeighborPositionOnLevel( position, size, level, level, discreteNeighborPosition ); validateWithParams2(tarch::la::equals(neighborPosition, expectedNeighborPosition), neighborPosition, expectedNeighborPosition);}
开发者ID:unterweg,项目名称:peanoclaw,代码行数:36,
示例15: trshared_ptr<ValidationError> PersonValidator::validateEmail() const { auto editor = dynamic_cast<QLineEdit *>(mFieldEditors["email"]); auto text = editor->text().trimmed(); if (text.isEmpty()) { return nullptr; } if (text.size() > 64) { return make_shared<ValidationError>( editor, tr("Invalid data entered"), tr("The email cannot be longer than 64 characters.")); } QRegExp regExp("//b[A-Z0-9._%+-][email C++ valloc函数代码示例 C++ validationMessageValueMissingText函数代码示例
|