-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjunk_manager.cpp
More file actions
51 lines (44 loc) · 975 Bytes
/
junk_manager.cpp
File metadata and controls
51 lines (44 loc) · 975 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include ".\junk_manager.h"
#include "junk_template.h"
#include "junk_loader.h"
#include "configuration.h"
#include <iostream>
#include "source_parser.h"
junk_manager::junk_manager(void)
{
_list.clear();
}
junk_manager::~junk_manager(void)
{
}
void junk_manager::init()
{
junk_loader loader;
loader.load_files(configuration::instance().value(config::templates,"path"));
}
void junk_manager::add_junk(junk_template *el)
{
if(!strstr(configuration::instance().value(config::disabled_template,"misc"),el->name.c_str()))
_list.push_front(el);
else
std::cout << "disabled template: "<< el->name << std::endl;
}
char * junk_manager::random_junk()
{
junk_list::iterator iter;
int max=0;
max=_list.size();
if(max)
{
max=rand()%max;
for(iter=_list.begin();iter!=_list.end();iter++)
{
if(!max--)
{
*source_parser::instance().output_macro() << ";using template " << (*iter)->name << std::endl;
return (*iter)->tostr();
}
}
}
return "";
}