-#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
#include "hit.h"
#include "ghit.h"
#include "chit.h"
+#include "string.h"
using namespace std;
using namespace bife;
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;
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;
}
--- /dev/null
+// 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());
+}
--- /dev/null
+// 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