cmGlob.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmGlob_h
  14. #define cmGlob_h
  15. #include "cmStandardIncludes.h"
  16. class cmGlobInternal;
  17. /** \class cmGlob
  18. * \brief Helper class for performing globbing searches.
  19. *
  20. * Finds all files that match a given globbing expression.
  21. */
  22. class cmGlob
  23. {
  24. public:
  25. cmGlob();
  26. ~cmGlob();
  27. //! Find all files that match the pattern.
  28. bool FindFiles(const std::string& inexpr);
  29. //! Return the list of files that matched.
  30. std::vector<std::string>& GetFiles();
  31. //! Set recurse to true to match subdirectories.
  32. void RecurseOn() { this->SetRecurse(true); }
  33. void RecurseOff() { this->SetRecurse(false); }
  34. void SetRecurse(bool i) { m_Recurse = i; }
  35. bool GetRecurse() { return m_Recurse; }
  36. protected:
  37. //! Process directory
  38. void ProcessDirectory(std::string::size_type start,
  39. const std::string& dir, bool dir_only);
  40. //! Process last directory, but only when recurse flags is on. That is
  41. // effectively like saying: /path/to/file/**/file
  42. void RecurseDirectory(const std::string& dir, bool dir_only);
  43. //! Escape all non-alphanumeric characters in pattern.
  44. void Escape(int ch, char* buffer);
  45. //!
  46. // Translate a shell PATTERN to a regular expression.
  47. // There is no way to quote meta-characters.
  48. std::string ConvertExpression(const std::string& expr);
  49. //! Add regular expression
  50. void AddExpression(const char* expr);
  51. cmGlobInternal* m_Internals;
  52. bool m_Recurse;
  53. };
  54. #endif