about summary refs log tree commit diff stats
path: root/freevars.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2015-11-22 18:49:58 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2015-11-22 18:49:58 -0500
commit01746a0e03267b6c082b58436c1370567f7cb7c5 (patch)
treee3cfeadb97f93858f326f57958bff4675cd8f9ed /freevars.cpp
parent294fe00911c6ee0dd9853df7612dcdbd63425c05 (diff)
downloadrawr-ebooks-01746a0e03267b6c082b58436c1370567f7cb7c5.tar.gz
rawr-ebooks-01746a0e03267b6c082b58436c1370567f7cb7c5.tar.bz2
rawr-ebooks-01746a0e03267b6c082b58436c1370567f7cb7c5.zip
Added malapropisms
Diffstat (limited to 'freevars.cpp')
-rw-r--r--freevars.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/freevars.cpp b/freevars.cpp index 6472fef..8c3eda4 100644 --- a/freevars.cpp +++ b/freevars.cpp
@@ -4,17 +4,17 @@
4 4
5freevars::freevars() 5freevars::freevars()
6{ 6{
7 vars = new map<string, vector<string>* >(); 7 vars = new std::map<std::string, std::vector<std::string>* >();
8} 8}
9 9
10void freevars::addVar(string name, string filename) 10void freevars::addVar(std::string name, std::string filename)
11{ 11{
12 vector<string>* eltlist = new vector<string>(); 12 std::vector<std::string>* eltlist = new std::vector<std::string>();
13 13
14 ifstream infile(filename.c_str()); 14 std::ifstream infile(filename.c_str());
15 if (infile) 15 if (infile)
16 { 16 {
17 string line; 17 std::string line;
18 18
19 while (getline(infile, line)) 19 while (getline(infile, line))
20 { 20 {
@@ -27,18 +27,18 @@ void freevars::addVar(string name, string filename)
27 (*vars)[name] = eltlist; 27 (*vars)[name] = eltlist;
28} 28}
29 29
30string freevars::parse(string in) 30std::string freevars::parse(std::string in)
31{ 31{
32 string res(in); 32 std::string res(in);
33 33
34 for (map<string, vector<string>* >::iterator it = vars->begin(); it != vars->end(); it++) 34 for (std::map<std::string, std::vector<std::string>* >::iterator it = vars->begin(); it != vars->end(); it++)
35 { 35 {
36 string tofind = "$" + it->first + "$"; 36 std::string tofind = "$" + it->first + "$";
37 size_t fpos = res.find(tofind); 37 size_t fpos = res.find(tofind);
38 if (fpos != string::npos) 38 if (fpos != std::string::npos)
39 { 39 {
40 int r = rand() % it->second->size(); 40 int r = rand() % it->second->size();
41 res.replace(fpos, tofind.length(), (*it->second)[r], 0, string::npos); 41 res.replace(fpos, tofind.length(), (*it->second)[r], 0, std::string::npos);
42 } 42 }
43 } 43 }
44 44