cppFile.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file cppFile.h
  10. * @author drose
  11. * @date 1999-11-11
  12. */
  13. #ifndef CPPFILE_H
  14. #define CPPFILE_H
  15. #include "dtoolbase.h"
  16. #include "filename.h"
  17. /**
  18. * This defines a source file (typically a C++ header file) that is parsed by
  19. * the CPPParser. Each declaration indicates the source file where it
  20. * appeared.
  21. */
  22. class CPPFile {
  23. public:
  24. enum Source {
  25. S_local, // File resides in the current directory
  26. S_alternate, // File resides in some other directory
  27. S_system, // File resides in a system directory
  28. S_none, // File is internally generated
  29. };
  30. CPPFile(const Filename &filename = "",
  31. const Filename &filename_as_referenced = "",
  32. Source source = S_none);
  33. bool is_c_or_i_file() const;
  34. static bool is_c_or_i_file(const Filename &filename);
  35. bool is_c_file() const;
  36. static bool is_c_file(const Filename &filename);
  37. void replace_nearer(const CPPFile &other);
  38. bool operator < (const CPPFile &other) const;
  39. bool operator == (const CPPFile &other) const;
  40. bool operator != (const CPPFile &other) const;
  41. const char *c_str() const;
  42. bool empty() const;
  43. Filename _filename;
  44. Filename _filename_as_referenced;
  45. mutable Source _source;
  46. mutable bool _pragma_once;
  47. };
  48. inline std::ostream &operator << (std::ostream &out, const CPPFile &file) {
  49. return out << file._filename;
  50. }
  51. #endif