-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVPLBible.cpp
More file actions
78 lines (59 loc) · 1.5 KB
/
Copy pathVPLBible.cpp
File metadata and controls
78 lines (59 loc) · 1.5 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "VPLBible.h"
const string& TearsForNations::VPLBible::getScripture(int bk, int ch, int vs)
{
//TODO: umm convert to absolute verse
return getLastFoundScripture();
}
const string& TearsForNations::VPLBible::getScripture(int absolute_vs)
{
string buffer;
int line_num = 0;
if (m_pfile->fail()){
this->openFile(m_filename);
}
m_pfile->seekg(0, ios_base::beg);
m_lastfound = "";
m_lastfound_absolute_vs = 0;
//search until end of file
while (!m_pfile->eof())
{
//each line is a verse
getline(*m_pfile, buffer);
line_num++;
if (line_num == absolute_vs)
{
m_lastfound = buffer;
m_lastfound_absolute_vs = line_num;
return m_lastfound;
}
}
return m_lastfound;
}
const string& TearsForNations::VPLBible::find(string str, int start_absolute_vs)
{
string buffer;
int line_num = 0;
if (m_pfile->fail()){
this->openFile(m_filename);
}
m_pfile->seekg(0, ios_base::beg);
m_lastfound = "";
m_lastfound_absolute_vs = 0;
//printf("finding %s", str.c_str());
//search until end of file
while (!m_pfile->eof())
{
//each line is a verse
getline(*m_pfile, buffer);
line_num++;
//if neccessary skip lines until we get to the one we want to start the search at
if (start_absolute_vs > line_num){ continue; }
if (buffer.find(str) != string::npos)
{
m_lastfound = buffer;
m_lastfound_absolute_vs = line_num;
return m_lastfound;
}
}
return m_lastfound;
}