diff options
author | Feffernoose <fefferburbia@gmail.com> | 2013-10-07 23:32:37 -0400 |
---|---|---|
committer | Feffernoose <fefferburbia@gmail.com> | 2013-10-07 23:32:37 -0400 |
commit | 40bf33c9df2d24219826147417ad07dd21e35d17 (patch) | |
tree | 91a06d9c5aa4adbe927bddec5522e1b27c6756e5 /freevars.h | |
parent | d4b193e6e7fdefc66d9698337581b960c30844ea (diff) | |
download | rawr-ebooks-40bf33c9df2d24219826147417ad07dd21e35d17.tar.gz rawr-ebooks-40bf33c9df2d24219826147417ad07dd21e35d17.tar.bz2 rawr-ebooks-40bf33c9df2d24219826147417ad07dd21e35d17.zip |
Implemented freevars
Arbitrary variable tokens can now be defined (though at this point only in the code itself) as a pair of a variable name and a filename pointing to a plain text file containing a newline-delimited list of elements. When a token of the form $name$ (where name is the name of a variable) is encountered, the output will include a random element from the appropriate list. The variables $name$ and $noun$ are hard-coded at this point, but the program will not crash if names.txt and nouns.txt do not exist and will instead just silently ignore the variables.
Diffstat (limited to 'freevars.h')
-rw-r--r-- | freevars.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/freevars.h b/freevars.h new file mode 100644 index 0000000..6fdc4c2 --- /dev/null +++ b/freevars.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #include <map> | ||
2 | #include <string> | ||
3 | #include <vector> | ||
4 | |||
5 | using namespace::std; | ||
6 | |||
7 | #ifndef FREEVARS_H | ||
8 | #define FREEVARS_H | ||
9 | |||
10 | class freevars | ||
11 | { | ||
12 | public: | ||
13 | freevars(); | ||
14 | void addVar(string name, string filename); | ||
15 | string parse(string in); | ||
16 | |||
17 | private: | ||
18 | map<string, vector<string>* >* vars; | ||
19 | }; | ||
20 | |||
21 | #endif FREEVARS_H \ No newline at end of file | ||