void AlphabeticIndexTest::TestPinyinFirst() { UErrorCode status = U_ZERO_ERROR; LocalPointer<RuleBasedCollator> coll( static_cast<RuleBasedCollator *>(Collator::createInstance(Locale::getChinese(), status))); if (U_FAILURE(status)) { dataerrln("Failed Collator::createInstance call - %s", u_errorName(status)); return; } int32_t reorderCodes[] = { USCRIPT_HAN }; coll->setReorderCodes(reorderCodes, LENGTHOF(reorderCodes), status); TEST_CHECK_STATUS; AlphabeticIndex index(coll.orphan(), status); TEST_CHECK_STATUS; assertEquals("getBucketCount()", 28, index.getBucketCount(status)); // ... A-Z ... index.addLabels(Locale::getChinese(), status); assertEquals("getBucketCount()", 28, index.getBucketCount(status)); // ... A-Z ... int32_t bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x897f), status); assertEquals("getBucketIndex(U+897F)", (int32_t)((UChar)0x0058/*X*/ - (UChar)0x0041/*A*/ + 1), (int32_t)bucketIndex); bucketIndex = index.getBucketIndex("i", status); assertEquals("getBucketIndex(i)", 9, bucketIndex); bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x03B1), status); assertEquals("getBucketIndex(Greek alpha)", (int32_t)27, bucketIndex); // U+50005 is an unassigned code point which sorts at the end, independent of the Hani group. bucketIndex = index.getBucketIndex(UnicodeString(0x50005), status); assertEquals("getBucketIndex(U+50005)", 27, bucketIndex); bucketIndex = index.getBucketIndex(UnicodeString((UChar)0xFFFF), status); assertEquals("getBucketIndex(U+FFFF)", 27, bucketIndex); }
Z3_ast_vector Z3_fixedpoint_from_stream( Z3_context c, Z3_fixedpoint d, std::istream& s) { ast_manager& m = mk_c(c)->m(); dl_collected_cmds coll(m); cmd_context ctx(false, &m); install_dl_collect_cmds(coll, ctx); ctx.set_ignore_check(true); if (!parse_smt2_commands(ctx, s)) { SET_ERROR_CODE(Z3_PARSER_ERROR); return 0; } Z3_ast_vector_ref* v = alloc(Z3_ast_vector_ref, m); mk_c(c)->save_object(v); for (unsigned i = 0; i < coll.m_queries.size(); ++i) { v->m_ast_vector.push_back(coll.m_queries[i].get()); } for (unsigned i = 0; i < coll.m_rels.size(); ++i) { to_fixedpoint_ref(d)->ctx().register_predicate(coll.m_rels[i].get(), true); } for (unsigned i = 0; i < coll.m_rules.size(); ++i) { to_fixedpoint_ref(d)->add_rule(coll.m_rules[i].get(), coll.m_names[i]); } ptr_vector<expr>::const_iterator it = ctx.begin_assertions(); ptr_vector<expr>::const_iterator end = ctx.end_assertions(); for (; it != end; ++it) { to_fixedpoint_ref(d)->ctx().assert_expr(*it); } return of_ast_vector(v); }
void KGlobalShortcutTest::testOverrideMainComponentData() { setupTest("testOverrideMainComponentData"); KComponentData otherComponent("test_component1"); KActionCollection coll((QObject*)NULL); coll.setComponentData(otherComponent); KShortcut cutB; // Action without action collection KAction *action = new KAction("Text For Action A", this); QVERIFY(action->d->componentData == KGlobal::mainComponent()); action->setObjectName("Action A"); action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == KGlobal::mainComponent()); // Action with action collection action->forgetGlobalShortcut(); delete action; action = coll.addAction("Action A"); QVERIFY(action->d->componentData == otherComponent); action->setGlobalShortcut(cutB, KAction::ActiveShortcut, KAction::NoAutoloading); QVERIFY(action->d->componentData == otherComponent); // cleanup action->forgetGlobalShortcut(); delete coll.takeAction(action); }
AuthRepositoryPatch AuthRepositoryServer::apply ( const AuthRepositoryPatch& clientSync ) { LogConfig::logger()->info ( "input: %s %s", clientSync.get_oldCommit().c_str(), clientSync.get_diffJson().c_str() ); authrepo::PPatch patch = authrepo::JsonPatch::parseString ( clientSync.get_diffJson() ); authrepo::DBDataSource src; //do patch authrepo::CommitNode myHead ( &m_dbStructure, src.getTaggedCommit ( "head" ) ); myHead.load ( &src ); myHead.setUserPermissions ( m_userStaticId ); authrepo::GeneralPatcher p ( &myHead, patch ); p.apply(); DBSession s = DBSessionFactory::getSession(); s.BeginTransaction(); authrepo::DBDataCollector coll ( s ); myHead.storeUpdates ( &coll ); coll.writeTag ( "head", myHead.getId() ); s.CommitTransaction(); //return current db status authrepo::CommitNode initialCommit ( &m_dbStructure, "initial" ); initialCommit.load ( &src ); AuthRepositoryPatch result; authrepo::DiffCalculator dc ( &initialCommit, &myHead ); result.set_diffJson(authrepo::JsonPatch::stringify ( dc.diff ( m_userStaticId ) )); result.set_newCommit(myHead.getId()); LogConfig::logger()->debug ( "repo output: %s %s", result.get_diffJson().c_str(), result.get_newCommit().c_str() ); return result; }
virtual bool EatPage( plRegistryPageNode *pageNode ) { #ifndef _DEBUG try { #endif if (pageNode->GetPageInfo().GetAge().CompareI(fAgeName) == 0) { // Try loading and searching thru this page hsTArray<plKey> keyRefs; IGetResMgr()->LoadPageKeys( pageNode ); plKeyCollector coll( keyRefs ); pageNode->IterateKeys( &coll ); if( !pageNode->IterateKeys( this ) ) return false; } #ifndef _DEBUG } catch (...) { } #endif return true; }
void SearchModel::searchPatternChanged(QString p) { SearchPatterns_ = Utils::GetPossibleStrings(p); if (p.isEmpty()) { unsigned size = (unsigned)Match_.size(); Match_ = GetContactListModel()->getSearchedContacts(); emit dataChanged(index(0), index(size)); return; } if (!SearchRequested_) { QTimer::singleShot(200, [this]() { SearchRequested_ = false; Ui::gui_coll_helper collection(Ui::GetDispatcher()->create_collection(), true); core::ifptr<core::iarray> patternsArray(collection->create_array()); patternsArray->reserve(SearchPatterns_.size()); for (auto iter = SearchPatterns_.begin(); iter != SearchPatterns_.end(); ++iter) { core::coll_helper coll(collection->create_collection(), true); coll.set_value_as_string("pattern", iter->toUtf8().data(), iter->toUtf8().size()); core::ifptr<core::ivalue> val(collection->create_value()); val->set_as_collection(coll.get()); patternsArray->push_back(val.get()); } collection.set_value_as_array("search_patterns", patternsArray.get()); Ui::GetDispatcher()->post_message_to_core("search", collection.get()); }); SearchRequested_ = true; } }
void AlphabeticIndexTest::TestPinyinFirst() { UErrorCode status = U_ZERO_ERROR; LocalPointer<RuleBasedCollator> coll( static_cast<RuleBasedCollator *>(Collator::createInstance(Locale::getChinese(), status))); if (U_FAILURE(status)) { dataerrln("Failed Collator::createInstance call - %s", u_errorName(status)); return; } int32_t reorderCodes[] = { USCRIPT_HAN }; coll->setReorderCodes(reorderCodes, LENGTHOF(reorderCodes), status); TEST_CHECK_STATUS; AlphabeticIndex index(coll.orphan(), status); TEST_CHECK_STATUS; assertEquals("getBucketCount()", 1, index.getBucketCount(status)); // ... (underflow only) index.addLabels(Locale::getChinese(), status); assertEquals("getBucketCount()", 28, index.getBucketCount(status)); // ... A-Z ... int bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x897f), status); assertEquals("getBucketIndex(U+897F)", 'X' - 'A' + 1, bucketIndex); bucketIndex = index.getBucketIndex("i", status); assertEquals("getBucketIndex(i)", 9, bucketIndex); bucketIndex = index.getBucketIndex(UnicodeString((UChar)0x03B1), status); assertEquals("getBucketIndex(Greek alpha)", 27, bucketIndex); // TODO: Test with an unassigned code point (not just U+FFFF) // when unassigned code points are not in the Hani reordering group any more. // String unassigned = UTF16.valueOf(0x50005); bucketIndex = index.getBucketIndex(UnicodeString((UChar)0xFFFF), status); assertEquals("getBucketIndex(U+FFFF)", 27, bucketIndex); }
bool isInRange(const vector3& posLeafCenter, const axisAlignedBox& octreeNode, const uint32& lod) { const vector3 sizeLeaf(t_tileContainer::voxelLength); const vector3 sizeLeafDoubled(sizeLeaf*2); const vector3 octreeNodeTwiceMinimum((octreeNode.getMinimum()/sizeLeafDoubled).getFloor()*sizeLeafDoubled); const axisAlignedBox octreeNodeTwice(octreeNodeTwiceMinimum, octreeNodeTwiceMinimum + octreeNode.getSize()*2.); const vector3 posLeafCenterScaled((posLeafCenter / sizeLeafDoubled).getFloor()); if (lod != 0 && false) { if (octreeNode.getSize() == sizeLeaf) { const real radius(m_syncRadien[lod-1] / 2.); blub::sphere coll2(posLeafCenter, radius); if (coll2.intersects(octreeNode)) { return false; } } } const real radius(m_syncRadien[lod]); blub::sphere coll(posLeafCenterScaled * sizeLeafDoubled + sizeLeaf, radius); const bool result(coll.intersects(octreeNodeTwice)); return result; }
void Game::findCollisions() { for(Object*& o : m.objs) { Collision coll(o->getRect(), pl.getRect()); if(coll) pl.onCollision(coll); } }
void CollationRegressionTest::TestTrailingComment() { // ICU ticket #8070: // Check that the rule parser handles a comment without terminating end-of-line. IcuTestErrorCode errorCode(*this, "TestTrailingComment"); RuleBasedCollator coll(UNICODE_STRING_SIMPLE("&c<b#comment1\n<a#comment2"), errorCode); UnicodeString a((UChar)0x61), b((UChar)0x62), c((UChar)0x63); assertTrue("c<b", coll.compare(c, b) < 0); assertTrue("b<a", coll.compare(b, a) < 0); }
adjacency_matrix::row_then_coll_iterator::iter_state_t& adjacency_matrix::row_then_coll_iterator::next(size_t size, size_t width, iter_state_t& i) { if (row(i) < width) { next_row(i); } if (row(i) == width && coll(i) < width) { next_coll(i); if (coll(i) < width) { i = iter_state_t(0, coll(i)); } } if ((row(i) == width) && (coll(i) == width)) { i = iter_state_t(size, size); } return i; }
pair<double, bool> CScoreUniqSeqCoverage::MakeScore(CBioseq_Handle const& query_handle, vector<CSeq_align const*>::const_iterator begin, vector<CSeq_align const*>::const_iterator end) { CConstRef<CBioseq> bioseq = query_handle.GetCompleteBioseq(); unsigned int qlen = 0; if ( !bioseq.Empty() && bioseq->IsSetLength()) { qlen = bioseq->GetLength(); } if ( !qlen ) { return make_pair(0, false); } bool isDenDiag = ( (*begin)->GetSegs().Which() == CSeq_align::C_Segs::e_Dendiag) ? true : false; CRangeCollection<TSeqPos> subj_rng_coll((*begin)->GetSeqRange(1)); CRange<TSeqPos> q_rng((*begin)->GetSeqRange(0)); CRangeCollection<TSeqPos> query_rng_coll(s_FixMinusStrandRange(q_rng)); for( ++begin; begin != end; ++begin ) { const CRange<TSeqPos> align_subj_rng((*begin)->GetSeqRange(1)); // subject range should always be on the positive strand assert(align_subj_rng.GetTo() > align_subj_rng.GetFrom()); CRangeCollection<TSeqPos> coll(align_subj_rng); coll.Subtract(subj_rng_coll); if ( coll.empty() ) { continue; } if(coll[0] == align_subj_rng) { CRange<TSeqPos> query_rng ((*begin)->GetSeqRange(0)); query_rng_coll += s_FixMinusStrandRange(query_rng); subj_rng_coll += align_subj_rng; } else { ITERATE (CRangeCollection<TSeqPos>, uItr, coll) { CRange<TSeqPos> query_rng; const CRange<TSeqPos> & subj_rng = (*uItr); CRef<CSeq_align> densegAln; if ( isDenDiag) { densegAln = CreateDensegFromDendiag(**begin); } CAlnMap map( (isDenDiag) ? densegAln->GetSegs().GetDenseg() : (*begin)->GetSegs().GetDenseg()); TSignedSeqPos subj_aln_start = map.GetAlnPosFromSeqPos(1,subj_rng.GetFrom()); TSignedSeqPos subj_aln_end = map.GetAlnPosFromSeqPos(1,subj_rng.GetTo()); query_rng.SetFrom(map.GetSeqPosFromAlnPos(0,subj_aln_start)); query_rng.SetTo(map.GetSeqPosFromAlnPos(0,subj_aln_end)); query_rng_coll += s_FixMinusStrandRange(query_rng); subj_rng_coll += subj_rng; } } }
OP_STATUS UniString::Remove(uni_char remove, size_t maxremove /* = OpDataFullLength */) { OpData result; UniCharFinder sepf(remove); Concatenator coll(result); RETURN_IF_ERROR(m_data.Split(&sepf, &coll, maxremove)); m_data = result; OP_ASSERT(IsUniCharAligned(m_data.Length())); return OpStatus::OK; }
TEST_F(ParseNsOrUUID, ParseValidUUID) { // Register a UUID/Collection pair in the UUIDCatalog. const CollectionUUID uuid = UUID::gen(); const NamespaceString nss("test.coll"); Collection coll(stdx::make_unique<CollectionMock>(nss)); UUIDCatalog& catalog = UUIDCatalog::get(opCtx); catalog.onCreateCollection(opCtx, &coll, uuid); auto cmd = BSON("query" << uuid); auto parsedNss = CommandHelpers::parseNsOrUUID(opCtx, "test", cmd); ASSERT_EQUALS(nss, parsedNss); }
void testSlist() { NS_STDEXT::BlockPool recycle; NS_STDEXT::ScopedPools alloc(recycle); NS_STDEXT::Slist<int> coll(alloc); coll.push_front(1); coll.push_front(2); coll.push_front(4); for (NS_STDEXT::Slist<int>::const_iterator it = coll.begin(); it != coll.end(); ++it) { std::cout << *it << '\n'; } }
TEST( RocksCollectionEntryTest, IndexCreateAndMod1 ) { std::string path = "/tmp/mongo-rocks-engine-test"; boost::filesystem::remove_all( path ); RocksEngine engine( path ); { RocksCollectionCatalogEntry coll( &engine, "test.foo" ); coll.createMetaData(); ASSERT_EQUALS( 0, coll.getTotalIndexCount() ); BSONObj spec = BSON( "key" << BSON( "a" << 1 ) << "name" << "silly" << "ns" << "test.foo" ); IndexDescriptor desc( NULL, "", spec ); { MyOperationContext opCtx( &engine ); Status status = coll.prepareForIndexBuild( &opCtx, &desc ); ASSERT_OK( status ); } ASSERT_EQUALS( 1, coll.getTotalIndexCount() ); ASSERT_EQUALS( 0, coll.getCompletedIndexCount() ); ASSERT( !coll.isIndexReady( "silly" ) ); { MyOperationContext opCtx( &engine ); coll.indexBuildSuccess( &opCtx, "silly" ); } ASSERT_EQUALS( 1, coll.getTotalIndexCount() ); ASSERT_EQUALS( 1, coll.getCompletedIndexCount() ); ASSERT( coll.isIndexReady( "silly" ) ); ASSERT_EQUALS( DiskLoc(), coll.getIndexHead( "silly" ) ); { MyOperationContext opCtx( &engine ); coll.setIndexHead( &opCtx, "silly", DiskLoc( 123,321 ) ); } ASSERT_EQUALS( DiskLoc(123, 321), coll.getIndexHead( "silly" ) ); ASSERT( !coll.isIndexMultikey( "silly" ) ); { MyOperationContext opCtx( &engine ); coll.setIndexIsMultikey( &opCtx, "silly", true ); } ASSERT( coll.isIndexMultikey( "silly" ) ); } }
AddUserResult AuthRepositoryServer::updateUserWithRole ( const std::string &licenseStaticId, const std::string &login, const std::string &password, const std::string &fullName, const std::string &email, const std::string &phone, bool enabled, const std::string& roleStaticId, const std::vector<std::string> & groupStaticIdList, const std::string &userStaticId ) { AddUserResult result; try { authrepo::DBDataSource src; authrepo::CommitNode myHead ( &m_dbStructure, src.getTaggedCommit ( "head" ) ); myHead.load ( &src ); myHead.setUserPermissions ( m_userStaticId ); validateUpdateUserParams ( myHead, licenseStaticId, login, password, fullName, email, phone, enabled, userStaticId ); updateUser ( myHead, licenseStaticId, login, password, fullName, email, phone, enabled, roleStaticId, groupStaticIdList, userStaticId ); //write DBSession s = DBSessionFactory::getSession(); s.BeginTransaction(); authrepo::DBDataCollector coll ( s ); myHead.storeUpdates ( &coll ); coll.writeTag ( "head", myHead.getId() ); if (!password.empty()) { std::string newSalt = authtools::generateRandomSalt(); std::string pwdHash = authtools::calculatePwdHash ( password, newSalt ); std::string computeridToken = authtools::calculatePwdHash ( licenseStaticId, authtools::generateRandomSalt() ); s.execUpdate ( "DELETE FROM repo.user_credentials WHERE userstaticid = %s", userStaticId.c_str() ); s.execUpdate ( "INSERT INTO repo.user_credentials(userstaticid, pwdhash, pwdsalt) VALUES (%s, %s, %s)", userStaticId.c_str(), pwdHash.c_str(), newSalt.c_str() ); } s.CommitTransaction(); result.set_successful ( true ); } catch ( ValidationException &re ) { result.set_successful ( false ); result.set_errorMessage ( re.what() ); } catch ( authrepo::util::permissions_check_error& e ) { result.set_successful ( false ); result.set_errorMessage ( "insufficient permissions" ); } return result; }
void testList() { NS_STDEXT::BlockPool recycle; NS_STDEXT::ScopedPools alloc(recycle); NS_STDEXT::List<Obj> coll(alloc); coll.push_back(1); coll.push_back(2); coll.push_back(4); while (!coll.empty()) { std::cout << coll.back().get() << '\n'; coll.pop_back(); } }
TEST_F(KVStorageEngineTest, RecreateIndexes) { repl::setGlobalReplicationCoordinator( new repl::ReplicationCoordinatorMock(getGlobalServiceContext(), repl::ReplSettings())); auto opCtx = cc().makeOperationContext(); // Create two indexes for `db.coll1` in the catalog named `foo` and `bar`. Verify the indexes // appear as idents in the KVEngine. ASSERT_OK(createCollection(opCtx.get(), NamespaceString("db.coll1")).getStatus()); ASSERT_OK(createIndex(opCtx.get(), NamespaceString("db.coll1"), "foo")); ASSERT_OK(createIndex(opCtx.get(), NamespaceString("db.coll1"), "bar")); auto kvIdents = getAllKVEngineIdents(opCtx.get()); ASSERT_EQUALS(2, std::count_if(kvIdents.begin(), kvIdents.end(), [](const std::string& str) { return str.find("index-") == 0; })); // Use the `getIndexNameObjs` to find the `foo` index in the IndexCatalog. DatabaseCatalogEntry* dbce = _storageEngine->getDatabaseCatalogEntry(opCtx.get(), "db"); CollectionCatalogEntry* cce = dbce->getCollectionCatalogEntry("db.coll1"); auto swIndexNameObjs = getIndexNameObjs( opCtx.get(), dbce, cce, [](const std::string& indexName) { return indexName == "foo"; }); ASSERT_OK(swIndexNameObjs.getStatus()); auto& indexNameObjs = swIndexNameObjs.getValue(); // There's one index that matched the name `foo`. ASSERT_EQUALS(static_cast<const unsigned long>(1), indexNameObjs.first.size()); // Assert the parallel vectors have matching sizes. ASSERT_EQUALS(static_cast<const unsigned long>(1), indexNameObjs.second.size()); // The index that matched should be named `foo`. ASSERT_EQUALS("foo", indexNameObjs.first[0]); ASSERT_EQUALS("db.coll1"_sd, indexNameObjs.second[0].getStringField("ns")); ASSERT_EQUALS("foo"_sd, indexNameObjs.second[0].getStringField("name")); ASSERT_EQUALS(2, indexNameObjs.second[0].getIntField("v")); ASSERT_EQUALS(1, indexNameObjs.second[0].getObjectField("key").getIntField("foo")); // Drop the `foo` index table. Count one remaining index ident according to the KVEngine. ASSERT_OK(dropIndexTable(opCtx.get(), NamespaceString("db.coll1"), "foo")); kvIdents = getAllKVEngineIdents(opCtx.get()); ASSERT_EQUALS(1, std::count_if(kvIdents.begin(), kvIdents.end(), [](const std::string& str) { return str.find("index-") == 0; })); AutoGetCollection coll(opCtx.get(), NamespaceString("db.coll1"), LockMode::MODE_X); // Find the `foo` index in the catalog. Rebuild it. Count two indexes in the KVEngine. ASSERT_OK(rebuildIndexesOnCollection(opCtx.get(), dbce, cce, indexNameObjs)); ASSERT_TRUE(cce->isIndexReady(opCtx.get(), "foo")); kvIdents = getAllKVEngineIdents(opCtx.get()); ASSERT_EQUALS(2, std::count_if(kvIdents.begin(), kvIdents.end(), [](const std::string& str) { return str.find("index-") == 0; })); }
OP_STATUS UniString::Replace(uni_char character, uni_char replacement, size_t maxreplace, size_t* replaced) { OpData result; UniCharFinder sepf(character); OpData replacement_data; RETURN_IF_ERROR(replacement_data.SetCopyData(reinterpret_cast<const char *>(&replacement), sizeof(uni_char))); ReplaceConcatenator coll(result, replacement_data, m_data.Length()); RETURN_IF_ERROR(m_data.Split(&sepf, &coll, maxreplace)); coll.Done(); m_data = result; if (replaced) *replaced = coll.CountReplacement(); OP_ASSERT(IsUniCharAligned(m_data.Length())); return OpStatus::OK; }
void AlphabeticIndexTest::TestNoLabels() { UErrorCode status = U_ZERO_ERROR; LocalPointer<RuleBasedCollator> coll( static_cast<RuleBasedCollator *>(Collator::createInstance(Locale::getRoot(), status))); TEST_CHECK_STATUS; AlphabeticIndex index(coll.orphan(), status); TEST_CHECK_STATUS; index.addRecord(UnicodeString((UChar)0x897f), NULL, status); index.addRecord("i", NULL, status); index.addRecord(UnicodeString((UChar)0x03B1), NULL, status); assertEquals("getBucketCount()", 1, index.getBucketCount(status)); // ... TEST_ASSERT(index.nextBucket(status)); assertEquals("underflow label type", (int32_t)U_ALPHAINDEX_UNDERFLOW, index.getBucketLabelType()); assertEquals("all records in the underflow bucket", (int32_t)3, index.getBucketRecordCount()); }
OP_STATUS UniString::Remove(const uni_char *remove, size_t length /* = OpDataUnknownLength */, size_t maxremove /* = OpDataFullLength */) { OP_ASSERT(remove); if (length == OpDataUnknownLength) length = uni_strlen(remove); OpData result; UniCharSequenceFinder sepf(remove, length); Concatenator coll(result); RETURN_IF_ERROR(m_data.Split(&sepf, &coll, maxremove)); m_data = result; OP_ASSERT(IsUniCharAligned(m_data.Length())); return OpStatus::OK; }
/* * Servo Information (all servos are generic) * */ void Heli::setup_servos() { this->servos.clear(); Servo pitch( -8.0*C_DEG2RAD, 8.0*C_DEG2RAD ); Servo roll( -8.0*C_DEG2RAD, 8.0*C_DEG2RAD ); Servo coll( -12.5*C_DEG2RAD, 18.0*C_DEG2RAD ); Servo tr( -20.0*C_DEG2RAD, 20.0*C_DEG2RAD ); this->servos.push_back( pitch ); this->servos.push_back( roll ); this->servos.push_back( coll ); this->servos.push_back( tr ); }
NekDouble StdExpansion2D::v_PhysEvaluate(const Array<OneD, const NekDouble>& coords, const Array<OneD, const NekDouble> & physvals) { Array<OneD, NekDouble> coll(2); Array<OneD, DNekMatSharedPtr> I(2); ASSERTL2(coords[0] > -1 - NekConstants::kNekZeroTol, "coord[0] < -1"); ASSERTL2(coords[0] < 1 + NekConstants::kNekZeroTol, "coord[0] > 1"); ASSERTL2(coords[1] > -1 - NekConstants::kNekZeroTol, "coord[1] < -1"); ASSERTL2(coords[1] < 1 + NekConstants::kNekZeroTol, "coord[1] > 1"); LocCoordToLocCollapsed(coords,coll); I[0] = m_base[0]->GetI(coll); I[1] = m_base[1]->GetI(coll+1); return v_PhysEvaluate(I,physvals); }
OP_STATUS UniString::Replace(const uni_char* substring, const uni_char* replacement, size_t maxreplace, size_t* replaced) { if (!substring || !*substring) return OpStatus::ERR; OpData result; size_t substring_length = uni_strlen(substring); UniCharSequenceFinder sepf(substring, substring_length); size_t replacement_length = replacement ? uni_strlen(replacement) : 0; OpData replacement_data; RETURN_IF_ERROR(replacement_data.SetCopyData(reinterpret_cast<const char *>(replacement), sizeof(uni_char) * replacement_length)); ReplaceConcatenator coll(result, replacement_data); RETURN_IF_ERROR(m_data.Split(&sepf, &coll, maxreplace)); m_data = result; if (replaced) *replaced = coll.CountReplacement(); OP_ASSERT(IsUniCharAligned(m_data.Length())); return OpStatus::OK; }
void EntryUpdateJobTest::testUpdate() { Tellico::Data::CollPtr coll(new Tellico::Data::BibtexCollection(true)); Tellico::Data::FieldPtr field(new Tellico::Data::Field("arxiv", "Arxiv ID")); coll->addField(field); Tellico::Data::EntryPtr entry(new Tellico::Data::Entry(coll)); entry->setField("arxiv", "hep-lat/0110180"); coll->addEntries(entry); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ArxivFetcher(this)); // don't use 'this' as job parent, it crashes Tellico::EntryUpdateJob* job = new Tellico::EntryUpdateJob(0, entry, fetcher); connect(job, SIGNAL(result(KJob*)), &m_loop, SLOT(quit())); job->start(); m_loop.exec(); QCOMPARE(entry->field("title"), QLatin1String("Speeding up the Hybrid-Monte-Carlo algorithm for dynamical fermions")); }
void csBulletRigidBody::AddCollider (CS::Collisions::iCollider* collider, const csOrthoTransform& relaTrans) { csRef<csBulletCollider> coll (dynamic_cast<csBulletCollider*>(collider)); CS::Collisions::ColliderType type = collider->GetGeometryType (); if (type == CS::Collisions::COLLIDER_CONCAVE_MESH ||type == CS::Collisions::COLLIDER_CONCAVE_MESH_SCALED ||type == CS::Collisions::COLLIDER_PLANE) haveStaticColliders ++; else if (type == CS::Collisions::COLLIDER_TERRAIN) { csFPrintf (stderr, "csBulletRigidBody: Can not add terrain collider to physical body.\n"); return; } colliders.Push (coll); relaTransforms.Push (relaTrans); shapeChanged = true; }
void AuthRepositoryServer::setDeviceIdent ( const std::string& deviceStaticId, const std::string& deviceident ) { authrepo::DBDataSource src; authrepo::CommitNode myHead ( &m_dbStructure, src.getTaggedCommit ( "head" ) ); myHead.load ( &src ); myHead.setUserPermissions ( m_userStaticId ); authrepo::DataNode *device = myHead.getIndex()->getIndex ( m_dbStructure.getByName ( "device" ) )->findStaticId ( deviceStaticId ); if ( !device ) throw std::runtime_error ( "AuthRepositoryServer::setDeviceIdent unknown device: " + deviceStaticId ); device->setField("deviceident", deviceident); device->setField("friendsstatus", "2"); //write DBSession s = DBSessionFactory::getSession(); s.BeginTransaction(); authrepo::DBDataCollector coll ( s ); myHead.storeUpdates ( &coll ); coll.writeTag ( "head", myHead.getId() ); s.CommitTransaction(); }
std::string AuthRepositoryServer::registerNewTrial ( const RegistrationParams& params ) { try { authrepo::DBDataSource src; authrepo::CommitNode myHead ( &m_dbStructure, src.getTaggedCommit ( "head" ) ); myHead.load ( &src ); myHead.setRootPermissions(); validateTrialParams ( myHead, params ); std::string userStaticId; std::string licenseStaticId; addTrial ( myHead, params, userStaticId, licenseStaticId ); //write DBSession s = DBSessionFactory::getSession(); s.BeginTransaction(); authrepo::DBDataCollector coll ( s ); myHead.storeUpdates ( &coll ); coll.writeTag ( "head", myHead.getId() ); std::string newSalt = authtools::generateRandomSalt(); std::string pwdHash = authtools::calculatePwdHash ( params.get_password(), newSalt ); std::string computeridToken = authtools::calculatePwdHash ( licenseStaticId, authtools::generateRandomSalt()); s.execUpdate ( "DELETE FROM repo.user_credentials WHERE userstaticid = %s", userStaticId.c_str() ); s.execUpdate ( "INSERT INTO repo.user_credentials(userstaticid, pwdhash, pwdsalt) VALUES (%s, %s, %s)", userStaticId.c_str(), pwdHash.c_str(), newSalt.c_str() ); s.execUpdate ( "INSERT INTO license_token(licensestaticid, computerid_token) VALUES (%s, %s)", licenseStaticId.c_str(), computeridToken.c_str()); s.CommitTransaction(); } catch ( ValidationException &re ) { return std::string ( re.what() ); } return std::string(); }
AlphabeticIndex::ImmutableIndex *AlphabeticIndex::buildImmutableIndex(UErrorCode &errorCode) { if (U_FAILURE(errorCode)) { return NULL; } // In C++, the ImmutableIndex must own its copy of the BucketList, // even if it contains no records, for proper memory management. // We could clone the buckets_ if they are not NULL, // but that would be worth it only if this method is called multiple times, // or called after using the old-style bucket iterator API. LocalPointer<BucketList> immutableBucketList(createBucketList(errorCode)); LocalPointer<RuleBasedCollator> coll( static_cast<RuleBasedCollator *>(collatorPrimaryOnly_->clone())); if (immutableBucketList.isNull() || coll.isNull()) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } ImmutableIndex *immIndex = new ImmutableIndex(immutableBucketList.getAlias(), coll.getAlias()); if (immIndex == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } // The ImmutableIndex adopted its parameter objects. immutableBucketList.orphan(); coll.orphan(); return immIndex; }