本文整理汇总了C++中Match::setNoGroups方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::setNoGroups方法的具体用法?C++ Match::setNoGroups怎么用?C++ Match::setNoGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::setNoGroups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: context
RefArrayVectorOf<XMLCh>* RegularExpression::tokenize(const XMLCh* const expression,
const int start, const int end,
RefVectorOf<Match> *subEx){
if (fOperations == 0)
prepare();
RefArrayVectorOf<XMLCh>* tokenStack = new (fMemoryManager) RefArrayVectorOf<XMLCh>(16, true, fMemoryManager);
Context context(fMemoryManager);
int strLength = XMLString::stringLen(expression);
context.reset(expression, strLength, start, end, fNoClosures);
Match* lMatch = 0;
bool adoptMatch = false;
if (subEx || fHasBackReferences) {
lMatch = new (fMemoryManager) Match(fMemoryManager);
adoptMatch = true;
lMatch->setNoGroups(fNoGroups);
}
if (context.fAdoptMatch)
delete context.fMatch;
context.fMatch = lMatch;
context.fAdoptMatch = adoptMatch;
int tokStart = start;
int matchStart = start;
for (; matchStart <= end; matchStart++) {
int matchEnd = match(&context, fOperations, matchStart, 1);
if (matchEnd != -1) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, context.fStart);
context.fMatch->setEndPos(0, matchEnd);
}
if (subEx){
subEx->addElement(lMatch);
lMatch = new (fMemoryManager) Match(*(context.fMatch));
adoptMatch = true;
context.fAdoptMatch = adoptMatch;
context.fMatch = lMatch;
}
XMLCh* token;
if (tokStart == matchStart){
if (tokStart == strLength){
tokStart--;
break;
}
token = (XMLCh*) fMemoryManager->allocate(sizeof(XMLCh));//new XMLCh[1];
token[0] = chNull;
// When you tokenize using zero string, will return each
// token in the string. Since the zero string will also
// match the start/end characters, resulting in empty
// tokens, we ignore them and do not add them to the stack.
if (!XMLString::equals(fPattern, &chNull))
tokenStack->addElement(token);
else
fMemoryManager->deallocate(token);//delete[] token;
} else {
token = (XMLCh*) fMemoryManager->allocate
(
(matchStart + 1 - tokStart) * sizeof(XMLCh)
);//new XMLCh[matchStart + 1 - tokStart];
XMLString::subString(token, expression, tokStart, matchStart, fMemoryManager);
tokenStack->addElement(token);
}
tokStart = matchEnd;
//decrement matchStart as will increment it at the top of the loop
if (matchStart < matchEnd - 1)
matchStart = matchEnd - 1;
}
}
XMLCh* token;
if (matchStart == tokStart + 1){
token = (XMLCh*) fMemoryManager->allocate(sizeof(XMLCh));//new XMLCh[1];
token[0] = chNull;
} else {
token = (XMLCh*) fMemoryManager->allocate
(
//.........这里部分代码省略.........
示例2: matches
bool RegularExpression::matches(const XMLCh* const expression, const int start,
const int end, Match* const pMatch
, MemoryManager* const manager) {
if (fOperations == 0)
prepare();
Context context(manager);
int strLength = XMLString::stringLen(expression);
context.reset(expression, strLength, start, end, fNoClosures);
bool adoptMatch = false;
Match* lMatch = pMatch;
if (lMatch != 0) {
lMatch->setNoGroups(fNoGroups);
}
else if (fHasBackReferences) {
lMatch = new (fMemoryManager) Match(fMemoryManager);
lMatch->setNoGroups(fNoGroups);
adoptMatch = true;
}
if (context.fAdoptMatch)
delete context.fMatch;
context.fMatch = lMatch;
context.fAdoptMatch = adoptMatch;
if (isSet(fOptions, XMLSCHEMA_MODE)) {
int matchEnd = match(&context, fOperations, context.fStart, 1);
if (matchEnd == context.fLimit) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, context.fStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
return false;
}
/*
* If the pattern has only fixed string, use Boyer-Moore
*/
if (fFixedStringOnly) {
int ret = fBMPattern->matches(expression, context.fStart,
context.fLimit);
if (ret >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, ret);
context.fMatch->setEndPos(0, ret + strLength);
}
return true;
}
return false;
}
/*
* If the pattern contains a fixed string, we check with Boyer-Moore
* whether the text contains the fixed string or not. If not found
* return false
*/
if (fFixedString != 0) {
int ret = fBMPattern->matches(expression, context.fStart,
context.fLimit);
if (ret < 0) { // No match
return false;
}
}
int limit = context.fLimit - fMinLength;
int matchStart;
int matchEnd = -1;
/*
* Check whether the expression start with ".*"
*/
if (fOperations != 0 && fOperations->getOpType() == Op::O_CLOSURE
&& fOperations->getChild()->getOpType() == Op::O_DOT) {
if (isSet(fOptions, SINGLE_LINE)) {
matchStart = context.fStart;
matchEnd = match(&context, fOperations, matchStart, 1);
}
else {
bool previousIsEOL = true;
for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
XMLCh ch = expression[matchStart];
//.........这里部分代码省略.........