// Between template < and > I suppose that a type is not included // because I cannot know how the type is used and I do not want to // produce circular #include bool UmlClassMember::compute_dependency(Q3PtrList<CppRefType> & dependencies, WrapperStr decl, const UmlTypeSpec & t, bool force_incl) { remove_comments(decl); remove_preprocessor(decl); remove_arrays(decl); int template_level = 0; bool have_type = FALSE; const char * p = decl; const char * dontsubstituteuntil = 0; for (;;) { UmlTypeSpec ts; char c; bool dontsearchend = FALSE; // search word beginning while ((c = *p) != 0) { if ((c == '_') || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) break; else if (dontsubstituteuntil != 0) { if (p >= dontsubstituteuntil) dontsubstituteuntil = 0; else p += 1; } else if (c == '=') // init, all is done return have_type; else if (!strncmp(p, "${type}", 7)) { p += 7; ts = t; if (ts.type != 0) { dontsearchend = TRUE; break; } else { decl = ts.explicit_type + p; p = decl; } } else { switch (c) { case '<': template_level += 1; break; case '>': template_level -= 1; } p += 1; } } if (c == 0) return have_type; if (!dontsearchend) { // search word end const char * p2 = p; ts.type = 0; ts.explicit_type = p2; p += 1; while ((c = *p) != 0) { if ((c == '_') || (c == ':') || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9'))) p += 1; else { ts.explicit_type.truncate(p - p2); break; } } //#warning NAMESPACE if (dontsubstituteuntil == 0) { WrapperStr subst = CppSettings::type(ts.explicit_type); if (subst != ts.explicit_type) { decl = subst + ' ' + p; p = decl; dontsubstituteuntil = p + subst.length(); continue; } } } // check manually added keyword if ((ts.explicit_type == "const") || (ts.explicit_type == "static")) continue; // search for a * or & or < after the typename bool incl = (template_level == 0); while ((c = *p) != 0) { if ((c == '*') || (c == '&')) { incl = FALSE; p += 1; break; } if ((c == '<') || (c == '>') || (c == '(') || (c == ')') || (c == ',') || (c == '_') || (c == '$') || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { break; } p += 1; } if (CppRefType::add(ts, dependencies, force_incl || incl)) have_type = TRUE; } return have_type; }
void remove_preprocessor(WrapperStr & s) { remove_preprocessor(s.GetInternalRef()); }