Re: Nested sets question...

From: Neo <neo55592_at_hotmail.com>
Date: 23 Nov 2004 11:58:45 -0800
Message-ID: <4b45d3ad.0411231158.7281eba3_at_posting.google.com>


> How to find all children in nested sets model
> that are two levels under specified item?

Following prints the names of children two levels under god, using XDb2:

// Create god and persons

CREATE *god.cls = thing;
CREATE *person.cls = thing;
CREATE *adam.cls = person;
CREATE *eve.cls = person;
CREATE *john.cls = person;
CREATE *mary.cls = person;

// Create hierarchy with god at root
CREATE god.child = adam;
CREATE god.child = eve;

CREATE adam.child = john;
CREATE eve.child = john;

CREATE adam.child = mary;
CREATE eve.child = mary;

// Print name of distinct children of god, 2 levels down. // Prints: john, mary.

   int* pGod = AStr_getDefT(_T("god"));
   int* pChild = AStr_getDefT(_T("child"));    #define stackSz1 64
   int* pDesc_a[stackSz1] = {T_R_PriRecip(pGod), NULL};    BOOL distinct_b = TRUE;
   while (int x=T_Relative(pDesc_a, stackSz1, pVbChild_g, distinct_b)){

      if (x == 2){
         TCHAR sName[kStrSz_g+1] = _T("");
         T_Name_get(N_getO(pDesc_a[x]), sName, kStrSz_g);
         TRACE(_T("%s\n"), sName);
      }

   } Received on Tue Nov 23 2004 - 20:58:45 CET

Original text of this message