2010-09-18 02:51:12 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dbtextstream.h"
|
2010-11-23 22:52:25 +01:00
|
|
|
#include "utf8.h"
|
2010-09-18 02:51:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
DbTextStream::DbTextStream()
|
|
|
|
{
|
|
|
|
was_param = false;
|
|
|
|
ext_escape = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DbTextStream::SetExtented(bool ext)
|
|
|
|
{
|
|
|
|
ext_escape = ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
without escaping
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::PutText(const char * str)
|
|
|
|
{
|
|
|
|
buffer += str;
|
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::PutText(const std::string * str)
|
|
|
|
{
|
|
|
|
return PutText(str->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::PutText(const std::string & str)
|
|
|
|
{
|
|
|
|
return PutText(str.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-09 22:27:45 +02:00
|
|
|
DbTextStream & DbTextStream::operator<<(const RawText<const char*> & raw)
|
2010-09-18 02:51:12 +02:00
|
|
|
{
|
|
|
|
return PutText(raw.par);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
DbTextStream & DbTextStream::operator<<(const RawText<const wchar_t*> & raw)
|
|
|
|
{
|
|
|
|
return PutText(raw.par);
|
|
|
|
}
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<const std::string*> raw)
|
|
|
|
{
|
|
|
|
return PutText(raw.par);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<const std::wstring*> raw)
|
|
|
|
{
|
|
|
|
return PutText(raw.par);
|
|
|
|
}
|
2010-09-18 02:51:12 +02:00
|
|
|
|
2010-10-09 22:27:45 +02:00
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<std::string> raw)
|
2010-09-18 02:51:12 +02:00
|
|
|
{
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
return PutText(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<std::wstring> raw)
|
|
|
|
{
|
added: uptime winix function prints how many sessions there are
changed: functions for text/numbers conversions
int Toi(const std::string & str, int base = 10);
int Toi(const std::wstring & str, int base = 10);
int Toi(const char * str, int base = 10);
int Toi(const wchar_t * str, int base = 10);
long Tol(const std::string & str, int base = 10);
long Tol(const std::wstring & str, int base = 10);
long Tol(const char * str, int base = 10);
long Tol(const wchar_t * str, int base = 10);
template<class CharType>
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10);
template<class CharType>
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10);
const wchar_t * Toa(unsigned int value, int base = 10);
const wchar_t * Toa(unsigned long value, int base = 10);
const wchar_t * Toa(int value, int base = 10);
const wchar_t * Toa(long value, int base = 10);
void Toa(int value, std::string & res, int base = 10, bool clear = true);
void Toa(long value, std::string & res, int base = 10, bool clear = true);
void Toa(int value, std::wstring & res, int base = 10, bool clear = true);
void Toa(long value, std::wstring & res, int base = 10, bool clear = true);
added: HtmlTextStream class (files htmltextstream.cpp htmltextstream.h in templates)
this is a special stream for automatically escaping html tags
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@682 e52654a7-88a9-db11-a3e9-0013d4bc506e
2010-11-25 02:34:46 +01:00
|
|
|
return PutText(raw.par);
|
2010-11-21 01:19:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<char> raw)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<wchar_t> raw)
|
|
|
|
{
|
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<int> raw)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<long> raw)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<unsigned int> raw)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<unsigned long> raw)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<double> raw)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(RawText<void*> raw)
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(raw.par);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-09 22:27:45 +02:00
|
|
|
DbTextStream & DbTextStream::operator<<(const RawText<tm> & t)
|
|
|
|
{
|
|
|
|
buffer += ConvertTime(t.par);
|
|
|
|
was_param = false;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
with escaping
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// !! sprawdzic jej dzialanie dla kolumn bytea (binarnych)
|
|
|
|
DbTextStream & DbTextStream::EBinPutChar(char c_)
|
|
|
|
{
|
|
|
|
char buf[10];
|
|
|
|
|
|
|
|
int c = (unsigned char)c_;
|
|
|
|
|
|
|
|
if( (c>=0 && c<=31) || c>=127 || c==39 || c==92 )
|
|
|
|
{
|
|
|
|
sprintf(buf, "\\\\%03o", c);
|
|
|
|
buffer += buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer += c;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::ETextPutChar(char c)
|
|
|
|
{
|
|
|
|
if( c == '\\' )
|
|
|
|
buffer += "\\\\";
|
|
|
|
else
|
|
|
|
if( c == '\'' )
|
|
|
|
buffer += "\\\'"; // don't use "''" because we use the method for PQconnectdb too
|
|
|
|
else
|
|
|
|
if( c != 0 )
|
|
|
|
buffer += c;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
|
|
|
|
DbTextStream & DbTextStream::EPutText(const char * 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::string * str)
|
|
|
|
{
|
|
|
|
return EPutText(str->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::EPutText(const std::string & str)
|
|
|
|
{
|
|
|
|
return EPutText(str.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
// this method can escaped 0 in the middle of the string
|
|
|
|
DbTextStream & DbTextStream::EPutBin(const char * str, size_t len)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
|
|
|
if( ext_escape )
|
|
|
|
buffer += 'E';
|
|
|
|
|
|
|
|
buffer += '\'';
|
|
|
|
|
|
|
|
for(size_t i = 0 ; i < len ; ++i)
|
|
|
|
EBinPutChar(str[i]);
|
|
|
|
|
|
|
|
buffer += '\'';
|
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::EPutBin(const std::string * str)
|
|
|
|
{
|
|
|
|
return EPutBin(str->c_str(), str->size());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::EPutBin(const std::string & str)
|
|
|
|
{
|
|
|
|
return EPutBin(str.c_str(), str.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(const char * str)
|
|
|
|
{
|
|
|
|
return EPutText(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(const std::string * str)
|
|
|
|
{
|
|
|
|
return EPutText(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(const std::string & str)
|
|
|
|
{
|
|
|
|
return EPutText(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(char v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
|
|
|
if( ext_escape )
|
|
|
|
buffer += 'E';
|
|
|
|
|
|
|
|
buffer += '\'';
|
|
|
|
ETextPutChar(v);
|
|
|
|
buffer += '\'';
|
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
DbTextStream & DbTextStream::operator<<(wchar_t v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
|
|
|
if( ext_escape )
|
|
|
|
buffer += 'E';
|
|
|
|
|
|
|
|
buffer += '\'';
|
|
|
|
ETextPutChar(v);
|
|
|
|
buffer += '\'';
|
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-18 02:51:12 +02:00
|
|
|
DbTextStream & DbTextStream::operator<<(int v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(v);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(long v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(v);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(unsigned int v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(v);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(unsigned long v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(v);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(double v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(v);
|
2010-09-18 02:51:12 +02:00
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DbTextStream & DbTextStream::operator<<(const void * v)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
|
|
|
|
|
|
|
buffer += '\''; // !! not needed here?
|
2010-11-21 01:19:17 +01:00
|
|
|
TextStream<std::string>::operator<<(v);
|
2010-09-18 02:51:12 +02:00
|
|
|
buffer += '\'';
|
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-09 22:27:45 +02:00
|
|
|
DbTextStream & DbTextStream::operator<<(const tm & t)
|
|
|
|
{
|
|
|
|
if( was_param )
|
|
|
|
buffer += ", ";
|
2010-09-18 02:51:12 +02:00
|
|
|
|
2010-10-09 22:27:45 +02:00
|
|
|
buffer += '\'';
|
|
|
|
buffer += ConvertTime(t);
|
|
|
|
buffer += '\'';
|
|
|
|
was_param = true;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char * DbTextStream::ConvertTime(const tm & t)
|
|
|
|
{
|
|
|
|
// not thread safe
|
|
|
|
static char buffer[100];
|
|
|
|
|
|
|
|
sprintf(buffer, "%04d-%02d-%02d %02d:%02d:%02d",
|
|
|
|
t.tm_year + 1900,
|
|
|
|
t.tm_mon + 1,
|
|
|
|
t.tm_mday,
|
|
|
|
t.tm_hour,
|
|
|
|
t.tm_min,
|
|
|
|
t.tm_sec);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
2010-09-18 02:51:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|