bool IsBoolField(const string& field_name) { static StringSet int_bool_filter, special_bool_filter; if (int_bool_filter.empty() && special_bool_filter.empty()) { int_bool_filter.insert("lan-mode"); int_bool_filter.insert("announce"); int_bool_filter.insert("query"); int_bool_filter.insert("rcon"); int_bool_filter.insert("logqueries"); int_bool_filter.insert("chatlogging"); special_bool_filter.insert("timestamp"); special_bool_filter.insert("output"); } return int_bool_filter.end() != int_bool_filter.find(field_name) || special_bool_filter.end() != special_bool_filter.find(field_name); }
void Viewer::CategoryImageConfig::groupChanged() { QString categoryName = currentGroup(); if (categoryName.isNull()) return; QString currentText = m_member->currentText(); m_member->clear(); StringSet directMembers = m_info->itemsOfCategory(categoryName); StringSet set = directMembers; QMap<QString,StringSet> map = DB::ImageDB::instance()->memberMap().inverseMap(categoryName); for( StringSet::const_iterator directMembersIt = directMembers.begin(); directMembersIt != directMembers.end(); ++directMembersIt ) { set += map[*directMembersIt]; } QStringList list = set.toList(); list.sort(); m_member->addItems( list ); int index = list.indexOf( currentText ); if ( index != -1 ) m_member->setCurrentIndex( index ); memberChanged(); }
bool inWordSet(int i) { const ECString& w = Pst::fromInt(i); if(wordSet.find(w) == wordSet.end()) return false; return true; }
MojErr MojObjectFilter::init(const StringSet& selectProps) { MojAssert(m_root.get() == NULL); //create the root node m_root.reset(new Node(MojString())); MojAllocCheck(m_root.get()); for (StringSet::ConstIterator i = selectProps.begin(); i != selectProps.end(); i++) { MojVector<MojString> parts; MojErr err = i->split(_T('.'), parts); MojErrCheck(err); Node* curNode = m_root.get(); for (MojVector<MojString>::ConstIterator pi = parts.begin(); pi != parts.end(); ++pi) { Node* child = curNode->find(*pi); if (child) { if (child->m_children.empty()) { break; } else { curNode = child; } } else { MojAutoPtr<Node> node(new Node(*pi)); MojAllocCheck(node.get()); Node* nextNode = node.get(); MojErr err = curNode->addChild(node); MojErrCheck(err); curNode = nextNode; } } } return MojErrNone; }
std::string normalize(const std::string& line) { static const char tbl[][3] = { "66", "67", "F2", "F3" }; size_t tblNum = sizeof(tbl) / sizeof(tbl[0]); typedef std::set<std::string> StringSet; StringSet suf; size_t pos = 0; for (; pos < line.size(); pos += 2) { bool found = false; for (size_t i = 0; i < tblNum; i++) { if (::memcmp(&line[pos], tbl[i], 2) == 0) { found = true; suf.insert(tbl[i]); break; } } if (!found) break; } std::string ret; for (StringSet::const_iterator i = suf.begin(), e = suf.end(); i != e; ++i) { ret += *i; } ret += &line[pos]; return ret; }
void Expressionizer::calculate_all_expressions(const std::string& i_str) { // __a_b__ -> __a_b__ // __a_b_ __a_b // _a_b__ a_b__ // _a_b_ a_b // // Store original -> __a_b__ OK // Remove leading _, store it -> _a_b__ OK // Remove trailing _, store it -> _a_b_ OK // Remove leading _, store it -> a_b_ OK // Remove trailing _, store it -> a_b OK // Repeat, starting with trailing -> __a_b_ OK, _a_b_ DUP, _a_b OK, a_b DUP if (i_str.size() < 2) // || i_str.find_first_not_of("_") == std::string::npos) { return; } StringSet permutations; generate_permutations(i_str, permutations); for (StringSet::const_iterator it = permutations.begin() ; it != permutations.end() ; ++it) { Expression e(*it); m_expression_seq.push_back(e); } }
void Exif::TreeView::reload() { clear(); setRootIsDecorated( true ); StringSet keys = Exif::Info::instance()->availableKeys(); QMap<QString, QTreeWidgetItem*> tree; for( StringSet::const_iterator keysIt = keys.begin(); keysIt != keys.end(); ++keysIt ) { QStringList subKeys = (*keysIt).split(QLatin1String(".")); QTreeWidgetItem* parent = nullptr; QString path; for( QStringList::Iterator subKeyIt = subKeys.begin(); subKeyIt != subKeys.end(); ++subKeyIt ) { if ( !path.isEmpty() ) path += QString::fromLatin1( "." ); path += *subKeyIt; if ( tree.contains( path ) ) parent = tree[path]; else { if ( parent == nullptr ) parent = new QTreeWidgetItem( this, QStringList(*subKeyIt) ); else parent = new QTreeWidgetItem( parent, QStringList(*subKeyIt) ); parent->setText( 1, path ); // This is simply to make the implementation of selected easier. parent->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); parent->setCheckState(0,Qt::Unchecked); tree.insert( path, parent ); } } } if ( QTreeWidgetItem* item = topLevelItem(0) ) item->setExpanded( true ); }
EStatusCode Type1ToCFFEmbeddedFontWriter::AddDependentGlyphs(StringVector& ioSubsetGlyphIDs) { EStatusCode status = PDFHummus::eSuccess; StringSet glyphsSet; StringVector::iterator it = ioSubsetGlyphIDs.begin(); bool hasCompositeGlyphs = false; for(;it != ioSubsetGlyphIDs.end() && PDFHummus::eSuccess == status; ++it) { bool localHasCompositeGlyphs; status = AddComponentGlyphs(*it,glyphsSet,localHasCompositeGlyphs); hasCompositeGlyphs |= localHasCompositeGlyphs; } if(hasCompositeGlyphs) { StringSet::iterator itNewGlyphs; for(it = ioSubsetGlyphIDs.begin();it != ioSubsetGlyphIDs.end(); ++it) glyphsSet.insert(*it); ioSubsetGlyphIDs.clear(); for(itNewGlyphs = glyphsSet.begin(); itNewGlyphs != glyphsSet.end(); ++itNewGlyphs) ioSubsetGlyphIDs.push_back(*itNewGlyphs); sort(ioSubsetGlyphIDs.begin(),ioSubsetGlyphIDs.end()); } return status; }
Listener::~Listener() { StringSet subs = theObserver.getSubscriptionsFor(this); StringSet::iterator it = subs.begin(); while (it != subs.end()) { ++it; } }
std::vector<std::string> IddFile_Impl::groups() const { StringSet result; for (const IddObject& object : objects()) { result.insert(object.group()); } return StringVector(result.begin(),result.end()); }
int Ardb::UnsubscribeAll(Context& ctx, bool notify) { if(NULL == ctx.pubsub) { return 0; } StringSet tmp = ctx.GetPubsub().pubsub_channels; StringSet::iterator it = tmp.begin(); int count = 0; while (it != tmp.end()) { count += UnsubscribeChannel(ctx, *it, notify); it++; } if (notify && count == 0 && NULL != ctx.client) { RedisReply r; RedisReply& r1 = r.AddMember(); RedisReply& r2 = r.AddMember(); RedisReply& r3 = r.AddMember(); fill_str_reply(r1, "unsubscribe"); r2.type = REDIS_REPLY_NIL; fill_int_reply(r3, ctx.GetPubsub().pubsub_channels.size() + ctx.GetPubsub().pubsub_patterns.size()); ctx.client->Write(r); } return 0; }
ModuleLinkerPass::StringVector ModuleLinkerPass::getAllSymbolsUsedByKernel( const std::string& kernelName) const { StringSet usedSymbols; usedSymbols.insert(kernelName); StringVector unprocessedSymbols = getAllSymbolsUsedByThisKernel( kernelName, _linkedModule); while(!unprocessedSymbols.empty()) { StringVector newSymbols; for(auto symbol = unprocessedSymbols.begin(); symbol != unprocessedSymbols.end(); ++symbol) { if(!usedSymbols.insert(*symbol).second) continue; if(!isKernelSymbol(_linkedModule, *symbol)) continue; StringVector kernelSymbols = getAllSymbolsUsedByThisKernel( *symbol, _linkedModule); newSymbols.insert(newSymbols.end(), kernelSymbols.begin(), kernelSymbols.end()); } unprocessedSymbols = std::move(newSymbols); } return StringVector(usedSymbols.begin(), usedSymbols.end()); }
int MMKVImpl::SRandMember(DBID db, const Data& key, const StringArrayResult& members, int count) { int err = 0; RWLockGuard<MemorySegmentManager, READ_LOCK> keylock_guard(m_segment); StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)(); if (IS_NOT_EXISTS(err)) { return 0; } if (0 != err) { return err; } if (set->empty()) { return 0; } //return whole set if (count > 0 && count > set->size()) { StringSet::iterator it = set->begin(); while (it != set->end()) { it->ToString(members.Get()); it++; } return 0; } int rand = 0; for (int i = 0; i < std::abs(count); i++) { if (count > 0) { if (i == 0) { rand = random_between_int32(0, set->size() - 1); } else { rand += i; if (rand >= set->size()) { rand -= set->size(); } } } else { rand = random_between_int32(0, set->size() - 1); } StringSet::iterator it = set->begin(); it.increment_by(rand); it->ToString(members.Get()); } return 0; }
static bool isInput(const StringSet<> &Prefixes, StringRef Arg) { if (Arg == "-") return true; for (StringSet<>::const_iterator I = Prefixes.begin(), E = Prefixes.end(); I != E; ++I) if (Arg.startswith(I->getKey())) return false; return true; }
static bool has_repeats(const Fragments& fragments) { StringSet genomes; BOOST_FOREACH (Fragment* f, fragments) { ASSERT_TRUE(f->seq()); std::string genome = f->seq()->genome(); if (genomes.find(genome) != genomes.end()) { return true; } genomes.insert(genome); }
GameManager::~GameManager() { StringSet subs = theSwitchboard.GetSubscriptionsFor(this); StringSet::iterator it = subs.begin(); while (it != subs.end()) { theSwitchboard.UnsubscribeFrom(this, *it); ++it; } }
// Note: static method bool LDModelParser::unsetToken(StringSet &tokens, const char *token) { StringSet::iterator it = tokens.find(token); if (it != tokens.end()) { tokens.erase(it); return true; } return false; }
void emitShinglesWithDocSizes(const StringSet& shingleSet, const std::string& docId) { assert(shingleSet.size() <= dedup::SKETCH_SIZE); std::string docIdWithSize = docId + dedup::DOC_SIZE_SEP + dedup::numToStr(shingleSet.size()); for (StringSet::iterator it = shingleSet.begin(); it != shingleSet.end(); ++it) { printf("%s\t%s\n", it->c_str(), docIdWithSize.c_str()); } }
bool UdmComparator::compareNode( Udm::Object udmObject1, Udm::Object udmObject2 ) { bool retval = compareNodeAux( udmObject1, udmObject2 ); StringSet includedClassNameSet = _classNameFilter.getIncludedClassNameSet(); std::cout << "Objects with the following class names were included in the comparison:" << std::endl; for( StringSet::iterator stsItr = includedClassNameSet.begin() ; stsItr != includedClassNameSet.end() ; ++stsItr ) { std::cout << *stsItr << std::endl; } std::cout << std::endl; StringSet excludedClassNameSet = _classNameFilter.getExcludedClassNameSet(); std::cout << "Objects with the following class names were excluded from the comparison:" << std::endl; for( StringSet::iterator stsItr = excludedClassNameSet.begin() ; stsItr != excludedClassNameSet.end() ; ++stsItr ) { std::cout << *stsItr << std::endl; } std::cout << std::endl; return retval; }
static inline void msd_CE_generic(const StringSet& ss, size_t depth) { typedef typename StringSet::Iterator Iterator; typedef typename StringSet::String String; if (ss.size() < g_inssort_threshold) return inssort::inssort_generic(ss, depth); // count character occurances size_t bktsize[256] = { 0 }; for (Iterator i = ss.begin(); i != ss.end(); ++i) ++bktsize[ss.get_uint8(ss[i], depth)]; String* sorted = new String[ss.size()]; // prefix sum size_t bktindex[256]; bktindex[0] = 0; for (size_t i = 1; i < 256; ++i) bktindex[i] = bktindex[i - 1] + bktsize[i - 1]; // distribute for (Iterator i = ss.begin(); i != ss.end(); ++i) sorted[bktindex[ss.get_uint8(ss[i], depth)]++] = std::move(ss[i]); size_t i = 0; for (Iterator o = ss.begin(); o != ss.end(); ++o, ++i) ss[o] = std::move(sorted[i]); delete[] sorted; // recursion Iterator bsum = ss.begin() + bktsize[0]; for (size_t i = 1; i < 256; ++i) { if (bktsize[i] == 0) continue; Iterator bend = bsum + bktsize[i]; msd_CE_generic(ss.sub(bsum, bend), depth + 1); bsum = bend; } }
void VariableCollectionHierarchy::print(const VarPrintFunc& pf) const { StringSet varSet; getVariableSet(varSet); String tst = getValue("GCC_PREPROCESSOR_DEFINITIONS"); StringSet::iterator varsIt = varSet.begin(); for (; varsIt != varSet.end(); ++varsIt) { pf.print(*varsIt, getValue(*varsIt)); } }
static void verifyAndReportDangerousProperties(const StringSet &dangerousProperties, const StringSet &clearedProperties, const std::string &ivarName, const QualType ivarType, const std::string &declName, const std::function<void(StringRef)> &emitBugReport) { // Verify that all the dangerous properties have been cleared for(auto it = dangerousProperties.begin(), end = dangerousProperties.end(); it != end; it++) { if (clearedProperties.find(*it) == clearedProperties.end()) { llvm::SmallString<128> buf; llvm::raw_svector_ostream os(buf); StringRef className; const ObjCObjectPointerType *classType = dyn_cast_or_null<ObjCObjectPointerType>(ivarType.getTypePtr()); if (classType && classType->getInterfaceDecl()) { className = classType->getInterfaceDecl()->getName(); } os << "Leaking unsafe reference to self stored in "<< ivarName << "." << *it; if (declName != "") { os << " (in " << declName << ")"; } os << ". "; os << "The assign property '" << *it << "' of the "; if (className != "") { os << "instance of " << className; } else { os << "object"; } os << " stored in '" << ivarName << "' appears to occasionally point to self. "; os << "For memory safety, you need to clear this property explicitly before losing reference to this object, typically by adding a line: '" << ivarName << "." << *it << " = nil;'. "; os << "In case of a false warning, consider adding an assert instead: 'FBAssert(" << ivarName << "." << *it << " != self);' or, if applicable: 'FBAssert(!" << ivarName << ");'."; emitBugReport(os.str()); } } }
bool SemanticValidator::nameIsUnique(StringSet set, const std::string name, CdefMessage msgType, const std::string& property) { StringSet::const_iterator got = set.find(name); if (got != set.end()) { CompileMessage error(CompileMessage::type_t::Error, msgType, _callback, "The %s '%s' is used more than once", property.c_str(), name.c_str()); return false; } set.insert(name); return true; }
MainWindow::OfferType MainWindow::ExternalPopup::appInfos(const DB::FileNameList& files ) { StringSet types = mimeTypes( files ); OfferType res; for ( StringSet::const_iterator mimeTypeIt = types.begin(); mimeTypeIt != types.end(); ++mimeTypeIt ) { KService::List offers = KMimeTypeTrader::self()->query( *mimeTypeIt, QLatin1String( "Application" )); for(KService::List::Iterator offerIt = offers.begin(); offerIt != offers.end(); ++offerIt) { res.insert( qMakePair( (*offerIt)->name(), (*offerIt)->icon() ) ); _appToMimeTypeMap[(*offerIt)->name()].insert( *mimeTypeIt ); } } return res; }
void PointMatcher<T>::ICPChainBase::loadFromYaml(std::istream& in) { this->cleanup(); YAML::Parser parser(in); YAML::Node doc; parser.GetNextDocument(doc); typedef set<string> StringSet; StringSet usedModuleTypes; // Fix for issue #6: compilation on gcc 4.4.4 //PointMatcher<T> pm; const PointMatcher & pm = PointMatcher::get(); { // NOTE: The logger needs to be initialize first to allow ouput from other contructors boost::mutex::scoped_lock lock(loggerMutex); usedModuleTypes.insert(createModuleFromRegistrar("logger", doc, pm.REG(Logger), logger)); } usedModuleTypes.insert(createModulesFromRegistrar("readingDataPointsFilters", doc, pm.REG(DataPointsFilter), readingDataPointsFilters)); usedModuleTypes.insert(createModulesFromRegistrar("readingStepDataPointsFilters", doc, pm.REG(DataPointsFilter), readingStepDataPointsFilters)); usedModuleTypes.insert(createModulesFromRegistrar("referenceDataPointsFilters", doc, pm.REG(DataPointsFilter), referenceDataPointsFilters)); //usedModuleTypes.insert(createModulesFromRegistrar("transformations", doc, pm.REG(Transformation), transformations)); //usedModuleTypes.insert(createModuleFromRegistrar("matcher", doc, pm.REG(Matcher), matcher)); // don't destroy the already created tree usedModuleTypes.insert(createModulesFromRegistrar("outlierFilters", doc, pm.REG(OutlierFilter), outlierFilters)); usedModuleTypes.insert(createModuleFromRegistrar("errorMinimizer", doc, pm.REG(ErrorMinimizer), errorMinimizer)); // See if to use a rigid transformation if (nodeVal("errorMinimizer", doc) != "PointToPointSimilarityErrorMinimizer") this->transformations.push_back(new typename TransformationsImpl<T>::RigidTransformation()); else this->transformations.push_back(new typename TransformationsImpl<T>::SimilarityTransformation()); usedModuleTypes.insert(createModulesFromRegistrar("transformationCheckers", doc, pm.REG(TransformationChecker), transformationCheckers)); usedModuleTypes.insert(createModuleFromRegistrar("inspector", doc, pm.REG(Inspector),inspector)); // FIXME: this line cause segfault when there is an error in the yaml file... //loadAdditionalYAMLContent(doc); // check YAML entries that do not correspend to any module for(YAML::Iterator moduleTypeIt = doc.begin(); moduleTypeIt != doc.end(); ++moduleTypeIt) { string moduleType; moduleTypeIt.first() >> moduleType; if (moduleType != "matcher" && usedModuleTypes.find(moduleType) == usedModuleTypes.end()) throw InvalidModuleType( (boost::format("Module type %1% does not exist") % moduleType).str() ); } }
static inline void msd_CE2_generic(const StringSet& ss, size_t depth) { typedef typename StringSet::Iterator Iterator; typedef typename StringSet::String String; if (ss.size() < g_inssort_threshold) return inssort::inssort_generic(ss, depth); // count character occurances size_t bkt[256 + 1] = { 0 }; for (Iterator i = ss.begin(); i != ss.end(); ++i) ++bkt[ss.get_uint8(ss[i], depth)]; String* sorted = new String[ss.size()]; // prefix sum for (size_t i = 1; i <= 256; ++i) bkt[i] += bkt[i - 1]; // distribute for (Iterator i = ss.begin(); i != ss.end(); ++i) sorted[--bkt[ss.get_uint8(ss[i], depth)]] = std::move(ss[i]); size_t i = 0; for (Iterator o = ss.begin(); o != ss.end(); ++o, ++i) ss[o] = std::move(sorted[i]); delete[] sorted; // recursion for (size_t i = 1; i < 256; ++i) { if (bkt[i] == bkt[i + 1]) continue; //if (bkt[i]+1 >= bkt[i+1]) continue; msd_CE2_generic(ss.sub(ss.begin() + bkt[i], ss.begin() + bkt[i + 1]), depth + 1); } }
int64_t MMKVImpl::SScan(DBID db, const Data& key, int64_t cursor, const std::string& pattern, int32_t limit_count, const StringArrayResult& results) { int err = 0; RWLockGuard<MemorySegmentManager, READ_LOCK> keylock_guard(m_segment); StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)(); if (NULL == set || 0 != err) { return err; } StringSet::iterator it = set->begin(); if (cursor >= set->size()) { return 0; } it.increment_by(cursor); int match_count = 0; while (it != set->end()) { std::string key_str; it->ToString(key_str); if (pattern == "" || stringmatchlen(pattern.c_str(), pattern.size(), key_str.c_str(), key_str.size(), 0) == 1) { std::string& ss = results.Get(); ss = key_str; match_count++; if (limit_count > 0 && match_count >= limit_count) { break; } } cursor++; it++; } return it != set->end() ? cursor : 0; }
MojErr MojDbKindState::initTokens(MojDbReq& req, const StringSet& strings) { // TODO: bug inside this function. (latest strace step) MojAssertMutexLocked(m_lock); // TODO: filing load tokens. Go inside readObj // load tokens MojErr err = readObj(TokensKey, m_tokensObj, m_kindEngine->kindDb(), req.txn(), m_oldTokensItem); MojErrCheck(err); // populate token vec MojUInt8 maxToken = 0; err = m_tokenVec.resize(m_tokensObj.size()); MojErrCheck(err); for (MojObject::ConstIterator i = m_tokensObj.begin(); i != m_tokensObj.end(); ++i) { MojString key = i.key(); MojInt64 value = i.value().intValue(); MojSize idx = (MojSize) (value - MojObjectWriter::TokenStartMarker); if (value < MojObjectWriter::TokenStartMarker || value >= MojUInt8Max || idx >= m_tokenVec.size()) { MojErrThrow(MojErrDbInvalidToken); } if (value > maxToken) { maxToken = (MojUInt8) value; } err = m_tokenVec.setAt(idx, key); MojErrCheck(err); } if (maxToken > 0) { m_nextToken = (MojUInt8) (maxToken + 1); } // add strings bool updated = false; for (StringSet::ConstIterator i = strings.begin(); i != strings.end(); ++i) { if (!m_tokensObj.contains(*i)) { updated = true; MojUInt8 token = 0; TokenVec tokenVec; MojObject tokenObj; err = addPropImpl(*i, false, token, tokenVec, tokenObj); MojErrCheck(err); } } if (updated) { err = writeTokens(m_tokensObj); MojErrCheck(err); } return MojErrNone; }
void ProcessAnimGraph(const char * section) { ConfigSectionGuard guard(section); orxASSERT(orxConfig_HasValue(links_key) && "ProcessAnimGraph needs a %s key in section %s", links_key, section); ConfigListBuilder links_preprocessor; for(orxU32 i=0, endi=orxConfig_GetListCounter(links_key);i<endi;++i) { const char * term = orxConfig_GetListString(links_key, i); if(term[0]=='+') { ConfigSectionGuard("_config_processor_tmp"); orxConfig_SetString("_tmp", term+1); for(orxU32 j=0, endj=orxConfig_GetListCounter("_tmp");j<endj;++j) { links_preprocessor << orxConfig_GetListString("_tmp", j); } } else links_preprocessor << term; } links_preprocessor.WriteToConfig(links_key); StringSet animations; ConfigListBuilder link_list_builder; for(orxU32 i=0, endi=orxConfig_GetListCounter(links_key);i<endi;++i) { const char * term_ = orxConfig_GetListString(links_key, i); substring term = {term_, term_ + strlen(term_)}; orxASSERT(strlen(term_)>0 && "Empty animation graph term"); split_result subterms = split(term, ':'); if(empty(subterms.rest)) { animations.insert(subterms.first); generateLinkSection(link_list_builder, subterms.first, subterms.first, link_properties()); } else { substring right; do { substring left = subterms.first; subterms = split(subterms.rest,':'); right = subterms.first; processSubtermPair(animations, link_list_builder, left, right); } while(!empty(subterms.rest)); } } ConfigListBuilder anim_list_builder; for(StringSet::iterator it = animations.begin(); it!= animations.end(); ++it) { anim_list_builder << orxConfig_GetString(*it); } link_list_builder.WriteToConfig("LinkList"); anim_list_builder.WriteToConfig("AnimationList"); }
int MMKVImpl::SIsMember(DBID db, const Data& key, const Data& member) { int err = 0; RWLockGuard<MemorySegmentManager, READ_LOCK> keylock_guard(m_segment); StringSet* set = GetObject<StringSet>(db, key, V_TYPE_SET, false, err)(); if (IS_NOT_EXISTS(err)) { return 0; } if (NULL == set || 0 != err) { return err; } return set->find(Object(member, true)) != set->end(); }