- Now (mostly string) arguments are passed as constant references.
- Removed some useless pure virtual method overrides.
using std::endl;
#endif
-CHIT::CHIT(string root, string postfix, string group): GHIT(root, postfix, group) {
+CHIT::CHIT(const string& root, const string& postfix, const string& group):
+ GHIT(root, postfix, group) {
#ifdef DEBUG
cerr << "In CHIT::CHIT(root = '" << root << "', postfix = '" << postfix
<< "', group = '" << group << "');" << endl;
#endif
}
-string CHIT::getFileContent(string filename) {
+string CHIT::getFileContent(const string& filename) {
Hash::iterator c = cache.find(filename);
if (c == cache.end()) {
cache[filename] = GHIT::getFileContent(filename);
* @param filename Name of the file to get the content.
* @return File content.
*/
- virtual string getFileContent(string);
+ virtual string getFileContent(const string&);
public:
/**
* @param postfix Postfix of the template files.
* @param group Starting group.
*/
- CHIT(string = string("."), string = string(".tpl"), string = string(""));
+ CHIT(const string& = string("."), const string& = string(".tpl"),
+ const string& = string(""));
/**
* Destructor.
#endif
}
-Container::Container(Hash attrs): Widget(attrs) {
+Container::Container(const Hash& attrs): Widget(attrs) {
#ifdef DEBUG
cerr << "In Container::Container(attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
-Container::Container(Hash attrs, Widget& content): Widget(attrs) {
+Container::Container(const Hash& attrs, Widget& content): Widget(attrs) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
cerr << "In Container::Container(attrs = {" /* TODO << attrs */
#endif
}
-Container::Container(Widget& content, Hash attrs): Widget(attrs) {
+Container::Container(Widget& content, const Hash& attrs): Widget(attrs) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
cerr << "In Container::Container(content = {" /* TODO << content */
*
* @param attrs Widget attributes.
*/
- Container(Hash);
+ Container(const Hash&);
/**
* Constructor.
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
- Container(Hash, Widget&);
+ Container(const Hash&, Widget&);
/**
* Constructor.
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
- Container(Widget&, Hash);
+ Container(Widget&, const Hash&);
/**
* Destructor.
* @param hit HIT template to use to render de widget.
* @return Rendered widget.
*/
- virtual string render(HIT&) = 0;
-
- /**
- * Renders the widget using a HIT template.
- *
- * @param hit HIT template to use to render de widget.
- * @return Rendered widget.
- */
- string renderContent(HIT&);
+ virtual string renderContent(HIT&);
};
}
using std::endl;
#endif
-Fallback::Fallback(string name) {
- root = NULL;
+Fallback::Fallback(const string& name): name(name) {
#ifdef DEBUG
cerr << "In Fallback::Fallback(name = '" << name << "');" << endl;
#endif
}
-Fallback::Fallback(string name, Hash attrs): Container(attrs) {
+Fallback::Fallback(const string& name, const Hash& attrs):
+ Container(attrs), name(name) {
#ifdef DEBUG
cerr << "In Fallback::Fallback(name = '" << name
<< "', attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
-Fallback::Fallback(string name, Hash attrs, Widget& content): Container(attrs) {
+Fallback::Fallback(const string& name, const Hash& attrs, Widget& content):
+ Container(attrs, content), name(name) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
cerr << "In Fallback::Fallback(name = '" << name
#endif
}
-Fallback::Fallback(string name, Widget& content, Hash attrs): Container(attrs) {
+Fallback::Fallback(const string& name, Widget& content, const Hash& attrs):
+ Container(content, attrs), name(name) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
cerr << "In Fallback::Fallback(name = '" << name
*/
class Fallback: public Container {
// Attributes.
- protected:
+ public:
/// Root widget.
- Widget* root;
+ string name;
// Methods.
public:
*
* @param name Name of the widget.
*/
- Fallback(string);
+ Fallback(const string&);
/**
* Constructor.
* @param name Name of the widget.
* @param attrs Widget attributes.
*/
- Fallback(string, Hash);
+ Fallback(const string&, const Hash&);
/**
* Constructor.
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
- Fallback(string, Hash, Widget&);
+ Fallback(const string&, const Hash&, Widget&);
/**
* Constructor.
* @param name Name of the widget.
* @param content Content of the widget.
*/
- Fallback(string, Widget&);
+ Fallback(const string&, Widget&);
/**
* Constructor.
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
- Fallback(string, Widget&, Hash);
+ Fallback(const string&, Widget&, const Hash&);
/**
* Destructor.
*/
virtual ~Fallback(void);
-
- /**
- * Renders the widget using a HIT template.
- *
- * @param hit HIT template to use to render de widget.
- * @return Rendered widget.
- */
- virtual string render(HIT&) = 0;
};
}
using std::endl;
#endif
-GHIT::GHIT(string root, string postfix, string group): HIT(root, postfix) {
+GHIT::GHIT(const string& root, const string& postfix, const string& group):
+ HIT(root, postfix) {
#ifdef DEBUG
cerr << "In GHIT::GHIT(root = '" << root << "', postfix = '" << postfix
<< "', group = '" << group << "');" << endl;
#endif
}
-string GHIT::getFileName(string blockname) {
+string GHIT::getFileName(const string& blockname) {
return string(root + '/' + group.top() + '/' + blockname + postfix);
}
-void GHIT::pushGroup(string group) {
+void GHIT::pushGroup(const string& group) {
this->group.push(group);
}
* @param blockname Name of the block to get the filename.
* @return Block's filename.
*/
- virtual string getFileName(string);
+ virtual string getFileName(const string&);
public:
/**
* @param postfix Postfix of the template files.
* @param group Starting group.
*/
- GHIT(string = string("."), string = string(".tpl"), string = string(""));
+ GHIT(const string& = string("."), const string& = string(".tpl"),
+ const string& = string(""));
/**
* Destructor.
*
* @param group Group of templates to work with.
*/
- virtual void pushGroup(string);
+ virtual void pushGroup(const string&);
/**
* Stops working with a group of templates.
using std::endl;
#endif
-HIT::HIT(string root, string postfix): root(root), postfix(postfix) {
+HIT::HIT(const string& root, const string& postfix): root(root), postfix(postfix) {
#ifdef DEBUG
cerr << "In HIT::HIT(root = '" << root << "', postfix = '" << postfix << "')" << endl;
#endif
#endif
}
-string HIT::getFileName(string blockname) {
+string HIT::getFileName(const string& blockname) {
return string(root + '/' + blockname + postfix);
}
-string HIT::getFileContent(string filename) {
+string HIT::getFileContent(const string& filename) {
stringbuf buff;
ifstream in(filename.c_str());
// FIXME - Verificar apertura.
return buff.str();
}
-string HIT::parse(string blockname, Hash& vars) {
+string HIT::parse(const string& blockname, Hash& vars) {
int pos;
string key;
string content = getFileContent(getFileName(blockname));
* @param blockname Name of the block to get the filename.
* @return Block's filename.
*/
- virtual string getFileName(string);
+ virtual string getFileName(const string&);
/**
* Gets file content.
* @param filename Name of the file to get the content.
* @return File content.
*/
- virtual string getFileContent(string);
+ virtual string getFileContent(const string&);
public:
/**
* @param root Root directory from where to get the templates.
* @param postfix Postfix of the template files.
*/
- HIT(string = string("."), string = string(".tpl"));
+ HIT(const string& = string("."), const string& = string(".tpl"));
/**
* Destructor.
* @param vars Hash containing the variable names and their values.
* @return Parsed block with variables replaced.
*/
- string parse(string, Hash&);
+ string parse(const string&, Hash&);
};
}
#endif
}
-Widget::Widget(Hash attrs): attrs(attrs) {
+Widget::Widget(const Hash& attrs): attrs(attrs) {
#ifdef DEBUG
cerr << "In Widget::Widget(attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
*
* @param attrs Widget attributes.
*/
- Widget(Hash);
+ Widget(const Hash&);
/**
* Destructor.