Ejemplo n.º 1
0
// Generate enum declarations.
static void GenEnum(const EnumDef &enum_def, std::string *code_ptr) {
  if (enum_def.generated) return;

  Comment(enum_def.doc_comment, code_ptr);
  BeginEnum(code_ptr);
  for (auto it = enum_def.vals.vec.begin();
       it != enum_def.vals.vec.end();
       ++it) {
    auto &ev = **it;
    Comment(ev.doc_comment, code_ptr, "  ");
    EnumMember(enum_def, ev, code_ptr);
  }
  EndEnum(code_ptr);
}
Ejemplo n.º 2
0
    bool FilteredTermEnum::next() {
    //Func - Increments the enumeration to the next element.  
	//Pre  - true
	//Post - Returns True if the enumeration has been moved to the next element otherwise false

		//The actual enumerator is not initialized!
		if (actualEnum == NULL){
			return false; 
		    }

		//Finalize the currentTerm and reset it to NULL
        currentTerm->finalize();
        currentTerm = NULL;

		//Iterate through the enumeration
        while (currentTerm == NULL) {
            if (EndEnum()) 
				return false;
            if (actualEnum->next()) {
                //Order getTerm not to return reference ownership here. */
                Term* term = actualEnum->getTerm(false);
				//Compare the retrieved term
                if (termCompare(term)){
					//Matched so finalize the current
                    currentTerm->finalize();
					//Get a reference to the matched term
                    currentTerm = term->pointer();
                    return true;
                    }
                }
            else 
                return false;
        }
        currentTerm->finalize();
        currentTerm = NULL;

        return false;
    }