本文整理汇总了C++中OwnArrayPtr::set方法的典型用法代码示例。如果您正苦于以下问题:C++ OwnArrayPtr::set方法的具体用法?C++ OwnArrayPtr::set怎么用?C++ OwnArrayPtr::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwnArrayPtr
的用法示例。
在下文中一共展示了OwnArrayPtr::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: match
int RegExp::match(const UString& s, int i, OwnArrayPtr<int>* ovector)
{
if (i < 0)
i = 0;
if (ovector)
ovector->clear();
if (i > s.size() || s.isNull())
return -1;
#if ENABLE(WREC)
if (m_wrecFunction) {
int offsetVectorSize = (m_numSubpatterns + 1) * 2;
int* offsetVector = new int [offsetVectorSize];
for (int j = 0; j < offsetVectorSize; ++j)
offsetVector[j] = -1;
OwnArrayPtr<int> nonReturnedOvector;
if (!ovector)
nonReturnedOvector.set(offsetVector);
else
ovector->set(offsetVector);
int result = reinterpret_cast<WRECFunction>(m_wrecFunction)(s.data(), i, s.size(), offsetVector);
if (result < 0) {
#ifndef NDEBUG
// TODO: define up a symbol, rather than magic -1
if (result != -1)
fprintf(stderr, "jsRegExpExecute failed with result %d\n", result);
#endif
if (ovector)
ovector->clear();
}
return result;
} else
#endif
if (m_regExp) {
// Set up the offset vector for the result.
// First 2/3 used for result, the last third used by PCRE.
int* offsetVector;
int offsetVectorSize;
int fixedSizeOffsetVector[3];
if (!ovector) {
offsetVectorSize = 3;
offsetVector = fixedSizeOffsetVector;
} else {
offsetVectorSize = (m_numSubpatterns + 1) * 3;
offsetVector = new int [offsetVectorSize];
ovector->set(offsetVector);
}
int numMatches = jsRegExpExecute(m_regExp, reinterpret_cast<const UChar*>(s.data()), s.size(), i, offsetVector, offsetVectorSize);
if (numMatches < 0) {
#ifndef NDEBUG
if (numMatches != JSRegExpErrorNoMatch)
fprintf(stderr, "jsRegExpExecute failed with result %d\n", numMatches);
#endif
if (ovector)
ovector->clear();
return -1;
}
return offsetVector[0];
}
return -1;
}