Hex Artifact Content Вы: nobody
Вход

Artifact 3d8c62d21af96c457ae40b6866caaa122af76ee3:


0000: 2f 2f 20 63 74 78 74 72 65 65 2e 68 0d 0a 23 70  // ctxtree.h..#p
0010: 72 61 67 6d 61 20 6f 6e 63 65 0d 0a 0d 0a 2f 2f  ragma once....//
0020: 20 c7 e0 e3 ee eb ee e2 ee ea 20 e8 ed f2 e5 f0   ......... .....
0030: f4 e5 e9 f1 e0 20 e4 eb ff 20 ee e1 f5 ee e4 e0  ..... ... ......
0040: 20 e4 f0 e5 e2 ee e2 e8 e4 ed ee e9 20 f1 f2 f0   ........... ...
0050: f3 ea f2 f3 f0 fb 20 ee e1 fa e5 ea f2 ee e2 2e  ...... .........
0060: 0d 0a 2f 2f 20 c2 e0 f8 20 ea eb e0 f1 f1 2c 20  ..// ... ....., 
0070: f0 e5 e0 eb e8 e7 f3 fe f9 e8 e9 20 43 42 4c 43  ........... CBLC
0080: 6f 6e 74 65 78 74 2c 20 e4 ee eb e6 e5 ed 20 f0  ontext, ...... .
0090: e5 e0 eb e8 e7 ee e2 e0 f2 fc 20 e8 20 fd f2 ee  .......... . ...
00a0: f2 20 e8 ed f2 e5 f0 f4 e5 e9 f1 2e 0d 0a 73 74  . ............st
00b0: 72 75 63 74 20 49 43 6f 6e 74 65 78 74 54 72 65  ruct IContextTre
00c0: 65 0d 0a 7b 0d 0a 09 2f 2f 20 cf ee eb f3 f7 e8  e..{...// ......
00d0: f2 fc 20 ea ee eb e8 f7 e5 f1 f2 e2 ee 20 e1 e0  .. .......... ..
00e0: e7 ee e2 fb f5 20 ee e1 fa e5 ea f2 ee e2 2e 0d  ..... ..........
00f0: 0a 09 76 69 72 74 75 61 6c 20 44 57 4f 52 44 20  ..virtual DWORD 
0100: 47 65 74 42 61 73 65 4f 62 6a 43 6f 75 6e 74 28  GetBaseObjCount(
0110: 29 20 3d 20 30 3b 0d 0a 09 2f 2f 20 cf ee eb f3  ) = 0;...// ....
0120: f7 e8 f2 fc 20 e8 ec ff 20 e1 e0 e7 ee e2 ee e3  .... ... .......
0130: ee 20 ee e1 fa e5 ea f2 e0 20 ef ee 20 e8 ed e4  . ....... .. ...
0140: e5 ea f1 f3 2e 0d 0a 09 76 69 72 74 75 61 6c 20  ........virtual 
0150: 43 53 74 72 69 6e 67 20 47 65 74 42 61 73 65 4f  CString GetBaseO
0160: 62 6a 4e 61 6d 65 28 44 57 4f 52 44 20 69 64 78  bjName(DWORD idx
0170: 29 20 3d 20 30 3b 0d 0a 09 2f 2f 20 cf ee eb f3  ) = 0;...// ....
0180: f7 e8 f2 fc 20 e1 e0 e7 ee e2 fb e9 20 ee e1 fa  .... ....... ...
0190: e5 ea f2 20 ef ee 20 e8 ed e4 e5 ea f1 f3 2e 0d  ... .. .........
01a0: 0a 09 76 69 72 74 75 61 6c 20 43 42 4c 43 6f 6e  ..virtual CBLCon
01b0: 74 65 78 74 2a 20 47 65 74 42 61 73 65 4f 62 6a  text* GetBaseObj
01c0: 28 44 57 4f 52 44 20 69 64 78 29 20 3d 20 30 3b  (DWORD idx) = 0;
01d0: 0d 0a 09 2f 2f 20 c4 eb ff 20 75 70 63 61 73 74  ...// ... upcast
01e0: 27 e0 0d 0a 09 76 69 72 74 75 61 6c 20 43 42 4c  '....virtual CBL
01f0: 43 6f 6e 74 65 78 74 2a 20 47 65 74 44 65 72 69  Context* GetDeri
0200: 76 65 64 4f 62 6a 28 29 20 3d 20 30 3b 0d 0a 7d  vedObj() = 0;..}
0210: 3b 0d 0a 0d 0a 2f 2f 20 cd e0 e1 ee f0 20 f0 e0  ;....// ..... ..
0220: e7 eb e8 f7 ed fb f5 20 ec e5 f2 ee e4 ee e2 20  ....... ....... 
0230: ef f0 e8 e2 e5 e4 e5 ed e8 ff 20 ea ee ed f2 e5  .......... .....
0240: ea f1 f2 ee e2 0d 0a 73 74 72 75 63 74 20 43 61  .......struct Ca
0250: 73 74 43 6f 6e 74 65 78 74 0d 0a 7b 0d 0a 09 2f  stContext..{.../
0260: 2f 20 ce e1 f9 e0 ff 20 f0 e5 e0 eb e8 e7 e0 f6  / ..... ........
0270: e8 ff 20 ee e1 f5 ee e4 e0 20 e4 e5 f0 e5 e2 e0  .. ...... ......
0280: 20 f1 20 ef f0 ee e2 e5 f0 ea ee e9 20 f3 e7 eb   . ......... ...
0290: ee e2 20 ef e5 f0 e5 e4 e0 e2 e0 e5 ec fb ec 20  .. ............ 
02a0: f4 f3 ed ea f2 ee f0 ee ec 0d 0a 09 74 65 6d 70  ............temp
02b0: 6c 61 74 65 3c 74 79 70 65 6e 61 6d 65 20 4f 70  late<typename Op
02c0: 3e 0d 0a 09 73 74 61 74 69 63 20 43 42 4c 43 6f  >...static CBLCo
02d0: 6e 74 65 78 74 2a 20 44 6f 43 61 73 74 28 43 42  ntext* DoCast(CB
02e0: 4c 43 6f 6e 74 65 78 74 2a 20 70 43 6f 6e 74 2c  LContext* pCont,
02f0: 20 4f 70 26 20 6f 70 29 0d 0a 09 7b 0d 0a 09 09   Op& op)...{....
0300: 69 66 28 6f 70 2e 43 68 65 63 6b 43 6f 6e 74 65  if(op.CheckConte
0310: 78 74 28 70 43 6f 6e 74 29 29 0d 0a 09 09 09 72  xt(pCont)).....r
0320: 65 74 75 72 6e 20 70 43 6f 6e 74 3b 0d 0a 09 09  eturn pCont;....
0330: 49 43 6f 6e 74 65 78 74 54 72 65 65 2a 20 70 54  IContextTree* pT
0340: 72 65 65 3b 0d 0a 09 09 74 72 79 7b 0d 0a 09 09  ree;....try{....
0350: 09 69 66 28 21 28 70 54 72 65 65 20 3d 20 64 79  .if(!(pTree = dy
0360: 6e 61 6d 69 63 5f 63 61 73 74 3c 49 43 6f 6e 74  namic_cast<ICont
0370: 65 78 74 54 72 65 65 2a 3e 28 70 43 6f 6e 74 29  extTree*>(pCont)
0380: 29 29 0d 0a 09 09 09 09 72 65 74 75 72 6e 20 4e  ))......return N
0390: 55 4c 4c 3b 0d 0a 09 09 7d 63 61 74 63 68 28 2e  ULL;....}catch(.
03a0: 2e 2e 29 7b 20 72 65 74 75 72 6e 20 4e 55 4c 4c  ..){ return NULL
03b0: 3b 20 7d 0d 0a 09 09 0d 0a 09 09 66 6f 72 28 44  ; }........for(D
03c0: 57 4f 52 44 20 69 64 78 20 3d 20 30 2c 20 6e 42  WORD idx = 0, nB
03d0: 61 73 65 73 20 3d 20 70 54 72 65 65 2d 3e 47 65  ases = pTree->Ge
03e0: 74 42 61 73 65 4f 62 6a 43 6f 75 6e 74 28 29 3b  tBaseObjCount();
03f0: 20 69 64 78 20 3c 20 6e 42 61 73 65 73 20 3b 20   idx < nBases ; 
0400: 69 64 78 2b 2b 29 0d 0a 09 09 7b 0d 0a 09 09 09  idx++)....{.....
0410: 43 42 4c 43 6f 6e 74 65 78 74 2a 20 70 42 61 73  CBLContext* pBas
0420: 65 4f 62 6a 20 3d 20 70 54 72 65 65 2d 3e 47 65  eObj = pTree->Ge
0430: 74 42 61 73 65 4f 62 6a 28 69 64 78 29 3b 0d 0a  tBaseObj(idx);..
0440: 09 09 09 69 66 28 6f 70 2e 43 68 65 63 6b 42 61  ...if(op.CheckBa
0450: 73 65 28 70 54 72 65 65 2c 20 69 64 78 2c 20 70  se(pTree, idx, p
0460: 42 61 73 65 4f 62 6a 29 29 0d 0a 09 09 09 09 72  BaseObj))......r
0470: 65 74 75 72 6e 20 70 42 61 73 65 4f 62 6a 3b 0d  eturn pBaseObj;.
0480: 0a 09 09 09 69 66 28 70 42 61 73 65 4f 62 6a 20  ....if(pBaseObj 
0490: 3d 20 44 6f 43 61 73 74 28 70 42 61 73 65 4f 62  = DoCast(pBaseOb
04a0: 6a 2c 20 6f 70 29 29 0d 0a 09 09 09 09 72 65 74  j, op))......ret
04b0: 75 72 6e 20 70 42 61 73 65 4f 62 6a 3b 0d 0a 09  urn pBaseObj;...
04c0: 09 7d 0d 0a 09 09 72 65 74 75 72 6e 20 4e 55 4c  .}....return NUL
04d0: 4c 3b 0d 0a 09 7d 0d 0a 09 2f 2f 20 cf f3 f1 f2  L;...}...// ....
04e0: ee e9 20 f4 f3 ed ea f2 ee f0 0d 0a 09 73 74 72  .. ..........str
04f0: 75 63 74 20 62 79 5f 65 6d 70 74 79 20 0d 0a 09  uct by_empty ...
0500: 7b 0d 0a 09 09 42 4f 4f 4c 20 43 68 65 63 6b 43  {....BOOL CheckC
0510: 6f 6e 74 65 78 74 28 43 42 4c 43 6f 6e 74 65 78  ontext(CBLContex
0520: 74 2a 20 70 43 6f 6e 74 29 20 7b 72 65 74 75 72  t* pCont) {retur
0530: 6e 20 46 41 4c 53 45 3b 20 7d 0d 0a 09 09 42 4f  n FALSE; }....BO
0540: 4f 4c 20 43 68 65 63 6b 42 61 73 65 28 49 43 6f  OL CheckBase(ICo
0550: 6e 74 65 78 74 54 72 65 65 2a 20 70 54 72 65 65  ntextTree* pTree
0560: 2c 20 44 57 4f 52 44 20 69 64 78 2c 20 43 42 4c  , DWORD idx, CBL
0570: 43 6f 6e 74 65 78 74 2a 20 70 43 6f 6e 74 29 20  Context* pCont) 
0580: 7b 20 72 65 74 75 72 6e 20 46 41 4c 53 45 3b 20  { return FALSE; 
0590: 7d 0d 0a 09 7d 3b 0d 0a 09 2f 2f 20 d4 f3 ed ea  }...};...// ....
05a0: f2 ee f0 20 e4 eb ff 20 ef ee e8 f1 ea e0 20 ea  ... ... ...... .
05b0: ee ed f2 e5 ea f1 f2 e0 20 ef ee 20 43 52 75 6e  ........ .. CRun
05c0: 54 69 6d 65 43 6c 61 73 73 0d 0a 09 73 74 72 75  TimeClass...stru
05d0: 63 74 20 62 79 5f 72 74 63 20 3a 20 62 79 5f 65  ct by_rtc : by_e
05e0: 6d 70 74 79 0d 0a 09 7b 0d 0a 09 09 63 6f 6e 73  mpty...{....cons
05f0: 74 20 43 52 75 6e 74 69 6d 65 43 6c 61 73 73 2a  t CRuntimeClass*
0600: 20 70 52 54 43 3b 0d 0a 09 09 62 79 5f 72 74 63   pRTC;....by_rtc
0610: 28 63 6f 6e 73 74 20 43 52 75 6e 74 69 6d 65 43  (const CRuntimeC
0620: 6c 61 73 73 2a 20 70 29 20 3a 20 70 52 54 43 28  lass* p) : pRTC(
0630: 70 29 7b 7d 0d 0a 09 09 42 4f 4f 4c 20 43 68 65  p){}....BOOL Che
0640: 63 6b 43 6f 6e 74 65 78 74 28 43 42 4c 43 6f 6e  ckContext(CBLCon
0650: 74 65 78 74 2a 20 70 43 6f 6e 74 29 20 7b 72 65  text* pCont) {re
0660: 74 75 72 6e 20 70 43 6f 6e 74 2d 3e 47 65 74 52  turn pCont->GetR
0670: 75 6e 74 69 6d 65 43 6c 61 73 73 28 29 2d 3e 49  untimeClass()->I
0680: 73 44 65 72 69 76 65 64 46 72 6f 6d 28 70 52 54  sDerivedFrom(pRT
0690: 43 29 3b 20 7d 0d 0a 09 7d 3b 0d 0a 09 2f 2f 20  C); }...};...// 
06a0: d4 f3 ed ea f2 ee f0 20 e4 eb ff 20 ef ee e8 f1  ....... ... ....
06b0: ea e0 20 ea ee ed f2 e5 ea f1 f2 e0 20 ef ee 20  .. ......... .. 
06c0: ed e0 e7 e2 e0 ed e8 fe 20 ea eb e0 f1 f1 e0 20  ........ ...... 
06d0: e2 20 43 52 75 6e 54 69 6d 65 43 6c 61 73 73 0d  . CRunTimeClass.
06e0: 0a 09 73 74 72 75 63 74 20 62 79 5f 72 74 63 5f  ..struct by_rtc_
06f0: 6e 61 6d 65 20 3a 20 62 79 5f 65 6d 70 74 79 0d  name : by_empty.
0700: 0a 09 7b 0d 0a 09 09 63 6f 6e 73 74 20 43 53 74  ..{....const CSt
0710: 72 69 6e 67 26 20 73 74 72 4e 61 6d 65 3b 0d 0a  ring& strName;..
0720: 09 09 62 79 5f 72 74 63 5f 6e 61 6d 65 28 63 6f  ..by_rtc_name(co
0730: 6e 73 74 20 43 53 74 72 69 6e 67 26 20 73 29 20  nst CString& s) 
0740: 3a 20 73 74 72 4e 61 6d 65 28 73 29 7b 7d 0d 0a  : strName(s){}..
0750: 09 09 42 4f 4f 4c 20 43 68 65 63 6b 43 6f 6e 74  ..BOOL CheckCont
0760: 65 78 74 28 43 42 4c 43 6f 6e 74 65 78 74 2a 20  ext(CBLContext* 
0770: 70 43 6f 6e 74 29 20 7b 72 65 74 75 72 6e 20 30  pCont) {return 0
0780: 20 3d 3d 20 73 74 72 4e 61 6d 65 2e 43 6f 6d 70   == strName.Comp
0790: 61 72 65 4e 6f 43 61 73 65 28 70 43 6f 6e 74 2d  areNoCase(pCont-
07a0: 3e 47 65 74 52 75 6e 74 69 6d 65 43 6c 61 73 73  >GetRuntimeClass
07b0: 28 29 2d 3e 6d 5f 6c 70 73 7a 43 6c 61 73 73 4e  ()->m_lpszClassN
07c0: 61 6d 65 29 3b 20 7d 0d 0a 09 7d 3b 0d 0a 09 2f  ame); }...};.../
07d0: 2f 20 d4 f3 ed ea f2 ee f0 20 e4 eb ff 20 ef ee  / ....... ... ..
07e0: e8 f1 ea e0 20 ea ee ed f2 e5 ea f1 f2 e0 20 ef  .... ......... .
07f0: ee 20 ed e0 e7 e2 e0 ed e8 fe 20 e1 e0 e7 ee e2  . ........ .....
0800: ee e3 ee 20 ea eb e0 f1 f1 e0 0d 0a 09 2f 2f 20  ... .........// 
0810: e2 ed e8 ec e0 ed e8 e5 3a 20 ef ee e8 f1 ea 20  ........: ..... 
0820: ee f1 f3 f9 e5 f1 f2 e2 eb ff e5 f2 f1 ff 20 f1  .............. .
0830: f0 e0 e7 f3 20 f1 20 e1 e0 e7 ee e2 fb f5 20 ea  .... . ....... .
0840: eb e0 f1 f1 ee e2 2c 20 f1 e0 ec 20 ea eb e0 f1  ......, ... ....
0850: f1 20 ed e0 20 e8 ec ff 20 ed e5 20 ef f0 ee e2  . .. ... .. ....
0860: e5 f0 ff e5 f2 f1 ff 0d 0a 09 73 74 72 75 63 74  ..........struct
0870: 20 62 79 5f 62 61 73 65 5f 6e 61 6d 65 20 3a 20   by_base_name : 
0880: 62 79 5f 65 6d 70 74 79 0d 0a 09 7b 0d 0a 09 09  by_empty...{....
0890: 63 6f 6e 73 74 20 43 53 74 72 69 6e 67 26 20 73  const CString& s
08a0: 74 72 4e 61 6d 65 3b 0d 0a 09 09 62 79 5f 62 61  trName;....by_ba
08b0: 73 65 5f 6e 61 6d 65 28 63 6f 6e 73 74 20 43 53  se_name(const CS
08c0: 74 72 69 6e 67 26 20 73 29 20 3a 20 73 74 72 4e  tring& s) : strN
08d0: 61 6d 65 28 73 29 7b 7d 0d 0a 09 09 42 4f 4f 4c  ame(s){}....BOOL
08e0: 20 43 68 65 63 6b 42 61 73 65 28 49 43 6f 6e 74   CheckBase(ICont
08f0: 65 78 74 54 72 65 65 2a 20 70 54 72 65 65 2c 20  extTree* pTree, 
0900: 44 57 4f 52 44 20 69 64 78 2c 20 43 42 4c 43 6f  DWORD idx, CBLCo
0910: 6e 74 65 78 74 2a 20 70 43 6f 6e 74 29 0d 0a 09  ntext* pCont)...
0920: 09 09 7b 20 72 65 74 75 72 6e 20 30 20 3d 3d 20  ..{ return 0 == 
0930: 73 74 72 4e 61 6d 65 2e 43 6f 6d 70 61 72 65 4e  strName.CompareN
0940: 6f 43 61 73 65 28 70 54 72 65 65 2d 3e 47 65 74  oCase(pTree->Get
0950: 42 61 73 65 4f 62 6a 4e 61 6d 65 28 69 64 78 29  BaseObjName(idx)
0960: 29 3b 20 7d 0d 0a 09 7d 3b 0d 0a 09 2f 2f 20 d4  ); }...};...// .
0970: f3 ed ea f2 ee f0 20 e4 eb ff 20 ef ee e8 f1 ea  ...... ... .....
0980: e0 20 ea ee ed f2 e5 ea f1 f2 e0 2c 20 f0 e5 e0  . ........., ...
0990: eb e8 e7 f3 fe f9 e5 e3 ee 20 e8 ed f2 e5 f0 f4  ......... ......
09a0: e5 e9 f1 2c 20 e4 ee f1 f2 f3 ef ed fb e9 20 f7  ..., ......... .
09b0: e5 f0 e5 e7 20 e4 e8 ed e0 ec e8 ea ea e0 f1 f2  .... ...........
09c0: 0d 0a 09 74 65 6d 70 6c 61 74 65 3c 74 79 70 65  ...template<type
09d0: 6e 61 6d 65 20 54 3e 0d 0a 09 73 74 72 75 63 74  name T>...struct
09e0: 20 62 79 5f 64 79 6e 61 6d 69 63 5f 63 61 73 74   by_dynamic_cast
09f0: 20 3a 20 62 79 5f 65 6d 70 74 79 0d 0a 09 7b 0d   : by_empty...{.
0a00: 0a 09 09 54 2a 26 20 70 52 65 73 75 6c 74 3b 0d  ...T*& pResult;.
0a10: 0a 09 09 62 79 5f 64 79 6e 61 6d 69 63 5f 63 61  ...by_dynamic_ca
0a20: 73 74 28 54 2a 26 20 70 29 20 3a 20 70 52 65 73  st(T*& p) : pRes
0a30: 75 6c 74 28 70 29 7b 7d 0d 0a 09 09 42 4f 4f 4c  ult(p){}....BOOL
0a40: 20 43 68 65 63 6b 43 6f 6e 74 65 78 74 28 43 42   CheckContext(CB
0a50: 4c 43 6f 6e 74 65 78 74 2a 20 70 43 6f 6e 74 29  LContext* pCont)
0a60: 0d 0a 09 09 7b 0d 0a 09 09 09 74 72 79 7b 0d 0a  ....{.....try{..
0a70: 09 09 09 09 70 52 65 73 75 6c 74 20 3d 20 64 79  ....pResult = dy
0a80: 6e 61 6d 69 63 5f 63 61 73 74 3c 54 2a 3e 28 70  namic_cast<T*>(p
0a90: 43 6f 6e 74 29 3b 0d 0a 09 09 09 7d 63 61 74 63  Cont);.....}catc
0aa0: 68 28 2e 2e 2e 29 7b 20 72 65 74 75 72 6e 20 46  h(...){ return F
0ab0: 41 4c 53 45 3b 20 7d 0d 0a 09 09 09 72 65 74 75  ALSE; }.....retu
0ac0: 72 6e 20 70 52 65 73 75 6c 74 20 21 3d 20 4e 55  rn pResult != NU
0ad0: 4c 4c 3b 0d 0a 09 09 7d 0d 0a 09 7d 3b 0d 0a 0d  LL;....}...};...
0ae0: 0a 09 2f 2f 20 d1 ee e1 f1 f2 e2 e5 ed ed ee 2c  ..// ..........,
0af0: 20 ec e5 f2 ee e4 fb 20 ef f0 e8 e2 e5 e4 e5 ed   ...... ........
0b00: e8 ff 0d 0a 09 0d 0a 09 2f 2f 20 55 70 63 61 73  ........// Upcas
0b10: 74 20 2d 20 ef ee eb f3 f7 e8 f2 fc 20 ea ee ed  t - ........ ...
0b20: e5 f7 ed fb e9 20 ea eb e0 f1 f1 2e 0d 0a 09 73  ..... .........s
0b30: 74 61 74 69 63 20 43 42 4c 43 6f 6e 74 65 78 74  tatic CBLContext
0b40: 2a 20 55 70 28 43 42 4c 43 6f 6e 74 65 78 74 2a  * Up(CBLContext*
0b50: 20 70 43 6f 6e 74 29 0d 0a 09 7b 0d 0a 09 09 49   pCont)...{....I
0b60: 43 6f 6e 74 65 78 74 54 72 65 65 2a 20 70 54 72  ContextTree* pTr
0b70: 65 65 3b 0d 0a 09 09 66 6f 72 28 3b 3b 29 0d 0a  ee;....for(;;)..
0b80: 09 09 7b 0d 0a 09 09 09 74 72 79 7b 0d 0a 09 09  ..{.....try{....
0b90: 09 09 69 66 28 21 28 70 54 72 65 65 20 3d 20 64  ..if(!(pTree = d
0ba0: 79 6e 61 6d 69 63 5f 63 61 73 74 3c 49 43 6f 6e  ynamic_cast<ICon
0bb0: 74 65 78 74 54 72 65 65 2a 3e 28 70 43 6f 6e 74  textTree*>(pCont
0bc0: 29 29 29 0d 0a 09 09 09 09 09 62 72 65 61 6b 3b  ))).......break;
0bd0: 0d 0a 09 09 09 7d 63 61 74 63 68 28 2e 2e 2e 29  .....}catch(...)
0be0: 7b 20 62 72 65 61 6b 3b 20 7d 0d 0a 09 09 09 43  { break; }.....C
0bf0: 42 4c 43 6f 6e 74 65 78 74 2a 20 70 44 65 72 69  BLContext* pDeri
0c00: 76 65 64 20 3d 20 70 54 72 65 65 2d 3e 47 65 74  ved = pTree->Get
0c10: 44 65 72 69 76 65 64 4f 62 6a 28 29 3b 0d 0a 09  DerivedObj();...
0c20: 09 09 69 66 28 21 70 44 65 72 69 76 65 64 29 0d  ..if(!pDerived).
0c30: 0a 09 09 09 09 62 72 65 61 6b 3b 0d 0a 09 09 09  .....break;.....
0c40: 70 43 6f 6e 74 20 3d 20 70 44 65 72 69 76 65 64  pCont = pDerived
0c50: 3b 0d 0a 09 09 7d 0d 0a 09 09 72 65 74 75 72 6e  ;....}....return
0c60: 20 70 43 6f 6e 74 3b 0d 0a 09 7d 0d 0a 0d 0a 09   pCont;...}.....
0c70: 2f 2f 20 cf f0 e8 e2 e5 e4 e5 ed e8 e5 20 ef ee  // .......... ..
0c80: 20 43 52 75 6e 54 69 6d 65 43 6c 61 73 73 27 f3   CRunTimeClass'.
0c90: 0d 0a 09 73 74 61 74 69 63 20 43 42 4c 43 6f 6e  ...static CBLCon
0ca0: 74 65 78 74 2a 20 42 79 52 54 43 28 43 42 4c 43  text* ByRTC(CBLC
0cb0: 6f 6e 74 65 78 74 2a 20 70 43 6f 6e 74 2c 20 63  ontext* pCont, c
0cc0: 6f 6e 73 74 20 43 52 75 6e 74 69 6d 65 43 6c 61  onst CRuntimeCla
0cd0: 73 73 2a 20 70 52 54 43 29 0d 0a 09 7b 0d 0a 09  ss* pRTC)...{...
0ce0: 09 72 65 74 75 72 6e 20 44 6f 43 61 73 74 28 70  .return DoCast(p
0cf0: 43 6f 6e 74 2c 20 62 79 5f 72 74 63 28 70 52 54  Cont, by_rtc(pRT
0d00: 43 29 29 3b 0d 0a 09 7d 0d 0a 09 2f 2f 20 cf f0  C));...}...// ..
0d10: e8 e2 e5 e4 e5 ed e8 e5 20 ef ee 20 ed e0 e7 e2  ........ .. ....
0d20: e0 ed e8 fe 20 e2 20 43 52 75 6e 54 69 6d 65 43  .... . CRunTimeC
0d30: 6c 61 73 73 27 e5 0d 0a 09 73 74 61 74 69 63 20  lass'....static 
0d40: 43 42 4c 43 6f 6e 74 65 78 74 2a 20 42 79 52 54  CBLContext* ByRT
0d50: 43 4e 61 6d 65 28 43 42 4c 43 6f 6e 74 65 78 74  CName(CBLContext
0d60: 2a 20 70 43 6f 6e 74 2c 20 63 6f 6e 73 74 20 43  * pCont, const C
0d70: 53 74 72 69 6e 67 26 20 73 74 72 4e 61 6d 65 29  String& strName)
0d80: 0d 0a 09 7b 0d 0a 09 09 72 65 74 75 72 6e 20 44  ...{....return D
0d90: 6f 43 61 73 74 28 70 43 6f 6e 74 2c 20 62 79 5f  oCast(pCont, by_
0da0: 72 74 63 5f 6e 61 6d 65 28 73 74 72 4e 61 6d 65  rtc_name(strName
0db0: 29 29 3b 0d 0a 09 7d 0d 0a 09 2f 2f 20 cf f0 e8  ));...}...// ...
0dc0: e2 e5 e4 e5 ed e8 e5 20 ef ee 20 e8 ec e5 ed e8  ....... .. .....
0dd0: 20 e1 e0 e7 ee e2 ee e3 ee 20 ea eb e0 f1 f1 e0   ........ ......
0de0: 0d 0a 09 73 74 61 74 69 63 20 43 42 4c 43 6f 6e  ...static CBLCon
0df0: 74 65 78 74 2a 20 42 79 42 61 73 65 4e 61 6d 65  text* ByBaseName
0e00: 28 43 42 4c 43 6f 6e 74 65 78 74 2a 20 70 43 6f  (CBLContext* pCo
0e10: 6e 74 2c 20 63 6f 6e 73 74 20 43 53 74 72 69 6e  nt, const CStrin
0e20: 67 26 20 73 74 72 4e 61 6d 65 29 0d 0a 09 7b 0d  g& strName)...{.
0e30: 0a 09 09 72 65 74 75 72 6e 20 44 6f 43 61 73 74  ...return DoCast
0e40: 28 70 43 6f 6e 74 2c 20 62 79 5f 62 61 73 65 5f  (pCont, by_base_
0e50: 6e 61 6d 65 28 73 74 72 4e 61 6d 65 29 29 3b 0d  name(strName));.
0e60: 0a 09 7d 0d 0a 09 2f 2f 20 cf f0 e8 e2 e5 e4 e5  ..}...// .......
0e70: ed e8 e5 20 f7 e5 f0 e5 e7 20 64 79 6e 61 6d 69  ... ..... dynami
0e80: 63 5f 63 61 73 74 20 ea 20 e7 e0 e4 e0 ed ed ee  c_cast . .......
0e90: ec f3 20 f2 e8 ef f3 0d 0a 09 74 65 6d 70 6c 61  .. .......templa
0ea0: 74 65 3c 74 79 70 65 6e 61 6d 65 20 54 3e 0d 0a  te<typename T>..
0eb0: 09 73 74 61 74 69 63 20 43 42 4c 43 6f 6e 74 65  .static CBLConte
0ec0: 78 74 2a 20 44 79 6e 61 6d 69 63 28 43 42 4c 43  xt* Dynamic(CBLC
0ed0: 6f 6e 74 65 78 74 2a 20 70 43 6f 6e 74 2c 20 54  ontext* pCont, T
0ee0: 2a 26 20 70 52 65 73 75 6c 74 29 0d 0a 09 7b 0d  *& pResult)...{.
0ef0: 0a 09 09 72 65 74 75 72 6e 20 44 6f 43 61 73 74  ...return DoCast
0f00: 28 70 43 6f 6e 74 2c 20 62 79 5f 64 79 6e 61 6d  (pCont, by_dynam
0f10: 69 63 5f 63 61 73 74 3c 54 3e 28 70 52 65 73 75  ic_cast<T>(pResu
0f20: 6c 74 29 29 3b 0d 0a 09 7d 0d 0a 7d 3b 0d 0a     lt));...}..};..