#include "CppSQLite3.h"
#include <cstdlib>
Go to the source code of this file.
Functions | |
int | sqlite3_encode_binary (const unsigned char *in, int n, unsigned char *out) |
int | sqlite3_decode_binary (const unsigned char *in, unsigned char *out) |
Variables | |
static const bool | DONT_DELETE_MSG = false |
int sqlite3_decode_binary | ( | const unsigned char * | in, | |
unsigned char * | out | |||
) |
Definition at line 2959 of file CppSQLite3.cpp.
Referenced by CppSQLite3Binary::getBinary().
{ int i, c, e; e = *(in++); i = 0; while( (c = *(in++))!=0 ){ if( c==1 ){ c = *(in++); if( c==1 ){ c = 0; }else if( c==2 ){ c = 1; }else if( c==3 ){ c = '\''; }else{ return -1; } } out[i++] = (c + e)&0xff; } return i; }
int sqlite3_encode_binary | ( | const unsigned char * | in, | |
int | n, | |||
unsigned char * | out | |||
) |
Definition at line 2855 of file CppSQLite3.cpp.
Referenced by CppSQLite3Binary::getEncoded().
{ int i, j, e, m; int cnt[256]; if( n<=0 ){ out[0] = 'x'; out[1] = 0; return 1; } memset(cnt, 0, sizeof(cnt)); for(i=n-1; i>=0; i--){ cnt[in[i]]++; } m = n; for(i=1; i<256; i++){ int sum; if( i=='\'' ) continue; sum = cnt[i] + cnt[(i+1)&0xff] + cnt[(i+'\'')&0xff]; if( sum<m ){ m = sum; e = i; if( m==0 ) break; } } out[0] = e; j = 1; for(i=0; i<n; i++){ int c = (in[i] - e)&0xff; if( c==0 ){ out[j++] = 1; out[j++] = 1; }else if( c==1 ){ out[j++] = 1; out[j++] = 2; }else if( c=='\'' ){ out[j++] = 1; out[j++] = 3; }else{ out[j++] = c; } } out[j] = 0; return j; }
const bool DONT_DELETE_MSG = false [static] |
Definition at line 67 of file CppSQLite3.cpp.
Referenced by CppSQLite3Binary::allocBuffer(), CppSQLite3Statement::bind(), CppSQLite3Statement::bindNull(), CppSQLite3DB::checkDB(), CppSQLite3Statement::checkDB(), CppSQLite3Table::checkResults(), CppSQLite3Statement::checkVM(), CppSQLite3Query::checkVM(), CppSQLite3Statement::execDML(), CppSQLite3DB::execQuery(), CppSQLite3Statement::execQuery(), CppSQLite3DB::execScalar(), CppSQLite3Query::fieldDataType(), CppSQLite3Query::fieldDeclType(), CppSQLite3Query::fieldIndex(), CppSQLite3Table::fieldName(), CppSQLite3Query::fieldName(), CppSQLite3Table::fieldValue(), CppSQLite3Query::fieldValue(), CppSQLite3Statement::finalize(), CppSQLite3Query::finalize(), CppSQLite3Binary::getBinary(), CppSQLite3Query::getBlobField(), CppSQLite3Query::nextRow(), CppSQLite3DB::open(), CppSQLite3Statement::reset(), CppSQLite3Binary::setEncoded(), and CppSQLite3Table::setRow().