本文整理汇总了C++中SearchResult::SetColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchResult::SetColumn方法的具体用法?C++ SearchResult::SetColumn怎么用?C++ SearchResult::SetColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult::SetColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoSearchLine
void SearchThread::DoSearchLine(const wxString& line,
const int lineNum,
const int lineOffset,
const wxString& fileName,
const SearchData* data,
const wxString& findWhat,
const wxArrayString& filters,
TextStatesPtr statesPtr)
{
wxString modLine = line;
if(!data->IsMatchCase()) {
modLine.MakeLower();
}
int pos = 0;
int col = 0;
int iCorrectedCol = 0;
int iCorrectedLen = 0;
while(pos != wxNOT_FOUND) {
pos = modLine.Find(findWhat);
if(pos != wxNOT_FOUND) {
col += pos;
// Pipe support
bool allFiltersOK = true;
if(!filters.IsEmpty()) {
// Apply the filters
for(size_t i = 0; i < filters.size() && allFiltersOK; ++i) {
allFiltersOK = (modLine.Find(filters.Item(i)) != wxNOT_FOUND);
}
}
// Pipe filtes OK?
if(!allFiltersOK) return;
// we have a match
if(data->IsMatchWholeWord()) {
// make sure that the word before is not in the wordChars map
if((pos > 0) && (m_wordCharsMap.find(modLine.GetChar(pos - 1)) != m_wordCharsMap.end())) {
if(!AdjustLine(modLine, pos, findWhat)) {
break;
} else {
col += (int)findWhat.Length();
continue;
}
}
// if we have more characters to the right, make sure that the first char does not match any
// in the wordCharsMap
if(pos + findWhat.Length() <= modLine.Length()) {
wxChar nextCh = modLine.GetChar(pos + findWhat.Length());
if(m_wordCharsMap.find(nextCh) != m_wordCharsMap.end()) {
if(!AdjustLine(modLine, pos, findWhat)) {
break;
} else {
col += (int)findWhat.Length();
continue;
}
}
}
}
// Notify our match
// correct search Pos and Length owing to non plain ASCII multibyte characters
iCorrectedCol = clUTF8Length(line.c_str(), col);
iCorrectedLen = clUTF8Length(findWhat.c_str(), findWhat.Length());
SearchResult result;
result.SetPosition(lineOffset + col);
result.SetColumnInChars(col);
result.SetColumn(iCorrectedCol);
result.SetLineNumber(lineNum);
result.SetPattern(line);
result.SetFileName(fileName);
result.SetLenInChars((int)findWhat.Length());
result.SetLen(iCorrectedLen);
result.SetFindWhat(data->GetFindString());
result.SetFlags(data->m_flags);
int position(wxNOT_FOUND);
bool canAdd(true);
if(statesPtr) {
position = statesPtr->LineToPos(lineNum - 1);
position += iCorrectedCol;
}
// Make sure our match is not on a comment
if(statesPtr && position != wxNOT_FOUND && data->GetSkipComments()) {
if(statesPtr->states.size() > (size_t)position) {
short state = statesPtr->states.at(position).state;
if(state == CppWordScanner::STATE_CPP_COMMENT || state == CppWordScanner::STATE_C_COMMENT) {
canAdd = false;
}
}
}
if(statesPtr && position != wxNOT_FOUND && data->GetSkipStrings()) {
//.........这里部分代码省略.........
示例2: DoSearchLineRE
void SearchThread::DoSearchLineRE(const wxString& line,
const int lineNum,
const int lineOffset,
const wxString& fileName,
const SearchData* data,
TextStatesPtr statesPtr)
{
wxRegEx& re = GetRegex(data->GetFindString(), data->IsMatchCase());
size_t col = 0;
int iCorrectedCol = 0;
int iCorrectedLen = 0;
wxString modLine = line;
if(re.IsValid()) {
while(re.Matches(modLine)) {
size_t start, len;
re.GetMatch(&start, &len);
col += start;
// Notify our match
// correct search Pos and Length owing to non plain ASCII multibyte characters
iCorrectedCol = clUTF8Length(line.c_str(), col);
iCorrectedLen = clUTF8Length(line.c_str(), col + len) - iCorrectedCol;
SearchResult result;
result.SetPosition(lineOffset + col);
result.SetColumnInChars((int)col);
result.SetColumn(iCorrectedCol);
result.SetLineNumber(lineNum);
result.SetPattern(line);
result.SetFileName(fileName);
result.SetLenInChars((int)len);
result.SetLen(iCorrectedLen);
result.SetFlags(data->m_flags);
result.SetFindWhat(data->GetFindString());
// Make sure our match is not on a comment
int position(wxNOT_FOUND);
bool canAdd(true);
if(statesPtr) {
position = statesPtr->LineToPos(lineNum - 1);
position += iCorrectedCol;
}
if(statesPtr && position != wxNOT_FOUND && data->GetSkipComments()) {
if(statesPtr->states.size() > (size_t)position) {
short state = statesPtr->states.at(position).state;
if(state == CppWordScanner::STATE_CPP_COMMENT || state == CppWordScanner::STATE_C_COMMENT) {
canAdd = false;
}
}
}
if(statesPtr && position != wxNOT_FOUND && data->GetSkipStrings()) {
if(statesPtr->states.size() > (size_t)position) {
short state = statesPtr->states.at(position).state;
if(state == CppWordScanner::STATE_DQ_STRING || state == CppWordScanner::STATE_SINGLE_STRING) {
canAdd = false;
}
}
}
result.SetMatchState(CppWordScanner::STATE_NORMAL);
if(canAdd && statesPtr && position != wxNOT_FOUND && data->GetColourComments()) {
// set the match state
if(statesPtr->states.size() > (size_t)position) {
short state = statesPtr->states.at(position).state;
if(state == CppWordScanner::STATE_C_COMMENT || state == CppWordScanner::STATE_CPP_COMMENT) {
result.SetMatchState(state);
}
}
}
if(canAdd) {
m_results.push_back(result);
m_summary.SetNumMatchesFound(m_summary.GetNumMatchesFound() + 1);
}
col += len;
// adjust the line
if(line.Length() - col <= 0) break;
modLine = modLine.Right(line.Length() - col);
}
}
}