cppFile.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Filename: cppFile.h
  2. // Created by: drose (11Nov99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef CPPFILE_H
  19. #define CPPFILE_H
  20. #include "dtoolbase.h"
  21. #include "filename.h"
  22. ///////////////////////////////////////////////////////////////////
  23. // Class : CPPFile
  24. // Description : This defines a source file (typically a C++ header
  25. // file) that is parsed by the CPPParser. Each
  26. // declaration indicates the source file where it
  27. // appeared.
  28. ////////////////////////////////////////////////////////////////////
  29. class CPPFile {
  30. public:
  31. enum Source {
  32. S_local, // File resides in the current directory
  33. S_alternate, // File resides in some other directory
  34. S_system, // File resides in a system directory
  35. S_none, // File is internally generated
  36. };
  37. CPPFile(const Filename &filename = "",
  38. const Filename &filename_as_referenced = "",
  39. Source source = S_none);
  40. CPPFile(const CPPFile &copy);
  41. void operator = (const CPPFile &copy);
  42. ~CPPFile();
  43. bool is_c_or_i_file() const;
  44. static bool is_c_or_i_file(const Filename &filename);
  45. bool is_c_file() const;
  46. static bool is_c_file(const Filename &filename);
  47. void replace_nearer(const CPPFile &other);
  48. bool operator < (const CPPFile &other) const;
  49. bool operator == (const CPPFile &other) const;
  50. bool operator != (const CPPFile &other) const;
  51. const char *c_str() const;
  52. bool empty() const;
  53. Filename _filename;
  54. Filename _filename_as_referenced;
  55. Source _source;
  56. };
  57. inline ostream &operator << (ostream &out, const CPPFile &file) {
  58. return out << file._filename;
  59. }
  60. #endif