added support for UTF-8
now the UTF-8 is a default charset git-svn-id: svn://ttmath.org/publicrep/winix/trunk@677 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "dbtextstream.h"
|
||||
|
||||
#include "ezc.h"
|
||||
|
||||
|
||||
DbTextStream::DbTextStream()
|
||||
@@ -54,12 +54,39 @@ DbTextStream & DbTextStream::PutText(const std::string & str)
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const wchar_t * str)
|
||||
{
|
||||
Ezc::WideToUTF8(str, buffer, false);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::wstring * str)
|
||||
{
|
||||
return PutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::PutText(const std::wstring & str)
|
||||
{
|
||||
return PutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const RawText<const char*> & raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const RawText<const wchar_t*> & raw)
|
||||
{
|
||||
return PutText(raw.par);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<std::string> raw)
|
||||
@@ -68,9 +95,24 @@ DbTextStream & DbTextStream::operator<<(RawText<std::string> raw)
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<std::wstring> raw)
|
||||
{
|
||||
return PutText(raw.par.c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<char> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<wchar_t> raw)
|
||||
{
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
@@ -79,7 +121,7 @@ return *this;
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<int> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
@@ -88,7 +130,7 @@ return *this;
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<long> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
@@ -97,7 +139,7 @@ return *this;
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<unsigned int> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
@@ -106,7 +148,7 @@ return *this;
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<unsigned long> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
@@ -115,7 +157,7 @@ return *this;
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<double> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
@@ -124,7 +166,7 @@ return *this;
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(RawText<void*> raw)
|
||||
{
|
||||
TextStream::operator<<(raw.par);
|
||||
TextStream<std::string>::operator<<(raw.par);
|
||||
was_param = false;
|
||||
|
||||
return *this;
|
||||
@@ -185,6 +227,20 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::ETextPutChar(wchar_t c)
|
||||
{
|
||||
if( c == '\\' )
|
||||
buffer += "\\\\";
|
||||
else
|
||||
if( c == '\'' )
|
||||
buffer += "\\\'"; // don't use "''" because we use the method for PQconnectdb too
|
||||
else
|
||||
if( c != 0 )
|
||||
Ezc::IntToUTF8(int(c), buffer, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const char * str)
|
||||
{
|
||||
@@ -218,6 +274,39 @@ DbTextStream & DbTextStream::EPutText(const std::string & str)
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const wchar_t * str)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
|
||||
for( ; *str ; ++str )
|
||||
ETextPutChar(*str);
|
||||
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::wstring * str)
|
||||
{
|
||||
return EPutText(str->c_str());
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::EPutText(const std::wstring & str)
|
||||
{
|
||||
return EPutText(str.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this method can escaped 0 in the middle of the string
|
||||
DbTextStream & DbTextStream::EPutBin(const char * str, size_t len)
|
||||
{
|
||||
@@ -273,6 +362,25 @@ DbTextStream & DbTextStream::operator<<(const std::string & str)
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const wchar_t * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::wstring * str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(const std::wstring & str)
|
||||
{
|
||||
return EPutText(str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(char v)
|
||||
{
|
||||
@@ -291,12 +399,29 @@ return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(wchar_t v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
if( ext_escape )
|
||||
buffer += 'E';
|
||||
|
||||
buffer += '\'';
|
||||
ETextPutChar(v);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
DbTextStream & DbTextStream::operator<<(int v)
|
||||
{
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
@@ -308,7 +433,7 @@ DbTextStream & DbTextStream::operator<<(long v)
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
@@ -320,7 +445,7 @@ DbTextStream & DbTextStream::operator<<(unsigned int v)
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
@@ -332,7 +457,7 @@ DbTextStream & DbTextStream::operator<<(unsigned long v)
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
@@ -344,7 +469,7 @@ DbTextStream & DbTextStream::operator<<(double v)
|
||||
if( was_param )
|
||||
buffer += ", ";
|
||||
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
was_param = true;
|
||||
|
||||
return *this;
|
||||
@@ -357,7 +482,7 @@ DbTextStream & DbTextStream::operator<<(const void * v)
|
||||
buffer += ", ";
|
||||
|
||||
buffer += '\''; // !! not needed here?
|
||||
TextStream::operator<<(v);
|
||||
TextStream<std::string>::operator<<(v);
|
||||
buffer += '\'';
|
||||
was_param = true;
|
||||
|
||||
|
Reference in New Issue
Block a user