From 14ae19143ff6f0161d5643d8d6b6995fad148b36 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Tue, 11 Sep 2012 21:41:10 +0000 Subject: [PATCH] added: new ezc filter: fil_new_line_to_br added: PutChar() methods to HtmlTextFilter and TexTextFilter git-svn-id: svn://ttmath.org/publicrep/winix/trunk@885 e52654a7-88a9-db11-a3e9-0013d4bc506e --- templates/filters.cpp | 19 ++++++++++++++++++- templates/htmltextstream.cpp | 16 ++++++++++++++++ templates/htmltextstream.h | 2 ++ templates/templates.cpp | 4 +++- templates/templates.h | 1 + templates/textextstream.cpp | 16 ++++++++++++++++ templates/textextstream.h | 16 ++++++---------- 7 files changed, 62 insertions(+), 12 deletions(-) diff --git a/templates/filters.cpp b/templates/filters.cpp index 1c7c15a..f15d583 100755 --- a/templates/filters.cpp +++ b/templates/filters.cpp @@ -2,7 +2,7 @@ * This file is a part of Winix * and is not publicly distributed * - * Copyright (c) 2008-2011, Tomasz Sowa + * Copyright (c) 2008-2012, Tomasz Sowa * All rights reserved. * */ @@ -136,4 +136,21 @@ void fil_csv_escape(Info & i) +void fil_new_line_to_br(Info & i) +{ + const std::wstring & str = i.in.Str(); + + for(size_t a=0 ; a\n"); + else + i.out << R(str[a]); + } +} + + + + + } // namespace diff --git a/templates/htmltextstream.cpp b/templates/htmltextstream.cpp index e7cb0ca..7a69029 100755 --- a/templates/htmltextstream.cpp +++ b/templates/htmltextstream.cpp @@ -23,6 +23,22 @@ HtmlTextStream::HtmlTextStream() without escaping */ +HtmlTextStream & HtmlTextStream::PutChar(char c) +{ + TextStream::operator<<(c); + +return *this; +} + + +HtmlTextStream & HtmlTextStream::PutChar(wchar_t c) +{ + TextStream::operator<<(c); + +return *this; +} + + HtmlTextStream & HtmlTextStream::PutText(const char * str) { diff --git a/templates/htmltextstream.h b/templates/htmltextstream.h index 6068dfb..97bb2bf 100755 --- a/templates/htmltextstream.h +++ b/templates/htmltextstream.h @@ -68,6 +68,8 @@ public: /* without escaping */ + HtmlTextStream & PutChar(char); + HtmlTextStream & PutChar(wchar_t); HtmlTextStream & PutText(const char *); HtmlTextStream & PutText(const char *, size_t len); diff --git a/templates/templates.cpp b/templates/templates.cpp index f511938..7bddbec 100755 --- a/templates/templates.cpp +++ b/templates/templates.cpp @@ -238,7 +238,7 @@ void Templates::CreateFunctions() ezc_functions.Insert("env_user_tab_id", env_user_tab_id); ezc_functions.Insert("env_user_tab_name", env_user_tab_name); ezc_functions.Insert("env_user_tab_is_current", env_user_tab_is_current); - ezc_functions.Insert("fil_csv_escape", fil_csv_escape); + /* filters @@ -249,6 +249,8 @@ void Templates::CreateFunctions() ezc_functions.Insert("fil_tosmall", fil_tosmall); ezc_functions.Insert("fil_firstup", fil_firstup); ezc_functions.Insert("fil_first_wordup", fil_first_wordup); + ezc_functions.Insert("fil_csv_escape", fil_csv_escape); + ezc_functions.Insert("fil_new_line_to_br", fil_new_line_to_br); /* diff --git a/templates/templates.h b/templates/templates.h index 4225282..6a20009 100755 --- a/templates/templates.h +++ b/templates/templates.h @@ -180,6 +180,7 @@ namespace TemplatesFunctions void fil_firstup(Info & i); void fil_first_wordup(Info & i); void fil_csv_escape(Info & i); + void fil_new_line_to_br(Info & i); /* diff --git a/templates/textextstream.cpp b/templates/textextstream.cpp index b901ab2..5d15dc3 100755 --- a/templates/textextstream.cpp +++ b/templates/textextstream.cpp @@ -24,6 +24,22 @@ TexTextStream::TexTextStream() */ +TexTextStream & TexTextStream::PutChar(char c) +{ + TextStream::operator<<(c); + +return *this; +} + + +TexTextStream & TexTextStream::PutChar(wchar_t c) +{ + TextStream::operator<<(c); + +return *this; +} + + TexTextStream & TexTextStream::PutText(const char * str) { TextStream::operator<<(str); diff --git a/templates/textextstream.h b/templates/textextstream.h index d073a4c..67c3bc6 100755 --- a/templates/textextstream.h +++ b/templates/textextstream.h @@ -16,7 +16,7 @@ /* - TexTextStream is used as a buffer for creating a html page + TexTextStream is used as a buffer for creating a TeX input By default all operators<< escape its string arguments. If you don't want to escape an argument you should use a helper function R() (raw argument) note: you have to define the function yourself, we do not provide it @@ -33,16 +33,10 @@ now you can use TexTextStream in an easy way: TexTextStream page; - std::string key = "some string"; - page << key << R("

html goes here

"); + std::string key = "some text with $# ^{} tex \\ special characters"; + page << key << R("\\def\\myfun{...}"); - // !! UPDATE INFO this is TEX text - only html tags "" and "" will be correctly escaped - - currently following characters are escaped: - < -> < - > -> > - & ->   + everything in 'key' is property escaped for using with TeX */ class TexTextStream : public TextStream { @@ -70,6 +64,8 @@ public: /* without escaping */ + TexTextStream & PutChar(char); + TexTextStream & PutChar(wchar_t); TexTextStream & PutText(const char *); TexTextStream & PutText(const char *, size_t len);