cmClassFile.cxx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #include "cmClassFile.h"
  12. #include "cmStandardIncludes.h"
  13. #include "cmSystemTools.h"
  14. // Set the name of the class and the full path to the file.
  15. // The class must be found in dir and end in name.cxx, name.txx,
  16. // name.c or it will be considered a header file only class
  17. // and not included in the build process
  18. void cmClassFile::SetName(const char* name, const char* dir)
  19. {
  20. m_HeaderFileOnly = true;
  21. m_ClassName = name;
  22. std::string pathname = dir;
  23. if(pathname != "")
  24. {
  25. pathname += "/";
  26. }
  27. // First try and see whether the listed file can be found
  28. // as is without extensions added on.
  29. pathname += m_ClassName;
  30. std::string hname = pathname;
  31. if(cmSystemTools::FileExists(hname.c_str()))
  32. {
  33. m_HeaderFileOnly = false;
  34. m_FullPath = hname;
  35. return;
  36. }
  37. // Try various extentions
  38. hname = pathname;
  39. hname += ".cxx";
  40. if(cmSystemTools::FileExists(hname.c_str()))
  41. {
  42. m_HeaderFileOnly = false;
  43. m_FullPath = hname;
  44. return;
  45. }
  46. hname = pathname;
  47. hname += ".c";
  48. if(cmSystemTools::FileExists(hname.c_str()))
  49. {
  50. m_HeaderFileOnly = false;
  51. m_FullPath = hname;
  52. return;
  53. }
  54. hname = pathname;
  55. hname += ".txx";
  56. if(cmSystemTools::FileExists(hname.c_str()))
  57. {
  58. m_HeaderFileOnly = false;
  59. m_FullPath = hname;
  60. return;
  61. }
  62. hname = pathname;
  63. hname += ".h";
  64. if(!cmSystemTools::FileExists(hname.c_str()))
  65. {
  66. cmSystemTools::Error("can not find file ", hname.c_str());
  67. cmSystemTools::Error("Tried .txx .cxx .c for ", hname.c_str());
  68. }
  69. }
  70. void cmClassFile::Print()
  71. {
  72. if(m_AbstractClass)
  73. std::cout << "Abstract ";
  74. else
  75. std::cout << "Concrete ";
  76. if(m_HeaderFileOnly)
  77. std::cout << "Header file ";
  78. else
  79. std::cout << "CXX file ";
  80. std::cout << m_ClassName << std::endl;
  81. }