std::string LedgerEntryIsValid::checkOnOperationApply(Operation const& operation, OperationResult const& result, LedgerStateDelta const& lsDelta) { uint32_t currLedgerSeq = lsDelta.header.current.ledgerSeq; if (currLedgerSeq > INT32_MAX) { return fmt::format("LedgerHeader ledgerSeq ({}) exceeds limits ({})", currLedgerSeq, INT32_MAX); } auto ver = lsDelta.header.current.ledgerVersion; for (auto const& entryDelta : lsDelta.entry) { if (!entryDelta.second.current) continue; auto s = checkIsValid(*entryDelta.second.current, currLedgerSeq, ver); if (!s.empty()) { s += ": "; s += xdr::xdr_to_string(*entryDelta.second.current); return s; } } return {}; }
void BaseCheckoutWizardPage::slotChanged() { const bool valid = checkIsValid(); if (valid != d->m_valid) { d->m_valid = valid; emit completeChanged(); } }
void object::test<1>() { GeomPtr geom = fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)"); LinearRing* ring_chk = dynamic_cast<LinearRing*>(geom.get()); ensure(nullptr != ring_chk); LinearRing& ring = *ring_chk; //cout << ring.toString() << endl; updateNonClosedRing(ring); //cout << ring.toString() << endl; checkIsValid(*geom, false); }
void object::test<4>() { GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1) ))"); Polygon* poly = dynamic_cast<Polygon*>(geom.get()); ensure(nullptr != poly); const LineString* ring = poly->getInteriorRingN(0); const LinearRing* lr = dynamic_cast<const LinearRing*>(ring); ensure(nullptr != lr); LinearRing* nclr = const_cast<LinearRing*>(lr); updateNonClosedRing(*nclr); checkIsValid(*geom, false); }
std::string LedgerEntryIsValid::checkIsValid(LedgerEntry const& le, uint32_t ledgerSeq, uint32 version) const { if (le.lastModifiedLedgerSeq != ledgerSeq) { return fmt::format("LedgerEntry lastModifiedLedgerSeq ({}) does not" " equal LedgerHeader ledgerSeq ({})", le.lastModifiedLedgerSeq, ledgerSeq); } switch (le.data.type()) { case ACCOUNT: return checkIsValid(le.data.account(), version); case TRUSTLINE: return checkIsValid(le.data.trustLine(), version); case OFFER: return checkIsValid(le.data.offer(), version); case DATA: return checkIsValid(le.data.data(), version); default: return "LedgerEntry has invalid type"; } }
std::string LedgerEntryIsValid::check(IterType iter, IterType const& end, uint32_t ledgerSeq, uint32 version) const { for (; iter != end; ++iter) { auto s = checkIsValid(iter->current->mEntry, ledgerSeq, version); if (!s.empty()) { s += ": "; s += xdr::xdr_to_string(iter->current->mEntry); return s; } } return {}; }
bool HDDisk::formatPartitions() { checkIsValid(); if( reportInvalidObjectError( __PRETTY_FUNCTION__ ) ) { return false; } LOG_I() << "format partitions on device " << c_config->index(); // call createPartitionTable() if not already done! if( c_device == nullptr && createPartitions() == false ) { LOG_E() << "createPartitions() failed... Abort!"; return false; } for( auto& part_config : c_config->partition() ) { LOG_I() << "create filesystem " << part_config.filesystem() << " on " << part_config.index(); fs::path part_path( part_config.index() ); if( fs::exists( part_path ) == false ) { LOG_E() << "Partition path " << part_path.string() << " does not exist... Abort!"; return false; } Command mkfs; if( part_config.filesystem().compare("swap") == 0 ) { mkfs << "mkswap" << part_config.index(); } else { mkfs << "mkfs" << "-q" << "-t" << part_config.filesystem() << part_config.index(); } if( mkfs.waitUntilFinished() != 0 ) { LOG_E() << "creating filesystem FAILED... Abort!"; return false; } } return true; }
void object::test<5>() { GeomPtr geom = fromWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))"); checkIsValid(*geom, true); }
void object::test<2>() { GeomPtr geom = fromWKT("LINEARRING (0 0, 0 10, 10 10, 10 0, 0 0)"); checkIsValid(*geom, true); }