]> git.llucax.com Git - software/bife/bife++.git/commitdiff
Added a basic string widget.
authorLeandro Lucarella <llucax@gmail.com>
Fri, 15 Aug 2003 05:40:01 +0000 (05:40 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Fri, 15 Aug 2003 05:40:01 +0000 (05:40 +0000)
Makefile
main.cpp
string.cpp [new file with mode: 0644]
string.h [new file with mode: 0644]

index c5a5901b48d918a480bbbe135e301a784f0bcc85..402293be63ade1d57841ece34b332676154eb331 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
 
-#CPPFLAGS=-g3 -Wall -DDEBUG
-CPPFLAGS=-O3 -Wall
+CPPFLAGS=-g3 -Wall -DDEBUG
+#CPPFLAGS=-O3 -Wall
 
-TAGETS=hit.o ghit.o chit.o widget.o container.o fallback.o
+TAGETS=hit.o ghit.o chit.o widget.o container.o fallback.o string.o
 
 all: main
 
index b76d29604946db0e659d90dff04ab6408ef8b929..80de24d3f74217e8ef6ddb64c6d5a30d55e6ecae 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -6,6 +6,7 @@
 #include "hit.h"
 #include "ghit.h"
 #include "chit.h"
+#include "string.h"
 
 using namespace std;
 using namespace bife;
@@ -38,7 +39,7 @@ int main(void) {
 
     cout << "CHIT example:" << endl;
     cout << "=============" << endl;
-    CHIT c("././././././", ".tpl.html");
+    CHIT chit("././././././", ".tpl.html");
     const int n = 65;
     for (int i = n; i < (n+10); i++) {
         stringstream ssi, ssc;
@@ -46,6 +47,18 @@ int main(void) {
         ssc << char(i);
         vars["NOMBRE"] = "Chit gay " + ssc.str();
         vars["EDAD"]   = ssi.str();
-        cout << indent << c.parse("test", vars) << endl;
+        cout << indent << chit.parse("test", vars) << endl;
     }
+
+    cout << "bife::String example:" << endl;
+    cout << "=====================" << endl;
+    string s = "std::string";
+    String a("Un string");
+    String b = "Otro string";
+    //String c = s;
+    cout << "s: '" << s << "' - "
+        << "a: '" << a << "' - "
+        << "b: '" << b << endl;
+    cout << "a.render(): '" << a.render(chit) << "' - "
+        << "b.render(): '" << b.render(chit) << endl;
 }
diff --git a/string.cpp b/string.cpp
new file mode 100644 (file)
index 0000000..7c76f56
--- /dev/null
@@ -0,0 +1,35 @@
+// vim: set expandtab tabstop=4 shiftwidth=4:
+
+#include "string.h"
+#include <sstream>
+
+using std::stringstream;
+using namespace bife;
+
+#ifdef DEBUG
+#include <iostream>
+using std::cerr;
+using std::endl;
+#endif
+/*
+String::String(void) {
+#ifdef DEBUG
+    cerr << "In String::String()." << endl;
+#endif
+}*/
+
+String::String(const char* str): string(str) {
+#ifdef DEBUG
+    cerr << "In String::String('" << str << "')." << endl;
+#endif
+}
+
+String::~String(void) {
+#ifdef DEBUG
+    cerr << "In String destructor." << endl;
+#endif
+}
+
+string String::render(HIT& tpl) {
+    return string(this->c_str());
+}
diff --git a/string.h b/string.h
new file mode 100644 (file)
index 0000000..935369c
--- /dev/null
+++ b/string.h
@@ -0,0 +1,51 @@
+// vim: set expandtab tabstop=4 shiftwidth=4:
+
+#ifndef BIFE_STRING_H
+#define BIFE_STRING_H
+
+#include "hit.h"
+#include "hash.h"
+#include "widget.h"
+#include <string>
+
+namespace bife {
+
+    using std::string;
+
+    /**
+     * Base String Class.
+     *
+     * @todo 
+     */
+    class String: public Widget, public string {
+        // Methods.
+        public:
+            /**
+             * Constructor.
+             */
+            //String(void);
+
+            /**
+             * Constructor.
+             *
+             * @param attrs String attributes.
+             */
+            String(const char*);
+
+            /**
+             * Destructor.
+             */
+            virtual ~String(void);
+
+            /**
+             * Renders the String using a HIT template.
+             *
+             * @param  hit HIT template to use to render de String.
+             * @return Rendered String.
+             */
+            virtual string render(HIT&);
+    };
+
+}
+
+#endif