本文整理汇总了C++中wxRegEx::ReplaceAll方法的典型用法代码示例。如果您正苦于以下问题:C++ wxRegEx::ReplaceAll方法的具体用法?C++ wxRegEx::ReplaceAll怎么用?C++ wxRegEx::ReplaceAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxRegEx
的用法示例。
在下文中一共展示了wxRegEx::ReplaceAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendLine
void CppCheckReportPage::AppendLine(const wxString& line)
{
wxString tmpLine(line);
// Locate status messages:
// 6/7 files checked 85% done
static wxRegEx reProgress(wxT("([0-9]+)/([0-9]+)( files checked )([0-9]+%)( done)"));
static wxRegEx reFileName(wxT("(Checking )([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)"));
// Locate the progress messages and update our progress bar
wxArrayString arrLines = wxStringTokenize(tmpLine, wxT("\n\r"), wxTOKEN_STRTOK);
for(size_t i = 0; i < arrLines.GetCount(); i++) {
if(reProgress.Matches(arrLines.Item(i))) {
// Get the current progress
wxString currentLine = reProgress.GetMatch(arrLines.Item(i), 1);
long fileNo(0);
currentLine.ToLong(&fileNo);
}
if(reFileName.Matches(arrLines.Item(i))) {
// Get the file name
wxString filename = reFileName.GetMatch(arrLines.Item(i), 2);
m_mgr->SetStatusMessage("CppCheck: checking file " + filename);
}
}
// Remove progress messages from the printed output
reProgress.ReplaceAll(&tmpLine, wxEmptyString);
tmpLine.Replace(wxT("\r"), wxT(""));
tmpLine.Replace(wxT("\n\n"), wxT("\n"));
m_stc->SetReadOnly(false);
m_stc->AppendText(tmpLine);
m_stc->SetReadOnly(true);
m_stc->ScrollToLine(m_stc->GetLineCount() - 1);
}
示例2: FormatComment
//.........这里部分代码省略.........
}
matchPattern.Replace(wxT("\t"), wxT(" "));
while(matchPattern.Replace(wxT(" "), wxT(" "))) {
}
matchPattern.Trim().Trim(false);
// BUG#3082954: limit the size of the 'match pattern' to a reasonable size (200 chars)
matchPattern = TagsManagerST::Get()->WrapLines(matchPattern);
matchPattern.Replace(GetName(), wxT("<b>") + GetName() + wxT("</b>"));
m_formattedComment << wxT("<code>") << matchPattern << wxT("</code>\n");
}
// Add comment section
wxString tagComment;
if(!GetFile().IsEmpty()) {
CommentParseResult comments;
::ParseComments(GetFile().mb_str(wxConvUTF8).data(), comments);
// search for comment in the current line, the line above it and 2 above it
// use the first match we got
for(size_t i = 0; i < 3; i++) {
wxString comment = comments.getCommentForLine(GetLine()-i);
if(!comment.IsEmpty()) {
SetComment(comment);
break;
}
}
}
if(!GetComment().IsEmpty()) {
wxString theComment;
theComment = GetComment();
theComment = TagsManagerST::Get()->WrapLines(theComment);
theComment.Trim(false);
wxString tagComment = wxString::Format(wxT("%s\n"), theComment.c_str());
if(m_formattedComment.IsEmpty() == false) {
m_formattedComment.Trim().Trim(false);
m_formattedComment << wxT("\n<hr>");
}
m_formattedComment << tagComment;
}
// Update all "doxy" comments and surround them with <green> tags
static wxRegEx reDoxyParam("([@\\\\]{1}param)[ \t]+([_a-z][a-z0-9_]*)?", wxRE_DEFAULT | wxRE_ICASE);
static wxRegEx reDoxyBrief("([@\\\\]{1}(brief|details))[ \t]*", wxRE_DEFAULT | wxRE_ICASE);
static wxRegEx reDoxyThrow("([@\\\\]{1}(throw|throws))[ \t]*", wxRE_DEFAULT | wxRE_ICASE);
static wxRegEx reDoxyReturn("([@\\\\]{1}(return|retval|returns))[ \t]*", wxRE_DEFAULT | wxRE_ICASE);
static wxRegEx reDoxyToDo("([@\\\\]{1}todo)[ \t]*", wxRE_DEFAULT | wxRE_ICASE);
static wxRegEx reDoxyRemark("([@\\\\]{1}(remarks|remark))[ \t]*", wxRE_DEFAULT | wxRE_ICASE);
static wxRegEx reDate("([@\\\\]{1}date)[ \t]*", wxRE_DEFAULT | wxRE_ICASE);
static wxRegEx reFN("([@\\\\]{1}fn)[ \t]*", wxRE_DEFAULT | wxRE_ICASE);
if(reDoxyParam.IsValid() && reDoxyParam.Matches(m_formattedComment)) {
reDoxyParam.ReplaceAll(&m_formattedComment, "\n<b>Parameter</b>\n<i>\\2</i>");
}
if(reDoxyBrief.IsValid() && reDoxyBrief.Matches(m_formattedComment)) {
reDoxyBrief.ReplaceAll(&m_formattedComment, "");
}
if(reDoxyThrow.IsValid() && reDoxyThrow.Matches(m_formattedComment)) {
reDoxyThrow.ReplaceAll(&m_formattedComment, "\n<b>Throws</b>\n");
}
if(reDoxyReturn.IsValid() && reDoxyReturn.Matches(m_formattedComment)) {
reDoxyReturn.ReplaceAll(&m_formattedComment, "\n<b>Returns</b>\n");
}
if(reDoxyToDo.IsValid() && reDoxyToDo.Matches(m_formattedComment)) {
reDoxyToDo.ReplaceAll(&m_formattedComment, "\n<b>TODO</b>\n");
}
if(reDoxyRemark.IsValid() && reDoxyRemark.Matches(m_formattedComment)) {
reDoxyRemark.ReplaceAll(&m_formattedComment, "\n ");
}
if(reDate.IsValid() && reDate.Matches(m_formattedComment)) {
reDate.ReplaceAll(&m_formattedComment, "<b>Date</b> ");
}
if(reFN.IsValid() && reFN.Matches(m_formattedComment)) {
size_t fnStart, fnLen, fnEnd;
if(reFN.GetMatch(&fnStart, &fnLen)) {
fnEnd = m_formattedComment.find('\n', fnStart);
if(fnEnd != wxString::npos) {
// remove the string from fnStart -> fnEnd (including ther terminating \n)
m_formattedComment.Remove(fnStart, (fnEnd - fnStart) + 1);
}
}
}
// if nothing to display skip this
m_formattedComment.Trim().Trim(false);
return m_formattedComment;
}