]> git.llucax.com Git - software/bife/bife++.git/commitdiff
Added namespace bife.
authorLeandro Lucarella <llucax@gmail.com>
Wed, 13 Aug 2003 22:46:34 +0000 (22:46 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Wed, 13 Aug 2003 22:46:34 +0000 (22:46 +0000)
14 files changed:
chit.cpp
chit.h
container.cpp
container.h
fallback.cpp
fallback.h
ghit.cpp
ghit.h
hash.h
hit.cpp
hit.h
main.cpp
widget.cpp
widget.h

index 4b09a9df7b6a339d9f5e342c79571b0b75dfd75a..8ef60eb73c87d3cfadac566f0bba33afba95b273 100644 (file)
--- a/chit.cpp
+++ b/chit.cpp
@@ -2,6 +2,8 @@
 
 #include "chit.h"
 
+using namespace bife;
+
 #ifdef DEBUG
 #include <iostream>
 using std::cerr;
diff --git a/chit.h b/chit.h
index 22776f5cb5227c71d689e43a8587e4bcc4e106ab..434e64e6942d9ae419fdba507d2da1fbd45f4b4c 100644 (file)
--- a/chit.h
+++ b/chit.h
@@ -7,48 +7,52 @@
 #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
index 8cfa82b7ac8f09f8d13a587db7a2fed4b496715d..5375cb10e7792a8751c74de02cd6408c0847293f 100644 (file)
@@ -4,6 +4,7 @@
 #include <sstream>
 
 using std::stringstream;
+using namespace bife;
 
 #ifdef DEBUG
 #include <iostream>
index 41ac0a6ef85363ac2636310c0465e3543ad11072..9029c8ade9f24b674065de31e0d8c7f852a52663 100644 (file)
@@ -9,73 +9,77 @@
 #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
index e8e1bbc7ea1e4dbc374cdc2ccdaf468c9a288eb7..e8ed815398d2dd2314f1c50df251c3548480d66b 100644 (file)
@@ -4,6 +4,7 @@
 #include <sstream>
 
 using std::stringstream;
+using namespace bife;
 
 #ifdef DEBUG
 #include <iostream>
index a754ac1d6932401bd0e844c8347f6c96a6829376..58f5cd34e5704a24494a30695fac066aba0cfb38 100644 (file)
 #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
index db0583321702c96a1a7537b8237363a9e550a937..5243932b5d74d70f8872db975eb1009617fb82b0 100644 (file)
--- a/ghit.cpp
+++ b/ghit.cpp
@@ -2,6 +2,8 @@
 
 #include "ghit.h"
 
+using namespace bife;
+
 #ifdef DEBUG
 #include <iostream>
 using std::cerr;
diff --git a/ghit.h b/ghit.h
index 32900a6bc96864a7c3d7bc4bcb0fa6afc69cce4b..e362728488ea8e644c1e7aa8a87a213ecd19a249 100644 (file)
--- a/ghit.h
+++ b/ghit.h
@@ -7,72 +7,76 @@
 #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
diff --git a/hash.h b/hash.h
index 08f7adbb30bb0741dca5fc4966d704af8a5ec4be..d825bdc9f833a66f72b7b33f9d2001373d645ae7 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -6,7 +6,9 @@
 #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
diff --git a/hit.cpp b/hit.cpp
index a9bfd666d62bc571459883b78e5778e5c5f0bea8..ad99316f60c89d3f2b498f7bb85ef86f45526a26 100644 (file)
--- a/hit.cpp
+++ b/hit.cpp
@@ -6,6 +6,7 @@
 
 using std::ifstream;
 using std::stringbuf;
+using namespace bife;
 
 #ifdef DEBUG
 #include <iostream>
diff --git a/hit.h b/hit.h
index 5086127872df297d1d9d22485eca6743348c1d05..9162460404b4090e8de9e3659d071ccbcc254ad7 100644 (file)
--- a/hit.h
+++ b/hit.h
@@ -6,67 +6,71 @@
 #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
index 92fbb6a5e20fb1d7a170df118222dad498c23f4d..b76d29604946db0e659d90dff04ab6408ef8b929 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -8,6 +8,7 @@
 #include "chit.h"
 
 using namespace std;
+using namespace bife;
 
 int main(void) {
     const string indent = "    ";
index 67853b5430019bd824515c7a0b80d94861f7bc4b..46e3d2b66ff3b9f197971ee2ea11d447be130011 100644 (file)
@@ -4,6 +4,7 @@
 #include <sstream>
 
 using std::stringstream;
+using namespace bife;
 
 #ifdef DEBUG
 #include <iostream>
index 95bc28dda096cfd44f28a97a8002b78015ae56ba..a054e20050415f64459d3ca6f3bdee0ca2c15ac7 100644 (file)
--- a/widget.h
+++ b/widget.h
@@ -7,53 +7,57 @@
 #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