#include "chit.h"
+using namespace bife;
+
#ifdef DEBUG
#include <iostream>
using std::cerr;
#include "hash.h"
#include <string>
-using std::string;
-
-/**
- * Cache enabled GHIT.
- *
- * GHIT with cache capabilities added. The templates are stored in memory once
- * they are readed and reused in succesive parse() calls, avoiding disc reads
- * overhead.
- *
- * @todo See if it's really usefull, since the OS is supposed to be in charge
- * of disc cache.
- */
-class CHIT: public GHIT {
- // Attributes.
- protected:
- /// Cache storage.
- Hash cache;
-
- // Methods.
- protected:
- /**
- * Gets cached file content.
- *
- * @param filename Name of the file to get the content.
- * @return File content.
- */
- virtual string getFileContent(string);
-
- public:
- /**
- * Constructor.
- *
- * @param root Root directory from where to get the templates.
- * @param postfix Postfix of the template files.
- * @param group Starting group.
- */
- CHIT(string = string("."), string = string(".tpl"), string = string(""));
-
- /**
- * Destructor.
- */
- virtual ~CHIT(void);
-};
+namespace bife {
+
+ using std::string;
+
+ /**
+ * Cache enabled GHIT.
+ *
+ * GHIT with cache capabilities added. The templates are stored in memory once
+ * they are readed and reused in succesive parse() calls, avoiding disc reads
+ * overhead.
+ *
+ * @todo See if it's really usefull, since the OS is supposed to be in charge
+ * of disc cache.
+ */
+ class CHIT: public GHIT {
+ // Attributes.
+ protected:
+ /// Cache storage.
+ Hash cache;
+
+ // Methods.
+ protected:
+ /**
+ * Gets cached file content.
+ *
+ * @param filename Name of the file to get the content.
+ * @return File content.
+ */
+ virtual string getFileContent(string);
+
+ public:
+ /**
+ * Constructor.
+ *
+ * @param root Root directory from where to get the templates.
+ * @param postfix Postfix of the template files.
+ * @param group Starting group.
+ */
+ CHIT(string = string("."), string = string(".tpl"), string = string(""));
+
+ /**
+ * Destructor.
+ */
+ virtual ~CHIT(void);
+ };
+
+}
#endif
#include <sstream>
using std::stringstream;
+using namespace bife;
#ifdef DEBUG
#include <iostream>
#include <vector>
#include <string>
-using std::string;
+namespace bife {
-/**
- * Base Container Class.
- *
- * @todo
- */
-class Container: public Widget {
- // Typedefs
- protected:
- typedef std::vector<Widget> Content;
+ using std::string;
- // Attributes.
- protected:
- /// Content.
- Content content;
+ /**
+ * Base Container Class.
+ *
+ * @todo
+ */
+ class Container: public Widget {
+ // Typedefs
+ protected:
+ typedef std::vector<Widget> Content;
- // Methods.
- public:
- /**
- * Constructor.
- */
- Container(void);
+ // Attributes.
+ protected:
+ /// Content.
+ Content content;
- /**
- * Constructor.
- *
- * @param attrs Widget attributes.
- */
- Container(Hash);
+ // Methods.
+ public:
+ /**
+ * Constructor.
+ */
+ Container(void);
- /**
- * Constructor.
- *
- * @param attrs Widget attributes.
- * @param content Content of the widget.
- */
- Container(Hash, Widget&);
+ /**
+ * Constructor.
+ *
+ * @param attrs Widget attributes.
+ */
+ Container(Hash);
- /**
- * Constructor.
- *
- * @param content Content of the widget.
- * @param attrs Widget attributes.
- */
- Container(Widget&, Hash);
+ /**
+ * Constructor.
+ *
+ * @param attrs Widget attributes.
+ * @param content Content of the widget.
+ */
+ Container(Hash, Widget&);
- /**
- * Destructor.
- */
- virtual ~Container(void);
+ /**
+ * Constructor.
+ *
+ * @param content Content of the widget.
+ * @param attrs Widget attributes.
+ */
+ Container(Widget&, Hash);
- /**
- * 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;
+ /**
+ * Destructor.
+ */
+ virtual ~Container(void);
- /**
- * Renders the widget using a HIT template.
- *
- * @param hit HIT template to use to render de widget.
- * @return Rendered widget.
- */
- string renderContent(HIT&);
-};
+ /**
+ * 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;
+
+ /**
+ * Renders the widget using a HIT template.
+ *
+ * @param hit HIT template to use to render de widget.
+ * @return Rendered widget.
+ */
+ string renderContent(HIT&);
+ };
+
+}
#endif
#include <sstream>
using std::stringstream;
+using namespace bife;
#ifdef DEBUG
#include <iostream>
#include <vector>
#include <string>
-using std::string;
+namespace bife {
-/**
- * Base Fallback Widget.
- *
- * @todo
- */
-class Fallback: public Container {
- // Attributes.
- protected:
- /// Root widget.
- Widget* root;
+ using std::string;
- // Methods.
- public:
- /**
- * Constructor.
- *
- * @param name Name of the widget.
- */
- Fallback(string);
+ /**
+ * Base Fallback Widget.
+ *
+ * @todo
+ */
+ class Fallback: public Container {
+ // Attributes.
+ protected:
+ /// Root widget.
+ Widget* root;
- /**
- * Constructor.
- *
- * @param name Name of the widget.
- * @param attrs Widget attributes.
- */
- Fallback(string, Hash);
+ // Methods.
+ public:
+ /**
+ * Constructor.
+ *
+ * @param name Name of the widget.
+ */
+ Fallback(string);
- /**
- * Constructor.
- *
- * @param name Name of the widget.
- * @param attrs Widget attributes.
- * @param content Content of the widget.
- */
- Fallback(string, Hash, Widget&);
+ /**
+ * Constructor.
+ *
+ * @param name Name of the widget.
+ * @param attrs Widget attributes.
+ */
+ Fallback(string, Hash);
- /**
- * Constructor.
- *
- * @param name Name of the widget.
- * @param content Content of the widget.
- */
- Fallback(string, Widget&);
+ /**
+ * Constructor.
+ *
+ * @param name Name of the widget.
+ * @param attrs Widget attributes.
+ * @param content Content of the widget.
+ */
+ Fallback(string, Hash, Widget&);
- /**
- * Constructor.
- *
- * @param name Name of the widget.
- * @param content Content of the widget.
- * @param attrs Widget attributes.
- */
- Fallback(string, Widget&, Hash);
+ /**
+ * Constructor.
+ *
+ * @param name Name of the widget.
+ * @param content Content of the widget.
+ */
+ Fallback(string, Widget&);
- /**
- * Destructor.
- */
- virtual ~Fallback(void);
+ /**
+ * Constructor.
+ *
+ * @param name Name of the widget.
+ * @param content Content of the widget.
+ * @param attrs Widget attributes.
+ */
+ Fallback(string, Widget&, Hash);
- /**
- * 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;
-};
+ /**
+ * 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;
+ };
+
+}
#endif
#include "ghit.h"
+using namespace bife;
+
#ifdef DEBUG
#include <iostream>
using std::cerr;
#include <stack>
#include <string>
-using std::string;
+namespace bife {
-/**
- * Group enabled HIT.
- *
- * HIT template with groups of templates added. You can specify a template
- * group. The group is used as a subdirectory in root template directory, so you
- * can group templates together. The default group ('') templates are stored in
- * the root directory.
- */
-class GHIT: public HIT {
- // Typedefs.
- protected:
- /// Group stack.
- typedef std::stack<string> GroupStack;
+ using std::string;
- // Attributes.
- protected:
- /// Group stack.
- GroupStack group;
+ /**
+ * Group enabled HIT.
+ *
+ * HIT template with groups of templates added. You can specify a template
+ * group. The group is used as a subdirectory in root template directory, so you
+ * can group templates together. The default group ('') templates are stored in
+ * the root directory.
+ */
+ class GHIT: public HIT {
+ // Typedefs.
+ protected:
+ /// Group stack.
+ typedef std::stack<string> GroupStack;
- // Methods.
- protected:
- /**
- * Gets file name based on the blockname and the group.
- *
- * @param blockname Name of the block to get the filename.
- * @return Block's filename.
- */
- virtual string getFileName(string);
+ // Attributes.
+ protected:
+ /// Group stack.
+ GroupStack group;
- public:
- /**
- * Constructor.
- *
- * @param root Root directory from where to get the templates.
- * @param postfix Postfix of the template files.
- * @param group Starting group.
- */
- GHIT(string = string("."), string = string(".tpl"), string = string(""));
+ // Methods.
+ protected:
+ /**
+ * Gets file name based on the blockname and the group.
+ *
+ * @param blockname Name of the block to get the filename.
+ * @return Block's filename.
+ */
+ virtual string getFileName(string);
- /**
- * Destructor.
- */
- virtual ~GHIT(void);
+ public:
+ /**
+ * Constructor.
+ *
+ * @param root Root directory from where to get the templates.
+ * @param postfix Postfix of the template files.
+ * @param group Starting group.
+ */
+ GHIT(string = string("."), string = string(".tpl"), string = string(""));
- /**
- * Starts working with a new group of templates.
- *
- * @param group Group of templates to work with.
- */
- virtual void pushGroup(string);
+ /**
+ * Destructor.
+ */
+ virtual ~GHIT(void);
- /**
- * Stops working with a group of templates.
- *
- * @return Last template's group used.
- */
- virtual string popGroup(void);
+ /**
+ * Starts working with a new group of templates.
+ *
+ * @param group Group of templates to work with.
+ */
+ virtual void pushGroup(string);
- /**
- * Gets the current working group.
- *
- * @return Current template's group.
- */
- virtual string getGroup(void);
-};
+ /**
+ * Stops working with a group of templates.
+ *
+ * @return Last template's group used.
+ */
+ virtual string popGroup(void);
+
+ /**
+ * Gets the current working group.
+ *
+ * @return Current template's group.
+ */
+ virtual string getGroup(void);
+ };
+
+}
#endif
#include <string>
#include <map>
-/// String hash similar to high level languages (like perl, python or php).
-typedef std::map<std::string, std::string> Hash;
+namespace bife {
+ /// String hash similar to high level languages (like perl, python or php).
+ typedef std::map<std::string, std::string> Hash;
+}
#endif
using std::ifstream;
using std::stringbuf;
+using namespace bife;
#ifdef DEBUG
#include <iostream>
#include "hash.h"
#include <string>
-using std::string;
+namespace bife {
-/**
- * Hooks vs IT Template Engine.
- *
- * Hooks vs IT (HIT) is a simple template implementation, based on hooks
- * and IT template systems.
- *
- * @todo Implementar buffers?
- */
-class HIT {
- // Attributes.
- public:
- /// Root directory where to search for templates.
- string root;
- /// Postfix added to the blockname to convert it to a filename.
- string postfix;
- // bool search_path = false
- // TODO - Para subclases
- //Hash buffer;
+ using std::string;
- // Methods.
- protected:
- /**
- * Gets file name based on the blockname.
- *
- * @param blockname Name of the block to get the filename.
- * @return Block's filename.
- */
- virtual string getFileName(string);
+ /**
+ * Hooks vs IT Template Engine.
+ *
+ * Hooks vs IT (HIT) is a simple template implementation, based on hooks
+ * and IT template systems.
+ *
+ * @todo Implementar buffers?
+ */
+ class HIT {
+ // Attributes.
+ public:
+ /// Root directory where to search for templates.
+ string root;
+ /// Postfix added to the blockname to convert it to a filename.
+ string postfix;
+ // bool search_path = false
+ // TODO - Para subclases
+ //Hash buffer;
- /**
- * Gets file content.
- *
- * @param filename Name of the file to get the content.
- * @return File content.
- */
- virtual string getFileContent(string);
+ // Methods.
+ protected:
+ /**
+ * Gets file name based on the blockname.
+ *
+ * @param blockname Name of the block to get the filename.
+ * @return Block's filename.
+ */
+ virtual string getFileName(string);
- public:
- /**
- * Constructor.
- *
- * @param root Root directory from where to get the templates.
- * @param postfix Postfix of the template files.
- */
- HIT(string = string("."), string = string(".tpl"));
+ /**
+ * Gets file content.
+ *
+ * @param filename Name of the file to get the content.
+ * @return File content.
+ */
+ virtual string getFileContent(string);
- /**
- * Destructor.
- */
- virtual ~HIT(void);
+ public:
+ /**
+ * Constructor.
+ *
+ * @param root Root directory from where to get the templates.
+ * @param postfix Postfix of the template files.
+ */
+ HIT(string = string("."), string = string(".tpl"));
- /**
- * Parses a block replacing keys with values in the hash.
- *
- * @param blockname Name of the block to parse.
- * @param vars Hash containing the variable names and their values.
- * @return Parsed block with variables replaced.
- */
- string parse(string, Hash&);
-};
+ /**
+ * Destructor.
+ */
+ virtual ~HIT(void);
+
+ /**
+ * Parses a block replacing keys with values in the hash.
+ *
+ * @param blockname Name of the block to parse.
+ * @param vars Hash containing the variable names and their values.
+ * @return Parsed block with variables replaced.
+ */
+ string parse(string, Hash&);
+ };
+
+}
#endif
#include "chit.h"
using namespace std;
+using namespace bife;
int main(void) {
const string indent = " ";
#include <sstream>
using std::stringstream;
+using namespace bife;
#ifdef DEBUG
#include <iostream>
#include "hash.h"
#include <string>
-using std::string;
-
-/**
- * Base Widget Class.
- *
- * @todo
- */
-class Widget {
- // Attributes.
- public:
- /// Widget attributes.
- Hash attrs;
-
- // Methods.
- public:
- /**
- * Constructor.
- */
- Widget(void);
-
- /**
- * Constructor.
- *
- * @param attrs Widget attributes.
- */
- Widget(Hash);
-
- /**
- * Destructor.
- */
- virtual ~Widget(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;
-
- /**
- * Renders the widget using a HIT template.
- *
- * @param hit HIT template to use to render de widget.
- * @return Rendered widget.
- */
- virtual operator string(void) const;
-};
+namespace bife {
+
+ using std::string;
+
+ /**
+ * Base Widget Class.
+ *
+ * @todo
+ */
+ class Widget {
+ // Attributes.
+ public:
+ /// Widget attributes.
+ Hash attrs;
+
+ // Methods.
+ public:
+ /**
+ * Constructor.
+ */
+ Widget(void);
+
+ /**
+ * Constructor.
+ *
+ * @param attrs Widget attributes.
+ */
+ Widget(Hash);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Widget(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;
+
+ /**
+ * Renders the widget using a HIT template.
+ *
+ * @param hit HIT template to use to render de widget.
+ * @return Rendered widget.
+ */
+ virtual operator string(void) const;
+ };
+
+}
#endif