CMake/Glob.hxx.in
KWSys Robot 7762c57405 KWSys 2014-05-07 (6074f33f)
Extract upstream KWSys using the following shell commands.

$ git archive --prefix=upstream-kwsys/ 6074f33f | tar x
$ git shortlog --no-merges --abbrev=8 --format='%h %s' f3a36760..6074f33f
Ben Boeckel (22):
      ef3bfa01 c_str: Don't use .c_str() when streaming strings
      9c165368 Glob: Use string comparisons if you have them ready
      53ba0bc6 containers: Use .empty() instead of .size() where possible
      6cbb57ac strings: Use string methods instead of size calculations
      e53596b7 RegularExpression: Add string overloads
      aec9de6a CommandLineArguments: Push the string back, not its C string
      1d531416 Glob: Accept a string in Glob::AddFile
      81f5e0a8 Glob: Accept a string in Glob::AddExpression
      d40c2706 SystemTools: Remove redundant if guards
      c1296f4a SystemTools: Defer computing length until after a .empty() check
      7ffb7106 SystemTools: Use the iterator constructor for strings
      29e3b1d8 SystemTools: Use .rfind('/') rather than .find_last_of("/")
      5eb3a65c SystemTools: Don't construct a string just for its length
      b07b5fc1 SystemTools: Take a string in GetShortPath
      153f6df7 SystemTools: Use strings in ComparePath
      2c2f6604 SystemTools: Accept strings in IsSubDirectory
      84db9ee5 SystemTools: Take strings in AddTranslationPath
      4b409aa4 SystemTools: Take strings in SplitPath
      d2dbff07 SystemTools: Take strings in CollapseFullPath
      e9204f8f SystemTools: Take strings in AddKeepPath
      3254681a SystemTools: Reserve memory in JoinPath
      6074f33f SystemTools: Use static strings in SystemToolsAppendComponents

Change-Id: I53c7a1005206dba43ee785bf807c478bf146ca0e
2014-05-13 14:55:30 -04:00

118 lines
4.0 KiB
C++

/*============================================================================
KWSys - Kitware System Library
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef @KWSYS_NAMESPACE@_Glob_hxx
#define @KWSYS_NAMESPACE@_Glob_hxx
#include <@KWSYS_NAMESPACE@/Configure.h>
#include <@KWSYS_NAMESPACE@/Configure.hxx>
#include <@KWSYS_NAMESPACE@/stl/string>
#include <@KWSYS_NAMESPACE@/stl/vector>
/* Define this macro temporarily to keep the code readable. */
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys_stl @KWSYS_NAMESPACE@_stl
#endif
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 kwsys_stl::string& inexpr);
//! Return the list of files that matched.
kwsys_stl::vector<kwsys_stl::string>& GetFiles();
//! Set recurse to true to match subdirectories.
void RecurseOn() { this->SetRecurse(true); }
void RecurseOff() { this->SetRecurse(false); }
void SetRecurse(bool i) { this->Recurse = i; }
bool GetRecurse() { return this->Recurse; }
//! Set recurse through symlinks to true if recursion should traverse the
// linked-to directories
void RecurseThroughSymlinksOn() { this->SetRecurseThroughSymlinks(true); }
void RecurseThroughSymlinksOff() { this->SetRecurseThroughSymlinks(false); }
void SetRecurseThroughSymlinks(bool i) { this->RecurseThroughSymlinks = i; }
bool GetRecurseThroughSymlinks() { return this->RecurseThroughSymlinks; }
//! Get the number of symlinks followed through recursion
unsigned int GetFollowedSymlinkCount() { return this->FollowedSymlinkCount; }
//! Set relative to true to only show relative path to files.
void SetRelative(const char* dir);
const char* GetRelative();
/** Convert the given globbing pattern to a regular expression.
There is no way to quote meta-characters. The
require_whole_string argument specifies whether the regex is
automatically surrounded by "^" and "$" to match the whole
string. This is on by default because patterns always match
whole strings, but may be disabled to support concatenating
expressions more easily (regex1|regex2|etc). */
static kwsys_stl::string PatternToRegex(const kwsys_stl::string& pattern,
bool require_whole_string = true,
bool preserve_case = false);
protected:
//! Process directory
void ProcessDirectory(kwsys_stl::string::size_type start,
const kwsys_stl::string& dir);
//! Process last directory, but only when recurse flags is on. That is
// effectively like saying: /path/to/file/**/file
void RecurseDirectory(kwsys_stl::string::size_type start,
const kwsys_stl::string& dir);
//! Add regular expression
void AddExpression(const kwsys_stl::string& expr);
//! Add a file to the list
void AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl::string& file);
GlobInternals* Internals;
bool Recurse;
kwsys_stl::string Relative;
bool RecurseThroughSymlinks;
unsigned int FollowedSymlinkCount;
private:
Glob(const Glob&); // Not implemented.
void operator=(const Glob&); // Not implemented.
};
} // namespace @KWSYS_NAMESPACE@
/* Undefine temporary macro. */
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# undef kwsys_stl
#endif
#endif