-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (27 loc) · 860 Bytes
/
main.cpp
File metadata and controls
38 lines (27 loc) · 860 Bytes
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
#include "randodo.h"
int main(int argc, char **argv)
{
if (argc < 3) {
std::cerr << "Usage: randodo <file_name> <generator_name> [how_many=1]" << std::endl;
return -1;
}
srand(time(NULL));
std::string fileName = argv[1], generatorName = argv[2];
int howMany = 1;
if (argc > 3) {
howMany = atoi(argv[3]);
}
Randodo::ConfigFile<> configFile(fileName);
auto &mapOfGenerators = configFile.getMapOfGenerators();
auto iter = mapOfGenerators.find(generatorName);
if (iter == mapOfGenerators.end()) {
std::cerr << "Couldn't find specified file or generator" << std::endl;
return -2;
}
for (int i = 0; i < howMany; ++i) {
std::stringstream stream;
iter->second->generate(stream);
std::cout << stream.str() << std::endl;
}
return 0;
}