creaImageIO_lib
CppSQLite3.cpp File Reference
#include "CppSQLite3.h"
#include <cstdlib>
Include dependency graph for CppSQLite3.cpp:

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
 

Function Documentation

int sqlite3_decode_binary ( const unsigned char *  in,
unsigned char *  out 
)

Definition at line 2959 of file CppSQLite3.cpp.

Referenced by CppSQLite3Binary::getBinary().

2959  {
2960 
2961  int i, c, e;
2962 
2963  e = *(in++);
2964 
2965  i = 0;
2966 
2967  while( (c = *(in++))!=0 ){
2968 
2969  if( c==1 ){
2970 
2971  c = *(in++);
2972 
2973  if( c==1 ){
2974 
2975  c = 0;
2976 
2977  }else if( c==2 ){
2978 
2979  c = 1;
2980 
2981  }else if( c==3 ){
2982 
2983  c = '\'';
2984 
2985  }else{
2986 
2987  return -1;
2988 
2989  }
2990 
2991  }
2992 
2993  out[i++] = (c + e)&0xff;
2994 
2995  }
2996 
2997  return i;
2998 
2999 }

Here is the caller graph for this function:

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().

2855  {
2856 
2857  int i, j, e, m;
2858 
2859  int cnt[256];
2860 
2861  if( n<=0 ){
2862 
2863  out[0] = 'x';
2864 
2865  out[1] = 0;
2866 
2867  return 1;
2868 
2869  }
2870 
2871  memset(cnt, 0, sizeof(cnt));
2872 
2873  for(i=n-1; i>=0; i--){ cnt[in[i]]++; }
2874 
2875  m = n;
2876 
2877  for(i=1; i<256; i++){
2878 
2879  int sum;
2880 
2881  if( i=='\'' ) continue;
2882 
2883  sum = cnt[i] + cnt[(i+1)&0xff] + cnt[(i+'\'')&0xff];
2884 
2885  if( sum<m ){
2886 
2887  m = sum;
2888 
2889  e = i;
2890 
2891  if( m==0 ) break;
2892 
2893  }
2894 
2895  }
2896 
2897  out[0] = e;
2898 
2899  j = 1;
2900 
2901  for(i=0; i<n; i++){
2902 
2903  int c = (in[i] - e)&0xff;
2904 
2905  if( c==0 ){
2906 
2907  out[j++] = 1;
2908 
2909  out[j++] = 1;
2910 
2911  }else if( c==1 ){
2912 
2913  out[j++] = 1;
2914 
2915  out[j++] = 2;
2916 
2917  }else if( c=='\'' ){
2918 
2919  out[j++] = 1;
2920 
2921  out[j++] = 3;
2922 
2923  }else{
2924 
2925  out[j++] = c;
2926 
2927  }
2928 
2929  }
2930 
2931  out[j] = 0;
2932 
2933  return j;
2934 
2935 }

Here is the caller graph for this function:

Variable Documentation