cppTemplateParameterList.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Filename: cppTemplateParameterList.h
  2. // Created by: drose (28Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef CPPTEMPLATEPARAMETERLIST_H
  6. #define CPPTEMPLATEPARAMETERLIST_H
  7. #include <dtoolbase.h>
  8. #include "cppDeclaration.h"
  9. #include <vector>
  10. #include <string>
  11. class CPPScope;
  12. ///////////////////////////////////////////////////////////////////
  13. // Class : CPPTemplateParameterList
  14. // Description : This class serves to store the parameter list for a
  15. // template function or class, both for the formal
  16. // parameter list (given when the template is defined)
  17. // and for the actual parameter list (given when the
  18. // template is instantiated).
  19. ////////////////////////////////////////////////////////////////////
  20. class CPPTemplateParameterList {
  21. public:
  22. CPPTemplateParameterList();
  23. string get_string() const;
  24. void build_subst_decl(const CPPTemplateParameterList &formal_params,
  25. CPPDeclaration::SubstDecl &subst,
  26. CPPScope *current_scope, CPPScope *global_scope) const;
  27. bool is_fully_specified() const;
  28. bool is_tbd() const;
  29. bool operator == (const CPPTemplateParameterList &other) const;
  30. bool operator != (const CPPTemplateParameterList &other) const;
  31. bool operator < (const CPPTemplateParameterList &other) const;
  32. CPPTemplateParameterList *substitute_decl(CPPDeclaration::SubstDecl &subst,
  33. CPPScope *current_scope,
  34. CPPScope *global_scope);
  35. void output(ostream &out, CPPScope *scope) const;
  36. void write_formal(ostream &out, CPPScope *scope) const;
  37. typedef vector<CPPDeclaration *> Parameters;
  38. Parameters _parameters;
  39. };
  40. inline ostream &
  41. operator << (ostream &out, const CPPTemplateParameterList &plist) {
  42. plist.output(out, (CPPScope *)NULL);
  43. return out;
  44. }
  45. // This is an STL function object used to uniquely order
  46. // CPPTemplateParameterList pointers.
  47. class CPPTPLCompare {
  48. public:
  49. bool operator () (const CPPTemplateParameterList *a,
  50. const CPPTemplateParameterList *b) const {
  51. return (*a) < (*b);
  52. }
  53. };
  54. #endif