diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-10-18 18:08:55 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-10-18 18:08:55 (GMT) |
commit | fdc4795b9131d43bc06a4051eac1ddeb11c2bce7 (patch) | |
tree | 652a89168aa97eb39719ab8d7de64cbfe287786a /Source/kwsys/Glob.hxx.in | |
parent | 37dc4bdc6e96ac66c0c95c3c977498a502604fe1 (diff) | |
download | CMake-fdc4795b9131d43bc06a4051eac1ddeb11c2bce7.zip CMake-fdc4795b9131d43bc06a4051eac1ddeb11c2bce7.tar.gz CMake-fdc4795b9131d43bc06a4051eac1ddeb11c2bce7.tar.bz2 |
ENH: Push glob to the kwsys
Diffstat (limited to 'Source/kwsys/Glob.hxx.in')
-rw-r--r-- | Source/kwsys/Glob.hxx.in | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in new file mode 100644 index 0000000..ae793ef --- /dev/null +++ b/Source/kwsys/Glob.hxx.in @@ -0,0 +1,81 @@ +/*========================================================================= + + Program: KWSys - Kitware System Library + Module: $RCSfile$ + + Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef @KWSYS_NAMESPACE@_Glob_hxx +#define @KWSYS_NAMESPACE@_Glob_hxx + +#include <@KWSYS_NAMESPACE@/stl/string> +#include <@KWSYS_NAMESPACE@/stl/vector> + +#include <@KWSYS_NAMESPACE@/Configure.h> + +namespace @KWSYS_NAMESPACE@ +{ + +class GlobInternals; + +/** \class Glob + * \brief Portable globbing searches. + * + * Globbing expressions are much simpler than regular + * expressions. This class will search for files using + * globbing expressions. + * + * Finds all files that match a given globbing expression. + */ +class @KWSYS_NAMESPACE@_EXPORT Glob +{ +public: + Glob(); + ~Glob(); + + //! Find all files that match the pattern. + bool FindFiles(const std::string& inexpr); + + //! Return the list of files that matched. + std::vector<std::string>& GetFiles(); + + //! Set recurse to true to match subdirectories. + void RecurseOn() { this->SetRecurse(true); } + void RecurseOff() { this->SetRecurse(false); } + void SetRecurse(bool i) { m_Recurse = i; } + bool GetRecurse() { return m_Recurse; } + +protected: + //! Process directory + void ProcessDirectory(std::string::size_type start, + const std::string& dir, bool dir_only); + + //! Process last directory, but only when recurse flags is on. That is + // effectively like saying: /path/to/file/**/file + void RecurseDirectory(std::string::size_type start, + const std::string& dir, bool dir_only); + + //! Escape all non-alphanumeric characters in pattern. + void Escape(int ch, char* buffer); + + //! + // Translate a shell PATTERN to a regular expression. + // There is no way to quote meta-characters. + std::string ConvertExpression(const std::string& expr); + + //! Add regular expression + void AddExpression(const char* expr); + + GlobInternals* m_Internals; + bool m_Recurse; +}; + +} // namespace @KWSYS_NAMESPACE@ + +#endif |