1 // vim: set expandtab tabstop=4 shiftwidth=4:
17 HIT::HIT(const string& root, const string& postfix): root(root), postfix(postfix) {
19 cerr << "In HIT::HIT(root = '" << root << "', postfix = '" << postfix << "')" << endl;
25 cerr << "In HIT destructor." << endl;
29 string HIT::getFileName(const string& blockname) {
30 return string(root + '/' + blockname + postfix);
33 string HIT::getFileContent(const string& filename) {
35 ifstream in(filename.c_str());
36 // FIXME - Verificar apertura.
39 cerr << "Can't read template file '" << filename << "'." << endl;
43 while (in.get(buff)) {
50 string HIT::parse(const string& blockname, Hash& vars) {
53 string content = getFileContent(getFileName(blockname));
54 for (Hash::iterator i = vars.begin(); i != vars.end(); i++) {
55 key = "{" + i->first + "}";
56 while ((pos = content.find(key)) != -1) {
58 cerr << "Founded at pos " << pos << ", key '" << key << "' (len: "
59 << key.length() << "). Will be replaced with '" << i->second
62 content.replace(pos, key.length(), i->second);
64 cerr << "New content: " << content << endl << endl << endl;