cppTemplateParameterList.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Filename: cppTemplateParameterList.h
  2. // Created by: drose (28Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef CPPTEMPLATEPARAMETERLIST_H
  15. #define CPPTEMPLATEPARAMETERLIST_H
  16. #include "dtoolbase.h"
  17. #include "cppDeclaration.h"
  18. #include <vector>
  19. #include <string>
  20. class CPPScope;
  21. ///////////////////////////////////////////////////////////////////
  22. // Class : CPPTemplateParameterList
  23. // Description : This class serves to store the parameter list for a
  24. // template function or class, both for the formal
  25. // parameter list (given when the template is defined)
  26. // and for the actual parameter list (given when the
  27. // template is instantiated).
  28. ////////////////////////////////////////////////////////////////////
  29. class CPPTemplateParameterList {
  30. public:
  31. CPPTemplateParameterList();
  32. string get_string() const;
  33. void build_subst_decl(const CPPTemplateParameterList &formal_params,
  34. CPPDeclaration::SubstDecl &subst,
  35. CPPScope *current_scope, CPPScope *global_scope) const;
  36. bool is_fully_specified() const;
  37. bool is_tbd() const;
  38. bool operator == (const CPPTemplateParameterList &other) const;
  39. bool operator != (const CPPTemplateParameterList &other) const;
  40. bool operator < (const CPPTemplateParameterList &other) const;
  41. CPPTemplateParameterList *substitute_decl(CPPDeclaration::SubstDecl &subst,
  42. CPPScope *current_scope,
  43. CPPScope *global_scope);
  44. void output(ostream &out, CPPScope *scope) const;
  45. void write_formal(ostream &out, CPPScope *scope) const;
  46. typedef vector<CPPDeclaration *> Parameters;
  47. Parameters _parameters;
  48. };
  49. inline ostream &
  50. operator << (ostream &out, const CPPTemplateParameterList &plist) {
  51. plist.output(out, (CPPScope *)NULL);
  52. return out;
  53. }
  54. // This is an STL function object used to uniquely order
  55. // CPPTemplateParameterList pointers.
  56. class CPPTPLCompare {
  57. public:
  58. bool operator () (const CPPTemplateParameterList *a,
  59. const CPPTemplateParameterList *b) const {
  60. return (*a) < (*b);
  61. }
  62. };
  63. #endif