cmSystemTools.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #ifndef cmSystemTools_h
  12. #define cmSystemTools_h
  13. #include "cmStandardIncludes.h"
  14. /** \class cmSystemTools
  15. * \brief A collection of useful functions for CMake.
  16. *
  17. * cmSystemTools is a class that provides helper functions
  18. * for the CMake build system.
  19. */
  20. class cmSystemTools
  21. {
  22. public:
  23. /**
  24. * Make a new directory if it is not there. This function
  25. * can make a full path even if none of the directories existed
  26. * prior to calling this function.
  27. */
  28. static bool MakeDirectory(const char* path);
  29. /**
  30. * Replace replace all occurances of the string in
  31. * the source string.
  32. */
  33. static void ReplaceString(std::string& source,
  34. const char* replace,
  35. const char* with);
  36. /**
  37. * Replace Windows file system slashes with Unix-style slashes.
  38. */
  39. static void ConvertToUnixSlashes(std::string& path);
  40. /**
  41. * Return true if a file exists in the current directory.
  42. */
  43. static bool FileExists(const char* filename);
  44. /**
  45. * Return the number of times the given expression occurs in the file
  46. * specified by the concatenation of dir/file.
  47. */
  48. static int Grep(const char* dir, const char* file, const char* expression);
  49. /**
  50. * Convert a path containing a cygwin drive specifier to its natural
  51. * equivalent.
  52. */
  53. static void ConvertCygwinPath(std::string& pathname);
  54. /**
  55. * Read a CMake command (or function) from an input file. This
  56. * returns the name of the function and a list of its
  57. * arguments.
  58. */
  59. static bool ParseFunction(std::ifstream&,
  60. std::string& name,
  61. std::vector<std::string>& arguments);
  62. /**
  63. * Extract white-space separated arguments from a string.
  64. * Double quoted strings are accepted with spaces.
  65. * This is called by ParseFunction.
  66. */
  67. static void GetArguments(std::string& line,
  68. std::vector<std::string>& arguments);
  69. /**
  70. * Display an error message.
  71. */
  72. static void Error(const char* m, const char* m2=0 );
  73. };
  74. #endif