HtmlTextStream has now pt::Stream as a based class and uses pt::WTextStream as a buffer
This commit is contained in:
@@ -45,67 +45,134 @@ HtmlTextStream::HtmlTextStream()
|
||||
}
|
||||
|
||||
|
||||
void HtmlTextStream::Clear()
|
||||
bool HtmlTextStream::is_char_stream() const
|
||||
{
|
||||
escape = true;
|
||||
TextStream<std::wstring>::Clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool HtmlTextStream::is_wchar_stream() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HtmlTextStream::clear()
|
||||
{
|
||||
Clear();
|
||||
escape = true;
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
|
||||
void HtmlTextStream::to_str(std::wstring & str)
|
||||
bool HtmlTextStream::empty() const
|
||||
{
|
||||
str = TextStream<std::wstring>::Str();
|
||||
return buffer.empty();
|
||||
}
|
||||
|
||||
|
||||
size_t HtmlTextStream::size() const
|
||||
{
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
|
||||
void HtmlTextStream::reserve(size_t len)
|
||||
{
|
||||
buffer.reserve(len);
|
||||
}
|
||||
|
||||
|
||||
size_t HtmlTextStream::capacity() const
|
||||
{
|
||||
return buffer.capacity();
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream::iterator HtmlTextStream::begin()
|
||||
{
|
||||
return buffer.begin();
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream::iterator HtmlTextStream::end()
|
||||
{
|
||||
return buffer.end();
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream::const_iterator HtmlTextStream::begin() const
|
||||
{
|
||||
return buffer.begin();
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream::const_iterator HtmlTextStream::end() const
|
||||
{
|
||||
return buffer.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void HtmlTextStream::to_str(std::string & str, bool clear_string) const
|
||||
{
|
||||
buffer.to_str(str, clear_string);
|
||||
}
|
||||
|
||||
|
||||
void HtmlTextStream::to_str(std::wstring & str, bool clear_string) const
|
||||
{
|
||||
buffer.to_str(str, clear_string);
|
||||
}
|
||||
|
||||
|
||||
std::string HtmlTextStream::to_str() const
|
||||
{
|
||||
return buffer.to_str();
|
||||
}
|
||||
|
||||
|
||||
std::wstring HtmlTextStream::to_wstr() const
|
||||
{
|
||||
return buffer.to_wstr();
|
||||
}
|
||||
|
||||
|
||||
char HtmlTextStream::get_char(size_t index) const
|
||||
{
|
||||
return buffer.get_char(index);
|
||||
}
|
||||
|
||||
wchar_t HtmlTextStream::get_wchar(size_t index) const
|
||||
{
|
||||
return buffer.get_wchar(index);
|
||||
}
|
||||
|
||||
|
||||
const pt::WTextStream & HtmlTextStream::get_buffer() const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
pt::WTextStream & HtmlTextStream::get_buffer()
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
without escaping
|
||||
*/
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutChar(char c)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(c);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutChar(wchar_t c)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(c);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const char * str)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const char * str, size_t len)
|
||||
{
|
||||
TextStream<std::wstring>::Write(str, len);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const std::string * str)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(str);
|
||||
buffer.operator<<(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -113,7 +180,7 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const std::string & str)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(str);
|
||||
buffer.operator<<(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -122,15 +189,7 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const wchar_t * str)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const std::wstring * str)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(str);
|
||||
buffer.operator<<(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -138,12 +197,64 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const std::wstring & str)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(str);
|
||||
buffer.operator<<(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const char * str, size_t len)
|
||||
{
|
||||
buffer.write(str, len);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutText(const wchar_t * str, size_t len)
|
||||
{
|
||||
buffer.write(str, len);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutChar(char c)
|
||||
{
|
||||
buffer.operator<<(c);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutChar(unsigned char c)
|
||||
{
|
||||
buffer.operator<<(c);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutChar(wchar_t c)
|
||||
{
|
||||
buffer.operator<<(c);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::PutChar(bool val)
|
||||
{
|
||||
buffer.operator<<(val);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -155,33 +266,18 @@ HtmlTextStream & HtmlTextStream::operator<<(const RawText<const char*> & raw)
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const RawText<const wchar_t*> & raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<const std::string*> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<const std::wstring*> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<std::string> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const RawText<const wchar_t*> & raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<std::wstring> raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
@@ -189,107 +285,158 @@ HtmlTextStream & HtmlTextStream::operator<<(RawText<std::wstring> raw)
|
||||
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<char> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned char> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<wchar_t> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<bool> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<short> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<int> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<long> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<long long> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned short> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned int> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned long> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned long long> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<float> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<double> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<long double> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<void*> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Stream> raw)
|
||||
{
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Space> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Date> raw)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(raw.par);
|
||||
buffer.operator<<(raw.par);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const HtmlTextStream & stream)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(stream.Str());
|
||||
buffer.operator<<(stream.buffer);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::Write(const char * buf, size_t len)
|
||||
{
|
||||
TextStream<std::wstring>::Write(buf, len);
|
||||
return *this;
|
||||
}
|
||||
|
||||
HtmlTextStream & HtmlTextStream::Write(const wchar_t * buf, size_t len)
|
||||
{
|
||||
TextStream<std::wstring>::Write(buf, len);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::write(const char * buf, size_t len)
|
||||
{
|
||||
TextStream<std::wstring>::write(buf, len);
|
||||
buffer.write(buf, len);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::write(const wchar_t * buf, size_t len)
|
||||
{
|
||||
TextStream<std::wstring>::write(buf, len);
|
||||
buffer.write(buf, len);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -300,94 +447,29 @@ HtmlTextStream & HtmlTextStream::write(const wchar_t * buf, size_t len)
|
||||
/*
|
||||
with escaping
|
||||
*/
|
||||
|
||||
|
||||
void HtmlTextStream::Escape(bool escape_characters)
|
||||
{
|
||||
escape = escape_characters;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::ETextPutChar(char c)
|
||||
{
|
||||
return ETextPutChar(static_cast<wchar_t>(c));
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::ETextPutChar(wchar_t c)
|
||||
{
|
||||
if( c == '<' )
|
||||
buffer += L"<";
|
||||
else
|
||||
if( c == '>' )
|
||||
buffer += L">";
|
||||
else
|
||||
if( c == '&' )
|
||||
buffer += L"&";
|
||||
else
|
||||
if( c == '\"' )
|
||||
buffer += L""";
|
||||
else
|
||||
if( c == '\'' )
|
||||
buffer += L"'"; // (it is "'" but IE8 has a problem with ')
|
||||
else
|
||||
if( c == 10 )
|
||||
buffer += L" ";
|
||||
else
|
||||
if( c == 13 )
|
||||
buffer += L" ";
|
||||
else
|
||||
if( c != 0 ) // !! CHECK ME may it should be changed to something like '�';
|
||||
buffer += c;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const char * str)
|
||||
{
|
||||
pt::utf8_to_wide(str, tmp_string);
|
||||
int res;
|
||||
bool correct;
|
||||
size_t utf8_len;
|
||||
|
||||
for(size_t i=0 ; i<tmp_string.size() ; ++i)
|
||||
ETextPutChar(tmp_string[i]);
|
||||
// CHECKME
|
||||
while( (utf8_len = pt::utf8_to_int(str, res, correct)) > 0 )
|
||||
{
|
||||
if( !correct )
|
||||
res = 0xFFFD; // U+FFFD "replacement character"
|
||||
|
||||
tmp_string.clear();
|
||||
ETextPutChar(static_cast<wchar_t>(res));
|
||||
str += utf8_len;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const char * str, size_t len)
|
||||
{
|
||||
pt::utf8_to_wide(str, len, tmp_string);
|
||||
|
||||
for(size_t i=0 ; i<tmp_string.size() ; ++i)
|
||||
ETextPutChar(tmp_string[i]);
|
||||
|
||||
tmp_string.clear();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const std::string * str)
|
||||
{
|
||||
return EPutText(*str);
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const std::string & str)
|
||||
{
|
||||
pt::utf8_to_wide(str, tmp_string);
|
||||
|
||||
for(size_t i=0 ; i<tmp_string.size() ; ++i)
|
||||
ETextPutChar(tmp_string[i]);
|
||||
|
||||
tmp_string.clear();
|
||||
|
||||
return *this;
|
||||
return EPutText(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -400,6 +482,34 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const std::wstring & str)
|
||||
{
|
||||
return EPutText(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const char * str, size_t len)
|
||||
{
|
||||
int res;
|
||||
bool correct;
|
||||
size_t utf8_len;
|
||||
|
||||
// CHECKME
|
||||
while( (utf8_len = pt::utf8_to_int(str, len, res, correct)) > 0 )
|
||||
{
|
||||
if( !correct )
|
||||
res = 0xFFFD; // U+FFFD "replacement character"
|
||||
|
||||
ETextPutChar(static_cast<wchar_t>(res));
|
||||
|
||||
len -= utf8_len;
|
||||
str += utf8_len;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const wchar_t * str, size_t len)
|
||||
{
|
||||
for(size_t i=0 ; i<len ; ++i)
|
||||
@@ -409,32 +519,61 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const std::wstring * str)
|
||||
|
||||
HtmlTextStream & HtmlTextStream::ETextPutChar(char c)
|
||||
{
|
||||
return EPutText(str->c_str(), str->size());
|
||||
return ETextPutChar(static_cast<unsigned char>(c));
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::EPutText(const std::wstring & str)
|
||||
HtmlTextStream & HtmlTextStream::ETextPutChar(unsigned char c)
|
||||
{
|
||||
return EPutText(str.c_str(), str.size());
|
||||
return ETextPutChar(static_cast<wchar_t>(c));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const char * str)
|
||||
HtmlTextStream & HtmlTextStream::ETextPutChar(wchar_t c)
|
||||
{
|
||||
if( escape )
|
||||
EPutText(str);
|
||||
if( c == '<' )
|
||||
buffer << L"<";
|
||||
else
|
||||
PutText(str);
|
||||
if( c == '>' )
|
||||
buffer << L">";
|
||||
else
|
||||
if( c == '&' )
|
||||
buffer << L"&";
|
||||
else
|
||||
if( c == '\"' )
|
||||
buffer << L""";
|
||||
else
|
||||
if( c == '\'' )
|
||||
buffer << L"'"; // (it is "'" but IE8 has a problem with ') (' is valid in HTML5, but not HTML4)
|
||||
else
|
||||
if( c == 10 )
|
||||
buffer << L" ";
|
||||
else
|
||||
if( c == 13 )
|
||||
buffer << L" ";
|
||||
else
|
||||
if( c == 0 )
|
||||
buffer << L"�";
|
||||
else
|
||||
buffer << c;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const std::string * str)
|
||||
|
||||
|
||||
void HtmlTextStream::Escape(bool escape_characters)
|
||||
{
|
||||
escape = escape_characters;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const char * str)
|
||||
{
|
||||
if( escape )
|
||||
EPutText(str);
|
||||
@@ -456,8 +595,6 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const wchar_t * str)
|
||||
{
|
||||
if( escape )
|
||||
@@ -469,17 +606,6 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const std::wstring * str)
|
||||
{
|
||||
if( escape )
|
||||
EPutText(str);
|
||||
else
|
||||
PutText(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const std::wstring & str)
|
||||
{
|
||||
if( escape )
|
||||
@@ -491,8 +617,6 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(char v)
|
||||
{
|
||||
if( escape )
|
||||
@@ -504,6 +628,17 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(unsigned char v)
|
||||
{
|
||||
if( escape )
|
||||
ETextPutChar(v);
|
||||
else
|
||||
PutChar(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(wchar_t v)
|
||||
{
|
||||
if( escape )
|
||||
@@ -515,14 +650,31 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(int v)
|
||||
HtmlTextStream & HtmlTextStream::operator<<(bool 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)
|
||||
* bool, short, int, long, long long, float, double and long double don't have to be escaped
|
||||
* they consist of digits only: '0' - '9' (and with an exponent in the case of float/double/long double)
|
||||
* and don't have to be escaped
|
||||
*
|
||||
*/
|
||||
TextStream<std::wstring>::operator<<(v);
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(short v)
|
||||
{
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(int v)
|
||||
{
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -530,7 +682,23 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(long v)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(v);
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(long long v)
|
||||
{
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(unsigned short v)
|
||||
{
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -538,7 +706,7 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(unsigned int v)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(v);
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -546,7 +714,23 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(unsigned long v)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(v);
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(unsigned long long v)
|
||||
{
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(float v)
|
||||
{
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -554,7 +738,15 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(double v)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(v);
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(long double v)
|
||||
{
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -562,7 +754,46 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const void * v)
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(v);
|
||||
buffer.operator<<(v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const Stream & stream)
|
||||
{
|
||||
if( escape )
|
||||
{
|
||||
if(stream.is_char_stream())
|
||||
{
|
||||
int res;
|
||||
bool correct;
|
||||
size_t len;
|
||||
size_t index = 0;
|
||||
size_t stream_len = stream.size();
|
||||
|
||||
// CHECKME
|
||||
while( index < stream_len && (len = pt::utf8_to_int(stream, index, res, correct)) > 0 )
|
||||
{
|
||||
if( !correct )
|
||||
res = 0xFFFD; // U+FFFD "replacement character"
|
||||
|
||||
ETextPutChar(static_cast<wchar_t>(res));
|
||||
index += len;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(stream.is_wchar_stream())
|
||||
{
|
||||
for(size_t i=0 ; i < stream.size() ; ++i)
|
||||
ETextPutChar(stream.get_wchar(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.operator<<(stream);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -573,20 +804,20 @@ HtmlTextStream & HtmlTextStream::operator<<(const pt::Space & space)
|
||||
{
|
||||
if( escape )
|
||||
{
|
||||
space.serialize_to_space_stream(*this, true);
|
||||
space.serialize_to_json_stream(*this, true);
|
||||
|
||||
/*
|
||||
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();
|
||||
*/
|
||||
pt::WTextStream tmp_stream;
|
||||
space.serialize_to_json_stream(tmp_stream, true);
|
||||
|
||||
pt::WTextStream::iterator i = tmp_stream.begin();
|
||||
|
||||
for( ; i != tmp_stream.end() ; ++i)
|
||||
ETextPutChar(*i);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextStream<std::wstring>::operator<<(space);
|
||||
// FIXME this will serialize to Space format !!!!
|
||||
buffer.operator<<(space);
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -595,28 +826,24 @@ return *this;
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(const pt::Date & date)
|
||||
{
|
||||
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);
|
||||
}
|
||||
// dates don't need to be escaped
|
||||
buffer.operator<<(date);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
HtmlTextStream & HtmlTextStream::operator<<(morm::Model & model)
|
||||
{
|
||||
// CHECKME
|
||||
pt::TextStream tmp_stream;
|
||||
model.to_text(tmp_stream);
|
||||
|
||||
return operator<<(tmp_stream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
Reference in New Issue
Block a user