@ -41,6 +41,7 @@ namespace Winix
HtmlTextStream : : HtmlTextStream ( )
{
escape = true ;
}
@ -226,6 +227,21 @@ HtmlTextStream & HtmlTextStream::operator<<(RawText<void*> raw)
}
HtmlTextStream & HtmlTextStream : : operator < < ( RawText < PT : : Space > raw )
{
TextStream < std : : wstring > : : operator < < ( raw . par ) ;
return * this ;
}
HtmlTextStream & HtmlTextStream : : operator < < ( RawText < PT : : Date > raw )
{
TextStream < std : : wstring > : : operator < < ( raw . par ) ;
return * this ;
}
HtmlTextStream & HtmlTextStream : : Write ( const char * buf , size_t len )
@ -262,6 +278,11 @@ HtmlTextStream & HtmlTextStream::write(const wchar_t * buf, size_t len)
*/
void HtmlTextStream : : Escape ( bool escape_characters )
{
escape = escape_characters ;
}
HtmlTextStream & HtmlTextStream : : ETextPutChar ( char c )
@ -293,7 +314,7 @@ HtmlTextStream & HtmlTextStream::ETextPutChar(wchar_t c)
if ( c = = 13 )
buffer + = L " " ;
else
if ( c ! = 0 )
if ( c ! = 0 ) // !! CHECK ME may it should be changed to something like '�';
buffer + = c ;
return * this ;
@ -380,19 +401,34 @@ HtmlTextStream & HtmlTextStream::EPutText(const std::wstring & str)
HtmlTextStream & HtmlTextStream : : operator < < ( const char * str )
{
return EPutText ( str ) ;
if ( escape )
EPutText ( str ) ;
else
PutText ( str ) ;
return * this ;
}
HtmlTextStream & HtmlTextStream : : operator < < ( const std : : string * str )
{
return EPutText ( str ) ;
if ( escape )
EPutText ( str ) ;
else
PutText ( str ) ;
return * this ;
}
HtmlTextStream & HtmlTextStream : : operator < < ( const std : : string & str )
{
return EPutText ( str ) ;
if ( escape )
EPutText ( str ) ;
else
PutText ( str ) ;
return * this ;
}
@ -400,19 +436,34 @@ HtmlTextStream & HtmlTextStream::operator<<(const std::string & str)
HtmlTextStream & HtmlTextStream : : operator < < ( const wchar_t * str )
{
return EPutText ( str ) ;
if ( escape )
EPutText ( str ) ;
else
PutText ( str ) ;
return * this ;
}
HtmlTextStream & HtmlTextStream : : operator < < ( const std : : wstring * str )
{
return EPutText ( str ) ;
if ( escape )
EPutText ( str ) ;
else
PutText ( str ) ;
return * this ;
}
HtmlTextStream & HtmlTextStream : : operator < < ( const std : : wstring & str )
{
return EPutText ( str ) ;
if ( escape )
EPutText ( str ) ;
else
PutText ( str ) ;
return * this ;
}
@ -420,7 +471,10 @@ HtmlTextStream & HtmlTextStream::operator<<(const std::wstring & str)
HtmlTextStream & HtmlTextStream : : operator < < ( char v )
{
ETextPutChar ( v ) ;
if ( escape )
ETextPutChar ( v ) ;
else
PutChar ( v ) ;
return * this ;
}
@ -428,7 +482,10 @@ return *this;
HtmlTextStream & HtmlTextStream : : operator < < ( wchar_t v )
{
ETextPutChar ( v ) ;
if ( escape )
ETextPutChar ( v ) ;
else
PutChar ( v ) ;
return * this ;
}
@ -436,6 +493,11 @@ return *this;
HtmlTextStream & HtmlTextStream : : operator < < ( int v )
{
/*
* int , long and others don ' t have to be escaped
* ( they consist of digits only : ' 0 ' - ' 9 ' and other characters which
* don ' t have to be escaped )
*/
TextStream < std : : wstring > : : operator < < ( v ) ;
return * this ;
@ -485,12 +547,23 @@ return *this;
HtmlTextStream & HtmlTextStream : : operator < < ( const PT : : Space & space )
{
tmp_stream . Clear ( ) ;
// !! IMPROVE ME
// we can calculate how many memory is needed beforehand
space . Serialize ( tmp_stream , true , false ) ;
operator < < ( tmp_stream . Str ( ) ) ;
tmp_stream . Clear ( ) ;
if ( escape )
{
space . Serialize ( * this , true , false ) ;
/*
tmp_stream . Clear ( ) ;
// !! IMPROVE ME
// we can calculate how many memory is needed beforehand
space . Serialize ( tmp_stream , true , false ) ;
operator < < ( tmp_stream . Str ( ) ) ;
tmp_stream . Clear ( ) ;
*/
}
else
{
TextStream < std : : wstring > : : operator < < ( space ) ;
}
return * this ;
}
@ -498,12 +571,23 @@ return *this;
HtmlTextStream & HtmlTextStream : : operator < < ( const PT : : Date & date )
{
tmp_stream . Clear ( ) ;
// !! IMPROVE ME
// we can calculate how many memory is needed beforehand
date . Serialize ( tmp_stream ) ;
operator < < ( tmp_stream . Str ( ) ) ;
tmp_stream . Clear ( ) ;
if ( escape )
{
date . Serialize ( * this ) ;
/*
tmp_stream . Clear ( ) ;
// !! IMPROVE ME
// we can calculate how many memory is needed beforehand
date . Serialize ( tmp_stream ) ;
operator < < ( tmp_stream . Str ( ) ) ;
tmp_stream . Clear ( ) ;
*/
}
else
{
TextStream < std : : wstring > : : operator < < ( date ) ;
}
return * this ;
}