From 5bfc157171563809b78a00ad74b0e7a9690a17f0 Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 25 Nov 2011 23:51:38 -0800 Subject: Fixing a few bugs and warnings. --- includes/BString.h | 4 ++-- includes/SimpleMustache.h | 4 +++- src/SimpleMustache.cc | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/BString.h b/includes/BString.h index 568a460..d8487d0 100644 --- a/includes/BString.h +++ b/includes/BString.h @@ -95,8 +95,8 @@ class String : private std::string { bool operator>=(const String & v) const { return compare(v) >= 0; } bool operator>=(const char * v) const { return compare(v) >= 0; } - const char & operator[](size_t i) const { if (i < 0) i = strlen() + i; return at(i); } - char & operator[](size_t i) { if (i < 0) i = strlen() + i; return at(i); } + const char & operator[](ssize_t i) const { if (i < 0) i = strlen() + i; return at(i); } + char & operator[](ssize_t i) { if (i < 0) i = strlen() + i; return at(i); } }; }; diff --git a/includes/SimpleMustache.h b/includes/SimpleMustache.h index d98b5eb..5b9dc3d 100644 --- a/includes/SimpleMustache.h +++ b/includes/SimpleMustache.h @@ -32,11 +32,13 @@ class SimpleMustache { empty(); m_type = STRING; m_str = str; + return *this; } Context & operator=(bool b) { empty(); m_type = BOOLSEC; m_bool = b; + return *this; } private: enum ContextType { @@ -48,7 +50,7 @@ class SimpleMustache { } m_type; Context(ContextType type) : m_type(type), m_root(false) { } Context(Context & c) { Assert(false); } - Context & operator=(Context & c) { Assert(false); } + Context & operator=(Context & c) { Assert(false); return *this; } String m_str; bool m_bool; typedef std::map SubContext; diff --git a/src/SimpleMustache.cc b/src/SimpleMustache.cc index c7cbee4..e87d08d 100644 --- a/src/SimpleMustache.cc +++ b/src/SimpleMustache.cc @@ -353,7 +353,7 @@ Balau::SimpleMustache::Fragments::iterator Balau::SimpleMustache::render_r(IOtype == Fragment::STRING); + if(fr->type == Fragment::STRING) h->write(fr->str); } return end; @@ -408,6 +408,9 @@ Balau::SimpleMustache::Fragments::iterator Balau::SimpleMustache::render_r(IOstr, ++cur, sCtx->find(fr->str) != sCtx->end(), -1); break; + default: + Assert(false); + break; } } } -- cgit v1.2.3