diff options
Diffstat (limited to 'freevars.cpp')
-rw-r--r-- | freevars.cpp | 22 |
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 | ||
5 | freevars::freevars() | 5 | freevars::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 | ||
10 | void freevars::addVar(string name, string filename) | 10 | void 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 | ||
30 | string freevars::parse(string in) | 30 | std::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 | ||