0000: 2f 2f 20 76 74 61 62 5f 69 6e 66 6f 2e 68 0d 0a // vtab_info.h..
0010: 23 70 72 61 67 6d 61 20 6f 6e 63 65 0d 0a 0d 0a #pragma once....
0020: 23 69 6e 63 6c 75 64 65 20 22 70 68 69 73 69 63 #include "phisic
0030: 61 6c 69 6e 66 6f 2e 68 22 0d 0a 23 69 6e 63 6c alinfo.h"..#incl
0040: 75 64 65 20 22 73 74 72 61 74 65 67 79 63 61 73 ude "strategycas
0050: 68 2e 68 22 0d 0a 23 69 6e 63 6c 75 64 65 20 22 h.h"..#include "
0060: 66 69 6c 74 65 72 6d 61 63 68 69 6e 65 2e 68 22 filtermachine.h"
0070: 0d 0a 0d 0a 0d 0a 73 74 72 75 63 74 20 72 65 63 ......struct rec
0080: 6f 72 64 5f 62 75 66 65 72 0d 0a 7b 0d 0a 09 4c ord_bufer..{...L
0090: 50 43 53 54 52 20 62 75 66 65 72 28 29 20 63 6f PCSTR bufer() co
00a0: 6e 73 74 20 7b 72 65 74 75 72 6e 20 5f 62 75 66 nst {return _buf
00b0: 65 72 3b 7d 0d 0a 0d 0a 70 72 69 76 61 74 65 3a er;}....private:
00c0: 0d 0a 09 66 72 69 65 6e 64 20 73 74 72 75 63 74 ...friend struct
00d0: 20 74 61 62 6c 65 5f 72 65 61 64 65 72 3b 0d 0a table_reader;..
00e0: 09 4c 50 53 54 52 20 5f 62 75 66 65 72 3b 0d 0a .LPSTR _bufer;..
00f0: 7d 3b 0d 0a 0d 0a 73 74 72 75 63 74 20 74 61 62 };....struct tab
0100: 6c 65 5f 72 65 61 64 65 72 0d 0a 7b 0d 0a 70 72 le_reader..{..pr
0110: 69 76 61 74 65 3a 0d 0a 09 66 72 69 65 6e 64 20 ivate:...friend
0120: 63 6c 61 73 73 20 43 56 74 61 62 49 6e 66 6f 3b class CVtabInfo;
0130: 0d 0a 09 66 72 69 65 6e 64 20 73 74 72 75 63 74 ...friend struct
0140: 20 72 65 61 64 5f 74 72 61 6e 5f 67 75 61 72 64 read_tran_guard
0150: 3b 0d 0a 0d 0a 09 74 61 62 6c 65 5f 72 65 61 64 ;.....table_read
0160: 65 72 28 29 20 3a 20 70 46 69 72 73 74 52 65 61 er() : pFirstRea
0170: 64 65 72 42 75 66 66 65 72 28 4e 55 4c 4c 29 20 derBuffer(NULL)
0180: 7b 7d 0d 0a 0d 0a 09 76 6f 69 64 20 63 6f 6e 6e {}.....void conn
0190: 65 63 74 52 65 61 64 65 72 28 72 65 63 6f 72 64 ectReader(record
01a0: 5f 62 75 66 65 72 26 20 72 65 61 64 65 72 42 75 _bufer& readerBu
01b0: 66 66 65 72 2c 20 43 54 61 62 6c 65 45 78 2a 20 ffer, CTableEx*
01c0: 70 54 61 62 6c 65 2c 20 4c 50 43 53 54 52 20 70 pTable, LPCSTR p
01d0: 54 61 62 6c 65 42 75 66 2c 20 44 57 4f 52 44 20 TableBuf, DWORD
01e0: 62 75 66 4c 65 6e 29 20 63 6f 6e 73 74 0d 0a 09 bufLen) const...
01f0: 7b 0d 0a 09 09 69 66 28 21 70 46 69 72 73 74 52 {....if(!pFirstR
0200: 65 61 64 65 72 42 75 66 66 65 72 29 20 2f 2f 20 eaderBuffer) //
0210: cf ee e4 ea eb fe f7 e0 e5 f2 f1 ff 20 ef e5 f0 ............ ...
0220: e2 fb e9 20 f7 e8 f2 e0 f2 e5 eb fc 0d 0a 09 09 ... ............
0230: 7b 0d 0a 09 09 09 2f 2f 20 c7 e0 ef ee ec ed e8 {.....// .......
0240: ec 20 e5 e3 ee 20 e1 f3 f4 e5 f0 2e 0d 0a 09 09 . ... ..........
0250: 09 70 46 69 72 73 74 52 65 61 64 65 72 42 75 66 .pFirstReaderBuf
0260: 66 65 72 20 3d 20 26 72 65 61 64 65 72 42 75 66 fer = &readerBuf
0270: 66 65 72 3b 0d 0a 09 09 09 2f 2f 20 cd e0 e7 ed fer;.....// ....
0280: e0 f7 e8 ec 20 e5 e3 ee 20 e1 f3 f4 e5 f0 20 f0 .... ... ..... .
0290: e0 e2 ed fb ec 20 e1 f3 f4 e5 f0 f3 20 f2 e0 e1 ..... ...... ...
02a0: eb e8 f6 fb 2c 20 f7 f2 ee e1 20 eb e8 f8 ed e8 ...., .... .....
02b0: e9 20 f0 e0 e7 20 ed e5 20 ea ee ef e8 f0 ee e2 . ... .. .......
02c0: e0 f2 fc 2e 0d 0a 09 09 09 72 65 61 64 65 72 42 .........readerB
02d0: 75 66 66 65 72 2e 5f 62 75 66 65 72 20 3d 20 28 uffer._bufer = (
02e0: 4c 50 53 54 52 29 70 54 61 62 6c 65 42 75 66 3b LPSTR)pTableBuf;
02f0: 0d 0a 09 09 7d 0d 0a 09 09 65 6c 73 65 0d 0a 09 ....}....else...
0300: 09 7b 0d 0a 09 09 09 2f 2f 20 d2 e0 ea 20 ea e0 .{.....// ... ..
0310: ea 20 f2 e5 ef e5 f0 fc 20 f7 e8 f2 e0 f2 e5 eb . ...... .......
0320: fc 20 ed e5 20 ee e4 e8 ed 2c 20 f2 ee 20 ef f0 . .. ...., .. ..
0330: e8 e4 e5 f2 f1 ff 20 ea e0 e6 e4 ee ec f3 20 ea ...... ....... .
0340: ee ef e8 f0 ee e2 e0 f2 fc 20 f2 e0 e1 eb e8 f7 ......... ......
0350: ed fb e9 20 e1 f3 f4 e5 f0 2e 0d 0a 09 09 09 69 ... ...........i
0360: 66 28 70 46 69 72 73 74 52 65 61 64 65 72 42 75 f(pFirstReaderBu
0370: 66 66 65 72 2d 3e 5f 62 75 66 65 72 20 3d 3d 20 ffer->_bufer ==
0380: 70 54 61 62 6c 65 42 75 66 29 09 2f 2f 20 c5 f1 pTableBuf).// ..
0390: eb e8 20 ef e5 f0 e2 ee ec f3 20 f7 e8 f2 e0 f2 .. ....... .....
03a0: e5 eb fe 20 ed e5 20 f1 ee e7 e4 e0 e2 e0 eb e8 ... .. .........
03b0: 20 f1 e2 ee e9 20 e1 f3 f4 e5 f0 2c 20 f2 ee 20 .... ....., ..
03c0: ed e0 e4 ee 20 f1 ee e7 e4 e0 f2 fc 0d 0a 09 09 .... ...........
03d0: 09 7b 0d 0a 09 09 09 09 2f 2f 20 cd e0 e4 ee 20 .{......// ....
03e0: ef e5 f0 e2 ee ec f3 20 f1 ee e7 e4 e0 f2 fc 20 ....... .......
03f0: f1 e2 ee fe 20 ef e5 f0 f1 ee ed e0 eb fc ed f3 .... ...........
0400: fe 20 ea ee ef e8 fe 20 e1 f3 f4 e5 f0 e0 2c 20 . ..... ......,
0410: e8 20 f1 ea ee ef e8 f0 ee e2 e0 f2 fc 20 f2 f3 . ........... ..
0420: e4 e0 20 f2 ee 2c 0d 0a 09 09 09 09 2f 2f 20 f7 .. ..,......// .
0430: f2 ee 20 f1 e5 e9 f7 e0 f1 20 eb e5 e6 e8 f2 20 .. ...... .....
0440: e2 20 e1 f3 f4 e5 f0 e5 20 f2 e0 e1 eb e8 f6 fb . ...... .......
0450: 2e 0d 0a 09 09 09 09 70 46 69 72 73 74 52 65 61 .......pFirstRea
0460: 64 65 72 42 75 66 66 65 72 2d 3e 5f 62 75 66 65 derBuffer->_bufe
0470: 72 20 3d 20 6e 65 77 20 63 68 61 72 5b 62 75 66 r = new char[buf
0480: 4c 65 6e 5d 3b 0d 0a 09 09 09 09 6d 65 6d 63 70 Len];......memcp
0490: 79 28 70 46 69 72 73 74 52 65 61 64 65 72 42 75 y(pFirstReaderBu
04a0: 66 66 65 72 2d 3e 5f 62 75 66 65 72 2c 20 70 54 ffer->_bufer, pT
04b0: 61 62 6c 65 42 75 66 2c 20 62 75 66 4c 65 6e 29 ableBuf, bufLen)
04c0: 3b 0d 0a 09 09 09 7d 0d 0a 09 09 09 2f 2f 20 c8 ;.....}.....// .
04d0: 20 f1 ee e7 e4 e0 f2 fc 20 ed ee e2 ee ec f3 20 ....... ......
04e0: f7 e8 f2 e0 f2 e5 eb fe 20 ef e5 f0 f1 ee ed e0 ........ .......
04f0: eb fc ed fb e9 20 e1 f3 f4 e5 f0 0d 0a 09 09 09 ..... ..........
0500: 72 65 61 64 65 72 42 75 66 66 65 72 2e 5f 62 75 readerBuffer._bu
0510: 66 65 72 20 3d 20 6e 65 77 20 63 68 61 72 5b 62 fer = new char[b
0520: 75 66 4c 65 6e 5d 3b 0d 0a 09 09 7d 0d 0a 09 09 ufLen];....}....
0530: 2f 2f 20 d2 e5 ef e5 f0 fc 20 ed e0 f1 f7 e5 f2 // ...... ......
0540: 20 f2 f0 e0 ed e7 e0 ea f6 e8 e8 0d 0a 09 09 69 ..............i
0550: 66 28 21 61 6c 6c 52 65 61 64 65 72 43 6f 75 6e f(!allReaderCoun
0560: 74 29 09 2f 2f 20 cf ee e4 ea eb fe f7 e0 e5 f2 t).// ..........
0570: f1 ff 20 f1 e0 ec fb e9 20 ef e5 f0 e2 fb e9 20 .. ..... ......
0580: f7 e8 f2 e0 f2 e5 eb fc 0d 0a 09 09 7b 0d 0a 09 ............{...
0590: 09 09 69 66 28 21 70 44 61 74 61 44 69 63 74 2d ..if(!pDataDict-
05a0: 3e 64 77 5f 34 38 29 09 2f 2f 20 d2 f0 e0 ed e7 >dw_48).// .....
05b0: e0 ea f6 e8 ff 20 ed e5 20 ed e0 f7 e0 f2 e0 0d ..... .. .......
05c0: 0a 09 09 09 7b 0d 0a 09 09 09 09 69 66 28 64 62 ....{......if(db
05d0: 4d 6f 64 65 20 3d 3d 20 64 62 44 62 66 4d 6f 6e Mode == dbDbfMon
05e0: 6f 20 7c 7c 20 62 4e 65 65 64 54 72 61 6e 73 61 o || bNeedTransa
05f0: 63 74 69 6f 6e 29 0d 0a 09 09 09 09 09 62 57 65 ction).......bWe
0600: 4f 70 65 6e 54 72 61 6e 73 61 63 74 69 6f 6e 20 OpenTransaction
0610: 3d 20 70 44 61 74 61 44 69 63 74 2d 3e 42 65 67 = pDataDict->Beg
0620: 69 6e 54 72 61 6e 73 61 63 74 69 6f 6e 28 29 3b inTransaction();
0630: 0d 0a 09 09 09 7d 0d 0a 09 09 7d 0d 0a 09 09 61 .....}....}....a
0640: 6c 6c 52 65 61 64 65 72 43 6f 75 6e 74 2b 2b 3b llReaderCount++;
0650: 0d 0a 09 7d 0d 0a 09 76 6f 69 64 20 64 69 73 63 ...}...void disc
0660: 6f 6e 6e 65 63 74 52 65 61 64 65 72 28 72 65 63 onnectReader(rec
0670: 6f 72 64 5f 62 75 66 65 72 26 20 72 65 61 64 65 ord_bufer& reade
0680: 72 42 75 66 66 65 72 2c 20 43 54 61 62 6c 65 45 rBuffer, CTableE
0690: 78 2a 20 70 54 61 62 6c 65 2c 20 4c 50 43 53 54 x* pTable, LPCST
06a0: 52 20 70 54 61 62 6c 65 42 75 66 29 20 63 6f 6e R pTableBuf) con
06b0: 73 74 0d 0a 09 7b 0d 0a 09 09 61 6c 6c 52 65 61 st...{....allRea
06c0: 64 65 72 43 6f 75 6e 74 2d 2d 3b 0d 0a 09 09 69 derCount--;....i
06d0: 66 28 21 61 6c 6c 52 65 61 64 65 72 43 6f 75 6e f(!allReaderCoun
06e0: 74 20 26 26 20 62 57 65 4f 70 65 6e 54 72 61 6e t && bWeOpenTran
06f0: 73 61 63 74 69 6f 6e 29 0d 0a 09 09 7b 0d 0a 09 saction)....{...
0700: 09 09 70 44 61 74 61 44 69 63 74 2d 3e 45 6e 64 ..pDataDict->End
0710: 54 72 61 6e 73 61 63 74 69 6f 6e 28 28 54 72 61 Transaction((Tra
0720: 6e 73 61 63 74 69 6f 6e 43 74 6c 29 30 29 3b 0d nsactionCtl)0);.
0730: 0a 09 09 09 62 57 65 4f 70 65 6e 54 72 61 6e 73 ....bWeOpenTrans
0740: 61 63 74 69 6f 6e 20 3d 20 46 41 4c 53 45 3b 0d action = FALSE;.
0750: 0a 09 09 7d 0d 0a 09 09 69 66 28 72 65 61 64 65 ...}....if(reade
0760: 72 42 75 66 66 65 72 2e 5f 62 75 66 65 72 20 21 rBuffer._bufer !
0770: 3d 20 70 54 61 62 6c 65 42 75 66 29 09 2f 2f 20 = pTableBuf).//
0780: d3 20 fd f2 ee e3 ee 20 f7 e8 f2 e0 f2 e5 eb ff . ..... ........
0790: 20 f1 e2 ee e9 20 e1 f3 f4 e5 f0 2c 20 e0 20 ed .... ....., . .
07a0: e5 20 f2 e0 e1 eb e8 f7 ed fb e9 0d 0a 09 09 09 . ..............
07b0: 64 65 6c 65 74 65 20 5b 5d 20 72 65 61 64 65 72 delete [] reader
07c0: 42 75 66 66 65 72 2e 5f 62 75 66 65 72 3b 0d 0a Buffer._bufer;..
07d0: 09 09 69 66 28 26 72 65 61 64 65 72 42 75 66 66 ..if(&readerBuff
07e0: 65 72 20 3d 3d 20 70 46 69 72 73 74 52 65 61 64 er == pFirstRead
07f0: 65 72 42 75 66 66 65 72 29 0d 0a 09 09 09 70 46 erBuffer).....pF
0800: 69 72 73 74 52 65 61 64 65 72 42 75 66 66 65 72 irstReaderBuffer
0810: 20 3d 20 4e 55 4c 4c 3b 0d 0a 09 7d 0d 0a 0d 0a = NULL;...}....
0820: 09 76 6f 69 64 20 72 65 61 64 28 72 65 63 6f 72 .void read(recor
0830: 64 5f 62 75 66 65 72 26 20 72 65 61 64 65 72 42 d_bufer& readerB
0840: 75 66 66 65 72 2c 20 4c 50 43 53 54 52 20 70 54 uffer, LPCSTR pT
0850: 61 62 6c 65 42 75 66 2c 20 44 57 4f 52 44 20 62 ableBuf, DWORD b
0860: 75 66 4c 65 6e 29 20 63 6f 6e 73 74 0d 0a 09 7b ufLen) const...{
0870: 0d 0a 09 09 69 66 28 72 65 61 64 65 72 42 75 66 ....if(readerBuf
0880: 66 65 72 2e 5f 62 75 66 65 72 20 21 3d 20 70 54 fer._bufer != pT
0890: 61 62 6c 65 42 75 66 29 09 2f 2f 20 d3 20 fd f2 ableBuf).// . ..
08a0: ee e3 ee 20 f7 e8 f2 e0 f2 e5 eb ff 20 f1 e2 ee ... ........ ...
08b0: e9 20 e1 f3 f4 e5 f0 2c 20 e0 20 ed e5 20 f2 e0 . ....., . .. ..
08c0: e1 eb e8 f7 ed fb e9 0d 0a 09 09 09 6d 65 6d 63 ............memc
08d0: 70 79 28 72 65 61 64 65 72 42 75 66 66 65 72 2e py(readerBuffer.
08e0: 5f 62 75 66 65 72 2c 20 70 54 61 62 6c 65 42 75 _bufer, pTableBu
08f0: 66 2c 20 62 75 66 4c 65 6e 29 3b 0d 0a 09 7d 0d f, bufLen);...}.
0900: 0a 0d 0a 09 6d 75 74 61 62 6c 65 20 72 65 63 6f ....mutable reco
0910: 72 64 5f 62 75 66 65 72 2a 20 70 46 69 72 73 74 rd_bufer* pFirst
0920: 52 65 61 64 65 72 42 75 66 66 65 72 3b 0d 0a 09 ReaderBuffer;...
0930: 0d 0a 09 73 74 61 74 69 63 20 44 57 4f 52 44 20 ...static DWORD
0940: 61 6c 6c 52 65 61 64 65 72 43 6f 75 6e 74 3b 0d allReaderCount;.
0950: 0a 09 73 74 61 74 69 63 20 42 4f 4f 4c 20 62 57 ..static BOOL bW
0960: 65 4f 70 65 6e 54 72 61 6e 73 61 63 74 69 6f 6e eOpenTransaction
0970: 3b 0d 0a 09 73 74 61 74 69 63 20 42 4f 4f 4c 20 ;...static BOOL
0980: 62 4e 65 65 64 54 72 61 6e 73 61 63 74 69 6f 6e bNeedTransaction
0990: 3b 0d 0a 7d 3b 0d 0a 0d 0a 73 74 72 75 63 74 20 ;..};....struct
09a0: 72 65 61 64 5f 74 72 61 6e 5f 67 75 61 72 64 20 read_tran_guard
09b0: 0d 0a 7b 0d 0a 09 72 65 61 64 5f 74 72 61 6e 5f ..{...read_tran_
09c0: 67 75 61 72 64 28 42 4f 4f 4c 20 64 6f 49 6e 54 guard(BOOL doInT
09d0: 72 61 6e 73 61 63 74 69 6f 6e 29 0d 0a 09 7b 0d ransaction)...{.
09e0: 0a 09 09 74 61 62 6c 65 5f 72 65 61 64 65 72 3a ...table_reader:
09f0: 3a 62 4e 65 65 64 54 72 61 6e 73 61 63 74 69 6f :bNeedTransactio
0a00: 6e 20 3d 20 64 6f 49 6e 54 72 61 6e 73 61 63 74 n = doInTransact
0a10: 69 6f 6e 3b 0d 0a 09 7d 0d 0a 09 7e 72 65 61 64 ion;...}...~read
0a20: 5f 74 72 61 6e 5f 67 75 61 72 64 28 29 0d 0a 09 _tran_guard()...
0a30: 7b 0d 0a 09 09 74 61 62 6c 65 5f 72 65 61 64 65 {....table_reade
0a40: 72 3a 3a 62 4e 65 65 64 54 72 61 6e 73 61 63 74 r::bNeedTransact
0a50: 69 6f 6e 20 3d 20 46 41 4c 53 45 3b 0d 0a 09 09 ion = FALSE;....
0a60: 74 61 62 6c 65 5f 72 65 61 64 65 72 3a 3a 61 6c table_reader::al
0a70: 6c 52 65 61 64 65 72 43 6f 75 6e 74 20 3d 20 30 lReaderCount = 0
0a80: 3b 0d 0a 09 09 69 66 28 74 61 62 6c 65 5f 72 65 ;....if(table_re
0a90: 61 64 65 72 3a 3a 62 57 65 4f 70 65 6e 54 72 61 ader::bWeOpenTra
0aa0: 6e 73 61 63 74 69 6f 6e 29 0d 0a 09 09 7b 0d 0a nsaction)....{..
0ab0: 09 09 09 69 66 28 70 44 61 74 61 44 69 63 74 2d ...if(pDataDict-
0ac0: 3e 64 77 5f 34 38 29 0d 0a 09 09 09 09 70 44 61 >dw_48)......pDa
0ad0: 74 61 44 69 63 74 2d 3e 45 6e 64 54 72 61 6e 73 taDict->EndTrans
0ae0: 61 63 74 69 6f 6e 28 28 54 72 61 6e 73 61 63 74 action((Transact
0af0: 69 6f 6e 43 74 6c 29 30 29 3b 0d 0a 09 09 09 74 ionCtl)0);.....t
0b00: 61 62 6c 65 5f 72 65 61 64 65 72 3a 3a 62 57 65 able_reader::bWe
0b10: 4f 70 65 6e 54 72 61 6e 73 61 63 74 69 6f 6e 20 OpenTransaction
0b20: 3d 20 46 41 4c 53 45 3b 0d 0a 09 09 7d 0d 0a 09 = FALSE;....}...
0b30: 7d 0d 0a 7d 3b 0d 0a 0d 0a 0d 0a 63 6c 61 73 73 }..};......class
0b40: 20 43 56 74 61 62 49 6e 66 6f 3b 0d 0a 0d 0a 73 CVtabInfo;....s
0b50: 74 72 75 63 74 20 63 75 72 73 6f 72 5f 64 61 74 truct cursor_dat
0b60: 61 0d 0a 7b 0d 0a 09 63 75 72 73 6f 72 5f 64 61 a..{...cursor_da
0b70: 74 61 28 43 54 61 62 6c 65 45 78 2a 20 70 54 61 ta(CTableEx* pTa
0b80: 62 6c 65 2c 20 4c 50 43 53 54 52 20 70 52 42 29 ble, LPCSTR pRB)
0b90: 20 3a 20 73 74 6f 72 65 28 70 54 61 62 6c 65 2c : store(pTable,
0ba0: 20 4e 55 4c 4c 29 2c 20 74 61 62 6c 65 52 65 63 NULL), tableRec
0bb0: 6f 72 64 42 75 66 28 70 52 42 29 7b 7d 0d 0a 09 ordBuf(pRB){}...
0bc0: 43 53 74 6f 72 65 4f 62 6a 20 73 74 6f 72 65 3b CStoreObj store;
0bd0: 0d 0a 09 4c 50 43 53 54 52 20 74 61 62 6c 65 52 ...LPCSTR tableR
0be0: 65 63 6f 72 64 42 75 66 3b 0d 0a 09 72 65 63 6f ecordBuf;...reco
0bf0: 72 64 5f 62 75 66 65 72 20 72 65 63 6f 72 64 3b rd_bufer record;
0c00: 0d 0a 7d 3b 0d 0a 0d 0a 73 74 72 75 63 74 20 6f ..};....struct o
0c10: 6e 65 5f 66 69 65 6c 64 0d 0a 7b 0d 0a 0d 0a 09 ne_field..{.....
0c20: 63 6f 6e 73 74 20 43 53 74 72 69 6e 67 26 20 6e const CString& n
0c30: 61 6d 65 28 29 20 63 6f 6e 73 74 20 7b 72 65 74 ame() const {ret
0c40: 75 72 6e 20 6d 5f 6e 61 6d 65 3b 7d 0d 0a 09 42 urn m_name;}...B
0c50: 4f 4f 4c 20 69 73 52 65 63 4e 6f 28 29 20 63 6f OOL isRecNo() co
0c60: 6e 73 74 20 7b 72 65 74 75 72 6e 20 74 79 70 65 nst {return type
0c70: 20 3d 3d 20 66 52 65 63 4e 6f 3b 7d 0d 0a 09 42 == fRecNo;}...B
0c80: 4f 4f 4c 20 69 73 46 69 65 6c 64 28 29 20 63 6f OOL isField() co
0c90: 6e 73 74 20 7b 72 65 74 75 72 6e 20 30 20 21 3d nst {return 0 !=
0ca0: 20 28 74 79 70 65 20 26 20 28 66 46 69 65 6c 64 (type & (fField
0cb0: 7c 66 4e 75 6d 4e 65 67 61 74 65 46 69 65 6c 64 |fNumNegateField
0cc0: 29 29 3b 7d 0d 0a 09 42 4f 4f 4c 20 69 73 49 6e ));}...BOOL isIn
0cd0: 64 65 78 28 29 20 63 6f 6e 73 74 20 7b 72 65 74 dex() const {ret
0ce0: 75 72 6e 20 30 20 21 3d 20 28 74 79 70 65 20 26 urn 0 != (type &
0cf0: 20 66 56 69 72 74 49 64 78 29 3b 7d 0d 0a 09 42 fVirtIdx);}...B
0d00: 4f 4f 4c 20 69 73 4c 6e 53 74 72 28 29 20 63 6f OOL isLnStr() co
0d10: 6e 73 74 20 7b 72 65 74 75 72 6e 20 30 20 21 3d nst {return 0 !=
0d20: 20 28 74 79 70 65 20 26 20 66 4c 6f 6e 67 53 74 (type & fLongSt
0d30: 72 29 3b 7d 0d 0a 09 44 57 4f 52 44 20 70 6f 73 r);}...DWORD pos
0d40: 28 29 20 63 6f 6e 73 74 20 7b 72 65 74 75 72 6e () const {return
0d50: 20 70 6f 73 69 74 69 6f 6e 3b 7d 0d 0a 09 0d 0a position;}.....
0d60: 09 42 4f 4f 4c 20 63 61 6e 55 73 65 46 69 65 6c .BOOL canUseFiel
0d70: 64 49 6e 49 64 78 28 54 65 73 74 4f 70 20 6f 70 dInIdx(TestOp op
0d80: 29 20 63 6f 6e 73 74 0d 0a 09 7b 0d 0a 09 09 69 ) const...{....i
0d90: 66 28 6f 70 20 21 3d 20 74 6f 45 71 75 61 6c 20 f(op != toEqual
0da0: 26 26 20 28 74 79 70 65 20 26 20 66 4e 75 6d 4e && (type & fNumN
0db0: 65 67 61 74 65 46 69 65 6c 64 29 20 21 3d 20 30 egateField) != 0
0dc0: 29 0d 0a 09 09 09 72 65 74 75 72 6e 20 46 41 4c ).....return FAL
0dd0: 53 45 3b 0d 0a 09 09 72 65 74 75 72 6e 20 54 52 SE;....return TR
0de0: 55 45 3b 0d 0a 09 7d 0d 0a 09 76 6f 69 64 20 63 UE;...}...void c
0df0: 6f 6c 75 6d 6e 28 73 71 6c 69 74 65 33 5f 63 6f olumn(sqlite3_co
0e00: 6e 74 65 78 74 2a 20 70 43 74 78 2c 20 63 6f 6e ntext* pCtx, con
0e10: 73 74 20 63 75 72 73 6f 72 5f 64 61 74 61 26 20 st cursor_data&
0e20: 63 75 72 73 6f 72 2c 20 63 6f 6e 73 74 20 43 56 cursor, const CV
0e30: 74 61 62 49 6e 66 6f 26 20 74 61 62 6c 65 29 20 tabInfo& table)
0e40: 63 6f 6e 73 74 3b 0d 0a 70 72 69 76 61 74 65 3a const;..private:
0e50: 0d 0a 09 66 72 69 65 6e 64 20 63 6c 61 73 73 20 ...friend class
0e60: 43 56 74 61 62 49 6e 66 6f 3b 0d 0a 09 65 6e 75 CVtabInfo;...enu
0e70: 6d 20 66 54 79 70 65 20 7b 66 52 65 63 4e 6f 20 m fType {fRecNo
0e80: 3d 20 30 2c 20 66 46 69 65 6c 64 20 3d 20 31 2c = 0, fField = 1,
0e90: 20 66 4e 75 6d 4e 65 67 61 74 65 46 69 65 6c 64 fNumNegateField
0ea0: 20 3d 20 32 2c 20 66 56 69 72 74 49 64 78 20 3d = 2, fVirtIdx =
0eb0: 20 34 2c 20 66 4c 6f 6e 67 53 74 72 20 3d 20 38 4, fLongStr = 8
0ec0: 2c 20 7d 20 74 79 70 65 3b 0d 0a 09 44 57 4f 52 , } type;...DWOR
0ed0: 44 20 70 6f 73 69 74 69 6f 6e 3b 0d 0a 09 43 53 D position;...CS
0ee0: 74 72 69 6e 67 20 6d 5f 6e 61 6d 65 3b 0d 0a 7d tring m_name;..}
0ef0: 3b 0d 0a 0d 0a 63 6c 61 73 73 20 73 65 6c 65 63 ;....class selec
0f00: 74 5f 69 74 65 72 61 74 6f 72 0d 0a 7b 0d 0a 70 t_iterator..{..p
0f10: 75 62 6c 69 63 3a 0d 0a 09 76 69 72 74 75 61 6c ublic:...virtual
0f20: 20 7e 73 65 6c 65 63 74 5f 69 74 65 72 61 74 6f ~select_iterato
0f30: 72 28 29 7b 7d 0d 0a 09 76 69 72 74 75 61 6c 20 r(){}...virtual
0f40: 42 4f 4f 4c 20 64 6f 4e 65 78 74 28 63 75 72 73 BOOL doNext(curs
0f50: 6f 72 5f 64 61 74 61 26 20 63 75 72 73 6f 72 2c or_data& cursor,
0f60: 20 63 6f 6e 73 74 20 43 56 74 61 62 49 6e 66 6f const CVtabInfo
0f70: 26 20 74 61 62 6c 65 29 20 3d 20 30 3b 0d 0a 7d & table) = 0;..}
0f80: 3b 0d 0a 0d 0a 0d 0a 63 6c 61 73 73 20 43 56 74 ;......class CVt
0f90: 61 62 49 6e 66 6f 20 3a 20 70 75 62 6c 69 63 20 abInfo : public
0fa0: 73 71 6c 69 74 65 33 5f 76 74 61 62 0d 0a 7b 0d sqlite3_vtab..{.
0fb0: 0a 70 75 62 6c 69 63 3a 0d 0a 09 43 54 61 62 6c .public:...CTabl
0fc0: 65 45 78 2a 20 74 61 62 6c 65 28 29 09 09 09 09 eEx* table()....
0fd0: 63 6f 6e 73 74 20 7b 20 72 65 74 75 72 6e 20 6d const { return m
0fe0: 5f 70 54 61 62 6c 65 3b 20 7d 0d 0a 09 63 6f 6e _pTable; }...con
0ff0: 73 74 20 43 53 74 72 69 6e 67 26 20 74 61 62 6c st CString& tabl
1000: 65 4e 61 6d 65 28 29 09 09 63 6f 6e 73 74 20 7b eName()..const {
1010: 20 72 65 74 75 72 6e 20 6d 5f 73 74 72 54 61 62 return m_strTab
1020: 6c 65 4e 61 6d 65 3b 20 7d 0d 0a 09 63 6f 6e 73 leName; }...cons
1030: 74 20 43 53 74 72 69 6e 67 26 20 74 65 78 74 53 t CString& textS
1040: 71 6c 43 72 65 61 74 65 28 29 09 63 6f 6e 73 74 qlCreate().const
1050: 20 7b 20 72 65 74 75 72 6e 20 6d 5f 73 74 72 53 { return m_strS
1060: 71 6c 43 72 65 61 74 65 3b 20 7d 0d 0a 09 63 6f qlCreate; }...co
1070: 6e 73 74 20 70 68 69 73 69 63 61 6c 5f 69 6e 66 nst phisical_inf
1080: 6f 26 20 70 68 69 73 49 6e 66 6f 28 29 09 63 6f o& phisInfo().co
1090: 6e 73 74 20 7b 20 72 65 74 75 72 6e 20 2a 6d 5f nst { return *m_
10a0: 70 68 69 73 49 6e 66 6f 3b 20 7d 0d 0a 09 63 6f phisInfo; }...co
10b0: 6e 73 74 20 6f 6e 65 5f 66 69 65 6c 64 26 20 66 nst one_field& f
10c0: 69 65 6c 64 28 44 57 4f 52 44 20 69 64 78 29 63 ield(DWORD idx)c
10d0: 6f 6e 73 74 7b 20 72 65 74 75 72 6e 20 6d 5f 70 onst{ return m_p
10e0: 46 69 65 6c 64 73 5b 69 64 78 5d 3b 20 7d 0d 0a Fields[idx]; }..
10f0: 09 73 74 61 74 69 63 20 63 6f 6e 73 74 20 43 53 .static const CS
1100: 74 72 69 6e 67 26 20 6c 61 73 74 45 72 72 6f 72 tring& lastError
1110: 28 29 09 20 20 7b 20 72 65 74 75 72 6e 20 6d 5f (). { return m_
1120: 6c 61 73 74 45 72 72 6f 72 3b 20 7d 0d 0a 0d 0a lastError; }....
1130: 09 69 6e 74 20 62 65 73 74 49 6e 64 65 78 28 73 .int bestIndex(s
1140: 71 6c 69 74 65 33 5f 69 6e 64 65 78 5f 69 6e 66 qlite3_index_inf
1150: 6f 2a 20 70 49 64 78 29 20 63 6f 6e 73 74 3b 0d o* pIdx) const;.
1160: 0a 0d 0a 09 76 6f 69 64 20 62 65 67 69 6e 52 65 ....void beginRe
1170: 61 64 28 72 65 63 6f 72 64 5f 62 75 66 65 72 26 ad(record_bufer&
1180: 20 62 75 66 65 72 29 20 63 6f 6e 73 74 0d 0a 09 bufer) const...
1190: 7b 0d 0a 09 09 6d 5f 74 61 62 6c 65 52 65 61 64 {....m_tableRead
11a0: 65 72 2e 63 6f 6e 6e 65 63 74 52 65 61 64 65 72 er.connectReader
11b0: 28 62 75 66 65 72 2c 20 6d 5f 70 54 61 62 6c 65 (bufer, m_pTable
11c0: 2c 20 6d 5f 70 68 69 73 49 6e 66 6f 2d 3e 74 61 , m_phisInfo->ta
11d0: 62 6c 65 52 65 61 64 42 75 66 65 72 28 29 2c 20 bleReadBufer(),
11e0: 6d 5f 70 68 69 73 49 6e 66 6f 2d 3e 72 65 63 6f m_phisInfo->reco
11f0: 72 64 53 69 7a 65 28 29 29 3b 0d 0a 09 7d 0d 0a rdSize());...}..
1200: 09 76 6f 69 64 20 64 6f 6e 65 52 65 61 64 28 72 .void doneRead(r
1210: 65 63 6f 72 64 5f 62 75 66 65 72 26 20 62 75 66 ecord_bufer& buf
1220: 65 72 29 20 63 6f 6e 73 74 0d 0a 09 7b 0d 0a 09 er) const...{...
1230: 09 6d 5f 74 61 62 6c 65 52 65 61 64 65 72 2e 64 .m_tableReader.d
1240: 69 73 63 6f 6e 6e 65 63 74 52 65 61 64 65 72 28 isconnectReader(
1250: 62 75 66 65 72 2c 20 6d 5f 70 54 61 62 6c 65 2c bufer, m_pTable,
1260: 20 6d 5f 70 68 69 73 49 6e 66 6f 2d 3e 74 61 62 m_phisInfo->tab
1270: 6c 65 52 65 61 64 42 75 66 65 72 28 29 29 3b 0d leReadBufer());.
1280: 0a 09 7d 0d 0a 09 76 6f 69 64 20 73 74 6f 72 65 ..}...void store
1290: 52 65 63 6f 72 64 28 63 75 72 73 6f 72 5f 64 61 Record(cursor_da
12a0: 74 61 26 20 64 61 74 61 29 20 63 6f 6e 73 74 0d ta& data) const.
12b0: 0a 09 7b 0d 0a 09 09 6d 5f 74 61 62 6c 65 52 65 ..{....m_tableRe
12c0: 61 64 65 72 2e 72 65 61 64 28 64 61 74 61 2e 72 ader.read(data.r
12d0: 65 63 6f 72 64 2c 20 6d 5f 70 68 69 73 49 6e 66 ecord, m_phisInf
12e0: 6f 2d 3e 74 61 62 6c 65 52 65 61 64 42 75 66 65 o->tableReadBufe
12f0: 72 28 29 2c 20 6d 5f 70 68 69 73 49 6e 66 6f 2d r(), m_phisInfo-
1300: 3e 72 65 63 6f 72 64 53 69 7a 65 28 29 29 3b 0d >recordSize());.
1310: 0a 09 7d 0d 0a 09 0d 0a 09 69 6e 74 20 6f 70 65 ..}......int ope
1320: 6e 43 75 72 73 6f 72 28 73 71 6c 69 74 65 33 5f nCursor(sqlite3_
1330: 76 74 61 62 5f 63 75 72 73 6f 72 20 2a 2a 70 70 vtab_cursor **pp
1340: 43 75 72 73 6f 72 29 3b 0d 0a 09 2f 2f 20 cf ee Cursor);...// ..
1350: eb f3 f7 e8 f2 fc 20 fd ea e7 e5 ec ef eb ff f0 ...... .........
1360: 20 43 56 74 61 62 49 6e 66 6f 20 ef ee 20 ef e5 CVtabInfo .. ..
1370: f0 e5 e4 e0 ed ed ee ec f3 20 ef ee eb fc e7 ee ......... ......
1380: e2 e0 f2 e5 eb fc f1 ea ee ec f3 20 e8 ec e5 ed ........... ....
1390: e8 0d 0a 09 2f 2f 20 28 d1 ef f0 e0 e2 ee f7 ed ....// (........
13a0: e8 ea 2e d2 e0 ea ee e9 d2 ee 20 e8 20 f2 ef 29 .......... . ..)
13b0: 0d 0a 09 73 74 61 74 69 63 20 43 56 74 61 62 49 ...static CVtabI
13c0: 6e 66 6f 2a 20 74 61 62 49 6e 66 6f 46 6f 72 4e nfo* tabInfoForN
13d0: 61 6d 65 28 63 6f 6e 73 74 20 43 53 74 72 69 6e ame(const CStrin
13e0: 67 26 20 73 74 72 55 73 65 72 4e 61 6d 65 29 3b g& strUserName);
13f0: 0d 0a 09 73 74 61 74 69 63 20 76 6f 69 64 20 64 ...static void d
1400: 6f 6e 65 57 6f 72 6b 28 29 3b 0d 0a 0d 0a 70 72 oneWork();....pr
1410: 6f 74 65 63 74 65 64 3a 0d 0a 09 43 56 74 61 62 otected:...CVtab
1420: 49 6e 66 6f 28 29 20 3a 20 6d 5f 70 54 61 62 6c Info() : m_pTabl
1430: 65 28 4e 55 4c 4c 29 2c 20 6d 5f 70 68 69 73 49 e(NULL), m_phisI
1440: 6e 66 6f 28 4e 55 4c 4c 29 2c 20 6d 5f 70 46 69 nfo(NULL), m_pFi
1450: 65 6c 64 73 28 4e 55 4c 4c 29 0d 0a 09 7b 0d 0a elds(NULL)...{..
1460: 09 09 7a 45 72 72 4d 73 67 20 3d 20 4e 55 4c 4c ..zErrMsg = NULL
1470: 3b 0d 0a 09 7d 0d 0a 09 76 69 72 74 75 61 6c 20 ;...}...virtual
1480: 7e 43 56 74 61 62 49 6e 66 6f 28 29 0d 0a 09 7b ~CVtabInfo()...{
1490: 0d 0a 09 09 64 65 6c 65 74 65 20 6d 5f 70 68 69 ....delete m_phi
14a0: 73 49 6e 66 6f 3b 0d 0a 09 09 69 66 28 6d 5f 70 sInfo;....if(m_p
14b0: 46 69 65 6c 64 73 29 0d 0a 09 09 09 64 65 6c 65 Fields).....dele
14c0: 74 65 20 5b 5d 20 28 6d 5f 70 46 69 65 6c 64 73 te [] (m_pFields
14d0: 20 2d 20 31 29 3b 0d 0a 09 7d 0d 0a 0d 0a 09 43 - 1);...}.....C
14e0: 56 74 61 62 49 6e 66 6f 28 63 6f 6e 73 74 20 43 VtabInfo(const C
14f0: 56 74 61 62 49 6e 66 6f 26 29 20 7b 7d 0d 0a 09 VtabInfo&) {}...
1500: 43 56 74 61 62 49 6e 66 6f 26 20 6f 70 65 72 61 CVtabInfo& opera
1510: 74 6f 72 20 3d 20 28 63 6f 6e 73 74 20 43 56 74 tor = (const CVt
1520: 61 62 49 6e 66 6f 26 29 20 7b 7d 0d 0a 09 0d 0a abInfo&) {}.....
1530: 09 73 74 61 74 69 63 20 76 6f 69 64 20 73 65 74 .static void set
1540: 45 72 72 6f 72 28 4c 50 43 53 54 52 20 73 74 72 Error(LPCSTR str
1550: 46 6f 72 6d 61 74 2c 20 2e 2e 2e 29 0d 0a 09 7b Format, ...)...{
1560: 0d 0a 09 09 76 61 5f 6c 69 73 74 20 61 72 67 3b ....va_list arg;
1570: 0d 0a 09 09 76 61 5f 73 74 61 72 74 28 61 72 67 ....va_start(arg
1580: 2c 20 73 74 72 46 6f 72 6d 61 74 29 3b 0d 0a 09 , strFormat);...
1590: 09 6d 5f 6c 61 73 74 45 72 72 6f 72 2e 46 6f 72 .m_lastError.For
15a0: 6d 61 74 56 28 73 74 72 46 6f 72 6d 61 74 2c 20 matV(strFormat,
15b0: 61 72 67 29 3b 0d 0a 09 7d 0d 0a 09 73 74 61 74 arg);...}...stat
15c0: 69 63 20 76 6f 69 64 20 66 69 6c 6c 4e 61 6d 65 ic void fillName
15d0: 73 46 72 6f 6d 4f 62 6a 73 28 43 4d 65 74 61 44 sFromObjs(CMetaD
15e0: 61 74 61 4f 62 6a 41 72 72 61 79 2a 20 61 72 72 ataObjArray* arr
15f0: 2c 20 43 4e 6f 43 61 73 65 4d 61 70 3c 43 53 74 , CNoCaseMap<CSt
1600: 72 69 6e 67 3e 26 20 61 6c 69 61 63 65 73 2c 20 ring>& aliaces,
1610: 43 44 57 6f 72 64 41 72 72 61 79 2a 20 6c 6f 6e CDWordArray* lon
1620: 67 53 74 72 20 3d 20 4e 55 4c 4c 29 3b 0d 0a 09 gStr = NULL);...
1630: 66 72 69 65 6e 64 20 73 74 72 75 63 74 20 74 61 friend struct ta
1640: 62 5f 64 65 6c 65 74 65 72 3b 0d 0a 0d 0a 09 0d b_deleter;......
1650: 0a 09 76 6f 69 64 20 66 69 6c 6c 54 61 62 49 6e ..void fillTabIn
1660: 66 6f 28 43 4e 6f 43 61 73 65 4d 61 70 3c 43 53 fo(CNoCaseMap<CS
1670: 74 72 69 6e 67 3e 26 20 61 6c 69 61 63 65 73 2c tring>& aliaces,
1680: 20 43 44 57 6f 72 64 41 72 72 61 79 2a 20 6c 6f CDWordArray* lo
1690: 6e 67 53 74 72 20 3d 20 4e 55 4c 4c 29 3b 0d 0a ngStr = NULL);..
16a0: 0d 0a 09 73 74 61 74 69 63 20 43 4e 6f 43 61 73 ...static CNoCas
16b0: 65 4d 61 70 3c 43 56 74 61 62 49 6e 66 6f 2a 3e eMap<CVtabInfo*>
16c0: 20 6d 5f 61 6c 6c 54 61 62 73 3b 0d 0a 09 73 74 m_allTabs;...st
16d0: 61 74 69 63 20 43 53 74 72 69 6e 67 20 6d 5f 6c atic CString m_l
16e0: 61 73 74 45 72 72 6f 72 3b 0d 0a 0d 0a 09 43 53 astError;.....CS
16f0: 74 72 69 6e 67 20 6d 5f 73 74 72 54 61 62 6c 65 tring m_strTable
1700: 4e 61 6d 65 3b 0d 0a 09 43 53 74 72 69 6e 67 20 Name;...CString
1710: 6d 5f 73 74 72 53 71 6c 43 72 65 61 74 65 3b 0d m_strSqlCreate;.
1720: 0a 09 43 54 61 62 6c 65 45 78 2a 20 6d 5f 70 54 ..CTableEx* m_pT
1730: 61 62 6c 65 3b 0d 0a 09 0d 0a 09 70 68 69 73 69 able;......phisi
1740: 63 61 6c 5f 69 6e 66 6f 2a 20 6d 5f 70 68 69 73 cal_info* m_phis
1750: 49 6e 66 6f 3b 0d 0a 09 6f 6e 65 5f 66 69 65 6c Info;...one_fiel
1760: 64 2a 20 6d 5f 70 46 69 65 6c 64 73 3b 0d 0a 09 d* m_pFields;...
1770: 74 61 62 6c 65 5f 72 65 61 64 65 72 20 6d 5f 74 table_reader m_t
1780: 61 62 6c 65 52 65 61 64 65 72 3b 0d 0a 09 6d 75 ableReader;...mu
1790: 74 61 62 6c 65 20 53 74 72 61 74 65 67 79 43 61 table StrategyCa
17a0: 73 68 20 73 74 72 61 74 43 61 73 68 3b 0d 0a 09 sh stratCash;...
17b0: 44 57 4f 52 44 20 6c 6f 67 52 6f 77 43 6f 75 6e DWORD logRowCoun
17c0: 74 3b 0d 0a 7d 3b 0d 0a 0d 0a 63 6c 61 73 73 20 t;..};....class
17d0: 43 75 72 73 6f 72 49 6d 70 6c 20 3a 20 70 75 62 CursorImpl : pub
17e0: 6c 69 63 20 73 71 6c 69 74 65 33 5f 76 74 61 62 lic sqlite3_vtab
17f0: 5f 63 75 72 73 6f 72 0d 0a 7b 0d 0a 70 75 62 6c _cursor..{..publ
1800: 69 63 3a 0d 0a 09 42 4f 4f 4c 20 49 73 45 6f 66 ic:...BOOL IsEof
1810: 28 29 20 7b 72 65 74 75 72 6e 20 6d 5f 70 49 74 () {return m_pIt
1820: 65 72 61 74 6f 72 20 3d 3d 20 4e 55 4c 4c 3b 20 erator == NULL;
1830: 7d 0d 0a 09 0d 0a 09 69 6e 74 20 52 6f 77 49 44 }......int RowID
1840: 28 73 71 6c 69 74 65 33 5f 69 6e 74 36 34 20 2a (sqlite3_int64 *
1850: 70 52 6f 77 69 64 29 0d 0a 09 7b 0d 0a 09 09 69 pRowid)...{....i
1860: 66 28 6d 5f 70 49 74 65 72 61 74 6f 72 29 0d 0a f(m_pIterator)..
1870: 09 09 7b 0d 0a 09 09 09 2a 70 52 6f 77 69 64 20 ..{.....*pRowid
1880: 3d 20 6d 5f 64 61 74 61 2e 73 74 6f 72 65 2e 6d = m_data.store.m
1890: 5f 70 6f 73 3b 0d 0a 09 09 09 72 65 74 75 72 6e _pos;.....return
18a0: 20 53 51 4c 49 54 45 5f 4f 4b 3b 0d 0a 09 09 7d SQLITE_OK;....}
18b0: 0d 0a 09 09 72 65 74 75 72 6e 20 53 51 4c 49 54 ....return SQLIT
18c0: 45 5f 45 52 52 4f 52 3b 0d 0a 09 7d 0d 0a 09 69 E_ERROR;...}...i
18d0: 6e 74 20 4e 65 78 74 28 29 0d 0a 09 7b 0d 0a 09 nt Next()...{...
18e0: 09 69 66 28 6d 5f 70 49 74 65 72 61 74 6f 72 29 .if(m_pIterator)
18f0: 0d 0a 09 09 7b 0d 0a 09 09 09 69 66 28 6d 5f 70 ....{.....if(m_p
1900: 49 74 65 72 61 74 6f 72 2d 3e 64 6f 4e 65 78 74 Iterator->doNext
1910: 28 6d 5f 64 61 74 61 2c 20 74 61 62 6c 65 28 29 (m_data, table()
1920: 29 29 0d 0a 09 09 09 09 74 61 62 6c 65 28 29 2e ))......table().
1930: 73 74 6f 72 65 52 65 63 6f 72 64 28 6d 5f 64 61 storeRecord(m_da
1940: 74 61 29 3b 0d 0a 09 09 09 65 6c 73 65 0d 0a 09 ta);.....else...
1950: 09 09 7b 0d 0a 09 09 09 09 64 65 6c 65 74 65 20 ..{......delete
1960: 6d 5f 70 49 74 65 72 61 74 6f 72 3b 0d 0a 09 09 m_pIterator;....
1970: 09 09 6d 5f 70 49 74 65 72 61 74 6f 72 20 3d 20 ..m_pIterator =
1980: 4e 55 4c 4c 3b 0d 0a 09 09 09 09 74 61 62 6c 65 NULL;......table
1990: 28 29 2e 64 6f 6e 65 52 65 61 64 28 6d 5f 64 61 ().doneRead(m_da
19a0: 74 61 2e 72 65 63 6f 72 64 29 3b 0d 0a 09 09 09 ta.record);.....
19b0: 7d 0d 0a 09 09 7d 0d 0a 09 09 72 65 74 75 72 6e }....}....return
19c0: 20 53 51 4c 49 54 45 5f 4f 4b 3b 0d 0a 09 7d 0d SQLITE_OK;...}.
19d0: 0a 09 76 6f 69 64 20 43 6c 6f 73 65 28 29 0d 0a ..void Close()..
19e0: 09 7b 0d 0a 09 09 64 65 6c 65 74 65 20 74 68 69 .{....delete thi
19f0: 73 3b 0d 0a 09 7d 0d 0a 09 0d 0a 09 69 6e 74 20 s;...}......int
1a00: 46 69 6c 74 65 72 28 69 6e 74 20 69 64 78 4e 75 Filter(int idxNu
1a10: 6d 2c 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 73 m, const char *s
1a20: 74 72 2c 20 69 6e 74 2c 20 73 71 6c 69 74 65 33 tr, int, sqlite3
1a30: 5f 76 61 6c 75 65 20 2a 2a 61 72 67 76 29 0d 0a _value **argv)..
1a40: 09 7b 0d 0a 09 09 74 61 62 6c 65 28 29 2e 62 65 .{....table().be
1a50: 67 69 6e 52 65 61 64 28 6d 5f 64 61 74 61 2e 72 ginRead(m_data.r
1a60: 65 63 6f 72 64 29 3b 0d 0a 0d 0a 09 09 69 66 28 ecord);......if(
1a70: 6d 5f 70 49 74 65 72 61 74 6f 72 20 3d 20 46 69 m_pIterator = Fi
1a80: 6c 74 65 72 4d 61 63 68 69 6e 65 3a 3a 70 61 72 lterMachine::par
1a90: 73 65 46 69 6c 74 65 72 28 6d 5f 64 61 74 61 2c seFilter(m_data,
1aa0: 20 74 61 62 6c 65 28 29 2c 20 73 74 72 2c 20 61 table(), str, a
1ab0: 72 67 76 29 29 0d 0a 09 09 09 74 61 62 6c 65 28 rgv)).....table(
1ac0: 29 2e 73 74 6f 72 65 52 65 63 6f 72 64 28 6d 5f ).storeRecord(m_
1ad0: 64 61 74 61 29 3b 0d 0a 09 09 65 6c 73 65 0d 0a data);....else..
1ae0: 09 09 09 74 61 62 6c 65 28 29 2e 64 6f 6e 65 52 ...table().doneR
1af0: 65 61 64 28 6d 5f 64 61 74 61 2e 72 65 63 6f 72 ead(m_data.recor
1b00: 64 29 3b 0d 0a 09 09 0d 0a 09 09 72 65 74 75 72 d);........retur
1b10: 6e 20 53 51 4c 49 54 45 5f 4f 4b 3b 0d 0a 09 7d n SQLITE_OK;...}
1b20: 0d 0a 09 69 6e 74 20 43 6f 6c 75 6d 6e 28 73 71 ...int Column(sq
1b30: 6c 69 74 65 33 5f 63 6f 6e 74 65 78 74 2a 20 70 lite3_context* p
1b40: 43 74 78 2c 20 69 6e 74 20 6e 43 6f 6c 29 0d 0a Ctx, int nCol)..
1b50: 09 7b 0d 0a 09 09 74 61 62 6c 65 28 29 2e 66 69 .{....table().fi
1b60: 65 6c 64 28 6e 43 6f 6c 29 2e 63 6f 6c 75 6d 6e eld(nCol).column
1b70: 28 70 43 74 78 2c 20 6d 5f 64 61 74 61 2c 20 74 (pCtx, m_data, t
1b80: 61 62 6c 65 28 29 29 3b 0d 0a 09 09 72 65 74 75 able());....retu
1b90: 72 6e 20 53 51 4c 49 54 45 5f 4f 4b 3b 0d 0a 09 rn SQLITE_OK;...
1ba0: 7d 0d 0a 0d 0a 70 72 6f 74 65 63 74 65 64 3a 0d }....protected:.
1bb0: 0a 09 66 72 69 65 6e 64 20 43 56 74 61 62 49 6e ..friend CVtabIn
1bc0: 66 6f 3b 0d 0a 09 43 75 72 73 6f 72 49 6d 70 6c fo;...CursorImpl
1bd0: 28 43 56 74 61 62 49 6e 66 6f 2a 20 70 54 61 62 (CVtabInfo* pTab
1be0: 29 20 3a 20 6d 5f 64 61 74 61 28 70 54 61 62 2d ) : m_data(pTab-
1bf0: 3e 74 61 62 6c 65 28 29 2c 20 70 54 61 62 2d 3e >table(), pTab->
1c00: 70 68 69 73 49 6e 66 6f 28 29 2e 74 61 62 6c 65 phisInfo().table
1c10: 52 65 61 64 42 75 66 65 72 28 29 29 2c 20 6d 5f ReadBufer()), m_
1c20: 70 49 74 65 72 61 74 6f 72 28 4e 55 4c 4c 29 0d pIterator(NULL).
1c30: 0a 09 7b 0d 0a 09 09 70 56 74 61 62 20 3d 20 70 ..{....pVtab = p
1c40: 54 61 62 3b 0d 0a 09 7d 0d 0a 09 7e 43 75 72 73 Tab;...}...~Curs
1c50: 6f 72 49 6d 70 6c 28 29 0d 0a 09 7b 0d 0a 09 09 orImpl()...{....
1c60: 69 66 28 6d 5f 70 49 74 65 72 61 74 6f 72 29 0d if(m_pIterator).
1c70: 0a 09 09 7b 0d 0a 09 09 09 2f 2f 20 cd e0 f1 20 ...{.....// ...
1c80: e7 e0 ea f0 fb e2 e0 fe f2 2c 20 ed e5 20 ef f0 ........., .. ..
1c90: ee ea e0 f7 e0 e2 20 e4 ee 20 ea ee ed f6 e0 2c ...... .. .....,
1ca0: 20 ec ee e6 e5 f2 20 f2 e0 ec 20 6c 69 6d 69 74 ..... ... limit
1cb0: 20 f1 f2 ee ff eb ee 0d 0a 09 09 09 74 61 62 6c ...........tabl
1cc0: 65 28 29 2e 64 6f 6e 65 52 65 61 64 28 6d 5f 64 e().doneRead(m_d
1cd0: 61 74 61 2e 72 65 63 6f 72 64 29 3b 0d 0a 09 09 ata.record);....
1ce0: 09 64 65 6c 65 74 65 20 6d 5f 70 49 74 65 72 61 .delete m_pItera
1cf0: 74 6f 72 3b 0d 0a 09 09 7d 0d 0a 09 7d 0d 0a 09 tor;....}...}...
1d00: 63 6f 6e 73 74 20 43 56 74 61 62 49 6e 66 6f 26 const CVtabInfo&
1d10: 20 74 61 62 6c 65 28 29 20 7b 72 65 74 75 72 6e table() {return
1d20: 20 2a 73 74 61 74 69 63 5f 63 61 73 74 3c 43 56 *static_cast<CV
1d30: 74 61 62 49 6e 66 6f 2a 3e 28 70 56 74 61 62 29 tabInfo*>(pVtab)
1d40: 3b 7d 0d 0a 09 63 75 72 73 6f 72 5f 64 61 74 61 ;}...cursor_data
1d50: 20 6d 5f 64 61 74 61 3b 0d 0a 09 73 65 6c 65 63 m_data;...selec
1d60: 74 5f 69 74 65 72 61 74 6f 72 2a 20 6d 5f 70 49 t_iterator* m_pI
1d70: 74 65 72 61 74 6f 72 3b 0d 0a 7d 3b 0d 0a 0d 0a terator;..};....
1d80: 69 6e 6c 69 6e 65 20 69 6e 74 20 43 56 74 61 62 inline int CVtab
1d90: 49 6e 66 6f 3a 3a 6f 70 65 6e 43 75 72 73 6f 72 Info::openCursor
1da0: 28 73 71 6c 69 74 65 33 5f 76 74 61 62 5f 63 75 (sqlite3_vtab_cu
1db0: 72 73 6f 72 20 2a 2a 70 70 43 75 72 73 6f 72 29 rsor **ppCursor)
1dc0: 0d 0a 7b 0d 0a 09 2a 70 70 43 75 72 73 6f 72 20 ..{...*ppCursor
1dd0: 3d 20 6e 65 77 20 43 75 72 73 6f 72 49 6d 70 6c = new CursorImpl
1de0: 28 74 68 69 73 29 3b 0d 0a 09 72 65 74 75 72 6e (this);...return
1df0: 20 53 51 4c 49 54 45 5f 4f 4b 3b 09 0d 0a 7d 0d SQLITE_OK;...}.
1e00: 0a 0d 0a 0d 0a 23 64 65 66 69 6e 65 20 46 49 4e .....#define FIN
1e10: 44 5f 49 4e 46 4f 28 70 31 2c 20 70 32 2c 20 70 D_INFO(p1, p2, p
1e20: 33 29 5c 0d 0a 73 74 61 74 69 63 20 76 6f 69 64 3)\..static void
1e30: 20 47 65 74 46 69 6e 64 49 6e 66 6f 28 4c 50 43 GetFindInfo(LPC
1e40: 53 54 52 26 20 6e 31 2c 20 4c 50 43 53 54 52 26 STR& n1, LPCSTR&
1e50: 20 6e 32 29 7b 6e 31 20 3d 20 70 31 3b 20 6e 32 n2){n1 = p1; n2
1e60: 3d 70 32 3b 7d 5c 0d 0a 73 74 61 74 69 63 20 4c =p2;}\..static L
1e70: 50 43 53 54 52 20 47 65 74 50 72 65 66 69 78 28 PCSTR GetPrefix(
1e80: 29 20 7b 72 65 74 75 72 6e 20 70 33 3b 7d 5c 0d ) {return p3;}\.
1e90: 0a 76 6f 69 64 20 46 72 65 65 28 29 7b 64 65 6c .void Free(){del
1ea0: 65 74 65 20 74 68 69 73 3b 7d 0d 0a 0d 0a 0d 0a ete this;}......