|
|
|
@ -45,100 +45,209 @@ 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool HtmlTextStream::empty() const
|
|
|
|
|
{
|
|
|
|
|
return buffer.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t HtmlTextStream::size() const
|
|
|
|
|
{
|
|
|
|
|
return buffer.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void HtmlTextStream::to_str(std::wstring & str)
|
|
|
|
|
void HtmlTextStream::reserve(size_t len)
|
|
|
|
|
{
|
|
|
|
|
str = TextStream<std::wstring>::Str();
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const char * str)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(c);
|
|
|
|
|
buffer.operator<<(str);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutChar(wchar_t c)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const std::string & str)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(c);
|
|
|
|
|
buffer.operator<<(str);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const char * str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const wchar_t * str)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(str);
|
|
|
|
|
buffer.operator<<(str);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const char * str, size_t len)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const std::wstring & str)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::Write(str, len);
|
|
|
|
|
buffer.operator<<(str);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const std::string * str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const char * str, size_t len)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(str);
|
|
|
|
|
buffer.write(str, len);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const std::string & str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const wchar_t * str, size_t len)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(str);
|
|
|
|
|
buffer.write(str, len);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const wchar_t * str)
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutChar(char c)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(str);
|
|
|
|
|
buffer.operator<<(c);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const std::wstring * str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutChar(unsigned char c)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(str);
|
|
|
|
|
buffer.operator<<(c);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutText(const std::wstring & str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutChar(wchar_t c)
|
|
|
|
|
{
|
|
|
|
|
buffer.operator<<(c);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::PutChar(bool val)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(str);
|
|
|
|
|
buffer.operator<<(val);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
@ -149,252 +258,253 @@ return *this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const RawText<const char*> & raw)
|
|
|
|
|
{
|
|
|
|
|
return PutText(raw.par);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const RawText<const wchar_t*> & raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<std::string> raw)
|
|
|
|
|
{
|
|
|
|
|
return PutText(raw.par);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<const std::string*> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const RawText<const wchar_t*> & raw)
|
|
|
|
|
{
|
|
|
|
|
return PutText(raw.par);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<const std::wstring*> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<std::wstring> raw)
|
|
|
|
|
{
|
|
|
|
|
return PutText(raw.par);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<std::string> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<char> raw)
|
|
|
|
|
{
|
|
|
|
|
return PutText(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<std::wstring> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned char> raw)
|
|
|
|
|
{
|
|
|
|
|
return PutText(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<wchar_t> raw)
|
|
|
|
|
{
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<char> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<bool> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<wchar_t> raw)
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<short> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
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<unsigned int> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<long long> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned long> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned short> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<double> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned int> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<void*> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned long> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Space> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<unsigned long long> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Date> raw)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<float> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(raw.par);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const HtmlTextStream & stream)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<double> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::operator<<(stream.Str());
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::Write(const char * buf, size_t len)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<long double> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::Write(buf, len);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::Write(const wchar_t * buf, size_t len)
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<void*> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::Write(buf, len);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::write(const char * buf, size_t len)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Stream> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::write(buf, len);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::write(const wchar_t * buf, size_t len)
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Space> raw)
|
|
|
|
|
{
|
|
|
|
|
TextStream<std::wstring>::write(buf, len);
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(RawText<pt::Date> raw)
|
|
|
|
|
{
|
|
|
|
|
buffer.operator<<(raw.par);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const HtmlTextStream & stream)
|
|
|
|
|
{
|
|
|
|
|
buffer.operator<<(stream.buffer);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
with escaping
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void HtmlTextStream::Escape(bool escape_characters)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::write(const char * buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
escape = escape_characters;
|
|
|
|
|
buffer.write(buf, len);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::ETextPutChar(char c)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::write(const wchar_t * buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
return ETextPutChar(static_cast<wchar_t>(c));
|
|
|
|
|
buffer.write(buf, len);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
with escaping
|
|
|
|
|
*/
|
|
|
|
|
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)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::EPutText(const std::string & str)
|
|
|
|
|
{
|
|
|
|
|
pt::utf8_to_wide(str, len, tmp_string);
|
|
|
|
|
return EPutText(str.c_str(), str.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(size_t i=0 ; i<tmp_string.size() ; ++i)
|
|
|
|
|
ETextPutChar(tmp_string[i]);
|
|
|
|
|
|
|
|
|
|
tmp_string.clear();
|
|
|
|
|
HtmlTextStream & HtmlTextStream::EPutText(const wchar_t * str)
|
|
|
|
|
{
|
|
|
|
|
for( ; *str ; ++str )
|
|
|
|
|
ETextPutChar(*str);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::EPutText(const std::string * str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::EPutText(const std::wstring & str)
|
|
|
|
|
{
|
|
|
|
|
return EPutText(*str);
|
|
|
|
|
return EPutText(str.c_str(), str.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::EPutText(const std::string & str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::EPutText(const char * str, size_t len)
|
|
|
|
|
{
|
|
|
|
|
pt::utf8_to_wide(str, tmp_string);
|
|
|
|
|
|
|
|
|
|
for(size_t i=0 ; i<tmp_string.size() ; ++i)
|
|
|
|
|
ETextPutChar(tmp_string[i]);
|
|
|
|
|
int res;
|
|
|
|
|
bool correct;
|
|
|
|
|
size_t utf8_len;
|
|
|
|
|
|
|
|
|
|
tmp_string.clear();
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
// 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));
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::EPutText(const wchar_t * str)
|
|
|
|
|
{
|
|
|
|
|
for( ; *str ; ++str )
|
|
|
|
|
ETextPutChar(*str);
|
|
|
|
|
len -= utf8_len;
|
|
|
|
|
str += utf8_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
@ -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,7 +606,7 @@ return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const std::wstring * str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const std::wstring & str)
|
|
|
|
|
{
|
|
|
|
|
if( escape )
|
|
|
|
|
EPutText(str);
|
|
|
|
@ -480,20 +617,18 @@ return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(const std::wstring & str)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(char v)
|
|
|
|
|
{
|
|
|
|
|
if( escape )
|
|
|
|
|
EPutText(str);
|
|
|
|
|
ETextPutChar(v);
|
|
|
|
|
else
|
|
|
|
|
PutText(str);
|
|
|
|
|
PutChar(v);
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(char v)
|
|
|
|
|
HtmlTextStream & HtmlTextStream::operator<<(unsigned char v)
|
|
|
|
|
{
|
|
|
|
|
if( escape )
|
|
|
|
|
ETextPutChar(v);
|
|
|
|
@ -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) |