本文整理汇总了C++中JRegex::MatchAll方法的典型用法代码示例。如果您正苦于以下问题:C++ JRegex::MatchAll方法的具体用法?C++ JRegex::MatchAll怎么用?C++ JRegex::MatchAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRegex
的用法示例。
在下文中一共展示了JRegex::MatchAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecodeMIMEWord
void
GMessageHeader::DecodeMIMEHeader
(
JString* header
)
{
JArray<JIndexRange> subList;
JSize count = encodedMIMEQRegex.MatchAll(*header, &subList);
JBoolean qType = kJTrue;
if (count == 0)
{
count = encodedMIMEBRegex.MatchAll(*header, &subList);
qType = kJFalse;
}
if (count > 0)
{
JString temp;
JIndex mIndex = 1;
const JSize count = subList.GetElementCount();
for (JIndex i = 1; i <= count; i++)
{
JIndexRange range = subList.GetElement(i);
// if ((range.first != mIndex) &&
// RangeContainsNWS(*header, mIndex, range.first))
// {
// temp += header->GetSubstring(mIndex, range.first - 1);
// }
if (range.first != mIndex)
{
JString trimmed = header->GetSubstring(mIndex, range.first - 1);
trimmed.TrimWhitespace();
if (!trimmed.IsEmpty())
{
temp += header->GetSubstring(mIndex, range.first - 1);
}
}
temp += DecodeMIMEWord(qType, header, range);
mIndex = range.last + 1;
}
if (mIndex < header->GetLength())
{
temp += header->GetSubstring(mIndex, header->GetLength());
}
*header = temp;
}
}
示例2: if
void
GMMIMEParser::ParseMIMEHeader
(
std::istream& input,
GMIMEHeader* header,
const JBoolean display
)
{
JString data;
JCharacter c = input.peek();
if (c == '\n')
{
// input.get(c);
}
// input >> std::ws;
// first we need to search for the first empty line. This line is the
// end of the header.
JString line;
while (1)
{
JBoolean found;
line = JReadLine(input, &found);
if (line.IsEmpty())
{
break;
}
if (isspace(line.GetFirstCharacter()))
{
line.TrimWhitespace();
if (line.IsEmpty())
{
break;
}
data.AppendCharacter(' ');
}
else if (!data.IsEmpty())
{
data.AppendCharacter('\n');
}
data += line;
}
data.AppendCharacter('\n');
// we now need to search through the header for parameter:value pairs
// using the gmime_header_regex defined above.
JArray<JIndexRange> ranges;
gmime_header_regex.MatchAll(data, &ranges);
JSize count = ranges.GetElementCount();
for (JSize i = 1; i <= count; i++)
{
JIndexRange range = ranges.GetElement(i);
JString parmValPair = data.GetSubstring(range);
JString parm;
JString val;
if (parmValPair.BeginsWith("MIME") ||
parmValPair.BeginsWith("Mime") ||
parmValPair.BeginsWith("Content"))
{
CleanParmValPair(parmValPair, &parm, &val);
parm.ToLower();
if (parm == "mime-Version")
{
val.TrimWhitespace();
header->SetVersion(val);
}
else if (parm == "content-type")
{
ParseContentType(val, header);
}
else if (parm == "content-transfer-encoding")
{
val.TrimWhitespace();
val.ToLower();
header->SetEncoding(val);
}
else if (parm == "content-disposition")
{
ParseContentDisposition(val, header);
}
}
}
// this is a nested message, so some of the headers need to be displayed
if (display)
{
JString text = "---------\n";
JIndex findex = 1;
if (data.BeginsWith("From: ") || data.LocateSubstring("\nFrom: ", &findex))
{
if (findex > 1)
{
findex ++;
}
JIndex eindex = findex;
if (data.LocateNextSubstring("\n", &eindex) && (eindex > findex + 1))
{
//.........这里部分代码省略.........