本文整理汇总了C++中auto_ptr::NumFound方法的典型用法代码示例。如果您正苦于以下问题:C++ auto_ptr::NumFound方法的具体用法?C++ auto_ptr::NumFound怎么用?C++ auto_ptr::NumFound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auto_ptr
的用法示例。
在下文中一共展示了auto_ptr::NumFound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HighlightPattern
bool Sequence::HighlightPattern(const string& prositePattern, const MoleculeHighlightMap& restrictTo) const
{
bool retval = true;
try {
// update CRegexp if not the same pattern as before
static auto_ptr < CRegexp > regexp;
static string previousPrositePattern;
static int nGroups;
if (!regexp.get() || prositePattern != previousPrositePattern) {
// convert from ProSite syntax
string regexPattern;
if (!Prosite2Regex(prositePattern, ®exPattern, &nGroups))
throw "error converting ProSite to regex syntax";
// create pattern buffer
TRACEMSG("creating CRegexp with pattern '" << regexPattern << "'");
regexp.reset(new CRegexp(regexPattern, CRegexp::fCompile_ungreedy));
previousPrositePattern = prositePattern;
}
// do the search, finding all non-overlapping matches
int i, start = 0;
while (start < (int)Length()) {
// do the search
string ignore = regexp->GetMatch(sequenceString, start, 0, CRegexp::fMatch_default, true);
if (regexp->NumFound() <= 0)
break;
// TRACEMSG("got match, num (sub)patterns: " << regexp->NumFound());
// for (i=0; i<regexp->NumFound(); ++i)
// TRACEMSG(" " << i << ": " << (regexp->GetResults(i)[0] + 1) << '-' << regexp->GetResults(i)[1]);
// check to see if this entire match is within the restricted set
bool addMatch = true;
if (restrictTo.size() > 0) {
MoleculeHighlightMap::const_iterator r = restrictTo.find(identifier);
if (r != restrictTo.end()) {
for (i=1; i<regexp->NumFound(); ++i) {
for (int j=regexp->GetResults(i)[0]; j<=regexp->GetResults(i)[1]-1; ++j) {
if (!r->second[j]) {
addMatch = false;
break;
}
}
if (!addMatch)
break;
}
} else
addMatch = false;
}
// parse the match subpatterns, highlight each subpattern range
if (addMatch)
for (i=1; i<regexp->NumFound(); ++i)
GlobalMessenger()->AddHighlights(this, regexp->GetResults(i)[0], regexp->GetResults(i)[1] - 1);
// start next search after the end of this one
start = regexp->GetResults(regexp->NumFound() - 1)[1];
}
} catch (const char *err) {
ERRORMSG("Sequence::HighlightPattern() - " << err);
retval = false;
} catch (exception& e) {
ERRORMSG("Sequence::HighlightPattern() - caught exception: " << e.what());
retval = false;
}
return retval;
}