From d440c3f50a918a932293ad98bcec96eaa4683222 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 4 Dec 2011 01:19:09 -0800 Subject: Reworked some things in the architecture, mainly exceptions and asserts. -) Removed Assert() -) Added AAssert(), IAssert(), RAssert(), TAssert() and Failure() -) Reworked all asserts in the code, and added meaningful messages to them. -) Changed the way the startup code is generated; BALAU_STARTUP is no longer necessary. --- includes/SimpleMustache.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'includes/SimpleMustache.h') diff --git a/includes/SimpleMustache.h b/includes/SimpleMustache.h index b16f683..2bb0cb1 100644 --- a/includes/SimpleMustache.h +++ b/includes/SimpleMustache.h @@ -57,8 +57,8 @@ class SimpleMustache { LAMBDA, } m_type; Context(ContextType type) : m_type(type), m_root(false) { } - Context(Context & c) { Assert(false); } - Context & operator=(Context & c) { Assert(false); return *this; } + Context(Context & c) { Failure("You can't copy a Context; use references"); } + Context & operator=(Context & c) { Failure("You can't assign a Context; use references"); return *this; } String m_str; bool m_bool; typedef std::map SubContext; @@ -82,9 +82,9 @@ class SimpleMustache { } void setTemplate(const char * str, ssize_t s = -1) { setTemplate((const uint8_t *) str, s); } void setTemplate(const String & str) { setTemplate((const uint8_t *) str.to_charp(), str.strlen()); } - void render(IO h, Context * ctx) { Assert(ctx); render_r(h, ctx, "", m_fragments.begin(), false, -1); } + void render(IO h, Context * ctx) { AAssert(ctx, "Please pass on a context to render"); render_r(h, ctx, "", m_fragments.begin(), false, -1); } void empty() { while (!m_fragments.empty()) { delete m_fragments.front(); m_fragments.pop_front(); } } - void checkTemplate() { Fragments::iterator end = checkTemplate_r(m_fragments.begin()); Assert(end == m_fragments.end()); } + void checkTemplate() { Fragments::iterator end = checkTemplate_r(m_fragments.begin()); AAssert(end == m_fragments.end(), "The template wasn't fully checked; possibly mismatched sections"); } ~SimpleMustache() { empty(); } private: struct Fragment { -- cgit v1.2.3