-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFieldStripper.cc
More file actions
49 lines (43 loc) · 1.22 KB
/
FieldStripper.cc
File metadata and controls
49 lines (43 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "FieldStripper.h"
#include <QStringList>
FieldStripper::FieldStripper()
{
}
void FieldStripper::strip(const SearchFields& sf, const QString &searchText, StringTable& table)
{
if(sf.length()==0)
{
return;
}
int from(0);
bool searching(true);
while(searching && from<searchText.size())
{
QList<FoundText> row;
for(int i=0; i<sf.size(); i++)
{
row.push_back(FoundText("", -1));
}
for(int i=0; i<sf.size(); i++)
{
int newIndex = searchText.indexOf(sf[i].searchText(), from);
if(newIndex==-1)
{
if(i==sf.size()-1)
{
searching=false;
break;
}
else
{
continue;
}
}
QString foundData = searchText.mid(newIndex+sf[i].searchText().length(), sf[i].fieldLength()).trimmed();
from = newIndex+sf[i].searchText().length()+sf[i].fieldLength();
FoundText ft = FoundText(foundData, newIndex);
row[i]=ft;
}
table.push_back(row);
}
}