added: a new way: HEX format to saving/reading from PostgreSQL bytea columns

added: to Request:
       // binary page
       BinaryPage binary_page;

       // a compressed page ready to send to the client
       BinaryPage compressed_page;

       // if true then either page or ajaxpage will be sent to the client
       // if false then binary_page is sent
       // default: true
       bool use_text_page;

       BinaryPage is defined as (in requesttypes.h):
       typedef PT::TextStreamBase<char, 1, 4096> BinaryPage;

added: to Compress: now it can gets BinaryPage as arguments (input, output)
changed: winix version to: 0.5.0
added: in templates: TexTextStream class
       for taking input to the TeX typesetting system





git-svn-id: svn://ttmath.org/publicrep/winix/trunk@884 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-09-11 05:19:45 +00:00
parent 9174555ff8
commit d8260d8383
23 changed files with 1051 additions and 129 deletions

View File

@@ -470,8 +470,9 @@ return err;
/*
converting from a bytea
the old way (escape format)
*/
/*
int DbBase::CharToInt(char c)
{
return (int)(unsigned char)(c-'0');
@@ -537,6 +538,53 @@ size_t i = 0;
out += c;
}
}
*/
/*
converting from a bytea
the new way (hex format)
*/
char DbBase::UnescapeBinHexToDigit(char hex)
{
if( hex>='0' && hex<='9' )
return hex - '0';
if( hex>='a' && hex<='z' )
return hex - 'a' + 10;
if( hex>='A' && hex<='Z' )
return hex - 'A' + 10;
return 0;
}
void DbBase::UnescapeBin(const char * str, size_t len, std::string & out, bool clear_out)
{
if( clear_out )
out.clear();
if( len < 2 || str[0]!='\\' || str[1]!='x' )
{
log << log1 << "Db: unsupported binary format (skipping)" << logend;
return;
}
for(size_t i=2 ; i + 1 < len ; i+=2 )
{
int c1 = UnescapeBinHexToDigit(str[i]);
int c2 = UnescapeBinHexToDigit(str[i+1]);
out += ((c1 << 4) | c2);
}
}
/*
end of converting from bytea

View File

@@ -93,9 +93,11 @@ protected:
private:
static int CharToInt(char c);
static bool IsCorrectOctalDigit(char c);
static int UnescapeBin(const char * str, size_t & i, size_t len);
// static int CharToInt(char c);
// static bool IsCorrectOctalDigit(char c);
// static int UnescapeBin(const char * str, size_t & i, size_t len);
static char UnescapeBinHexToDigit(char hex);
DbTextStream bquery;
PT::SpaceParser conf_parser;

View File

@@ -217,6 +217,10 @@ return *this;
*/
/*
old PostgreSQL Escape Format
*/
/*
DbTextStream & DbTextStream::EBinPutChar(char c_)
{
char buf[20];
@@ -235,6 +239,26 @@ char buf[20];
return *this;
}
*/
// get hex digit for c_ between <0, 15>
char DbTextStream::EBinGetHex(char c)
{
if( c < 10 )
return c + '0';
return c - 10 + 'A';
}
DbTextStream & DbTextStream::EBinPutChar(char c)
{
buffer += EBinGetHex(((unsigned char)c) >> 4);
buffer += EBinGetHex(((unsigned char)c) & 0x0f);
return *this;
}
DbTextStream & DbTextStream::ETextPutChar(char c)
@@ -341,7 +365,7 @@ DbTextStream & DbTextStream::EPutBin(const char * str, size_t len)
if( ext_escape )
buffer += 'E';
buffer += '\'';
buffer += "\'\\\\x";
for(size_t i = 0 ; i < len ; ++i)
EBinPutChar(str[i]);

View File

@@ -161,6 +161,8 @@ private:
bool ext_escape;
TextStream<std::wstring> tmp_stream;
char EBinGetHex(char c);
};