qaTree/functions/gfunc.cpp
// find_attr
// input: project root, category name, attribute ID
// output: node associated with attribute of choice
find_attr
input: project root, category name, attribute ID
output: node associated with attribute of choice
find_attr input : project root category name attribute ID output : node associated with attribute of choice
qaNode* find_attr(qaTree* proj, string cat, string attr) {
   if (proj == NULL) {
      printf("error: no project found");
      return NULL;
   }
   if (proj->cachildren.size()>0) {
      for (size_t child = 0; child < proj->cachildren.size(); child++) { 
         if (cat.compare(proj->cachildren[child]->name) == 0) {
             qaTree* categ = proj->cachildren[child];
             for (size_t atch = 0; atch < categ->children.size(); atch++) {
                 if (attr.compare(categ->children[atch]->ID) == 0) {
                    return categ->children[atch];
                 }
             } 
             return NULL;
         }
      }
      printf("error: no match for inputted category title");
      return NULL;
   }
   printf("error: project is empty");
   return NULL;
}
qaNode * find_attr ( qaTree * proj , string cat , string attr ) { if ( proj == NULL ) { printf ( " " ) ; return NULL ; } if ( proj -> cachildren . size ( ) > 0 ) { for ( size_t child = 0 ; child < proj -> cachildren . size ( ) ; child ++ ) { if ( cat . compare ( proj -> cachildren [ child ] -> name ) == 0 ) { qaTree * categ = proj -> cachildren [ child ] ; for ( size_t atch = 0 ; atch < categ -> children . size ( ) ; atch ++ ) { if ( attr . compare ( categ -> children [ atch ] -> ID ) == 0 ) { return categ -> children [ atch ] ; } } return NULL ; } } printf ( " " ) ; return NULL ; } printf ( " " ) ; return NULL ; }
find_attr
input: project root, category name, attribute ID
output: node associated with attribute of choice
find_attr input : project root category name attribute ID output : node associated with attribute of choice
// check that there is anything to iterate over // search for correct category to look through // search for correct attribute ID and return node // if no matching attribute