mirror of https://github.com/KLayout/klayout.git
136 lines
3.0 KiB
C++
136 lines
3.0 KiB
C++
|
|
/*
|
|
|
|
KLayout Layout Viewer
|
|
Copyright (C) 2006-2017 Matthias Koefferlein
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
#ifndef HDR_tlGlobPattern
|
|
#define HDR_tlGlobPattern
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "tlCommon.h"
|
|
|
|
namespace tl
|
|
{
|
|
|
|
/**
|
|
* @brief A class representing a glob pattern
|
|
*/
|
|
|
|
class TL_PUBLIC GlobPattern
|
|
{
|
|
public:
|
|
/**
|
|
* @brief The default constructor
|
|
*/
|
|
GlobPattern ();
|
|
|
|
/**
|
|
* @brief The constructor
|
|
*
|
|
* Creates a glob pattern form the given string
|
|
*/
|
|
GlobPattern (const std::string &p);
|
|
|
|
/**
|
|
* @brief Assignment of a string
|
|
*/
|
|
GlobPattern &operator= (const std::string &p)
|
|
{
|
|
m_p = p;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets a value indicating whether to treat the match case sensitive
|
|
*/
|
|
void set_case_sensitive (bool f);
|
|
|
|
/**
|
|
* @brief Gets a value indicating whether to treat the match case sensitive
|
|
*/
|
|
bool case_sensitive () const;
|
|
|
|
/**
|
|
* @brief Sets a value indicating whether to match exact (without brackets and wildcards)
|
|
*/
|
|
void set_exact (bool f);
|
|
|
|
/**
|
|
* @brief Gets a value indicating whether to match exact (without brackets and wildcards)
|
|
*/
|
|
bool exact () const;
|
|
|
|
/**
|
|
* @brief Sets a value indicating whether to allow trailing characters in the subject
|
|
*/
|
|
void set_header_match (bool f);
|
|
|
|
/**
|
|
* @brief Gets a value indicating whether to allow trailing characters in the subject
|
|
*/
|
|
bool header_match () const;
|
|
|
|
/**
|
|
* @brief Get the pattern string
|
|
*/
|
|
const std::string &pattern () const
|
|
{
|
|
return m_p;
|
|
}
|
|
|
|
/**
|
|
* @brief Match the given string
|
|
*
|
|
* Returns true, if the given subject string matches the glob pattern
|
|
*/
|
|
bool match (const std::string &s) const;
|
|
|
|
/**
|
|
* @brief Match the given string and extract the bracket expressions into the vector of substrings
|
|
*/
|
|
bool match (const std::string &s, std::vector<std::string> &e) const;
|
|
|
|
/**
|
|
* @brief Match the given string
|
|
*
|
|
* Returns true, if the given subject string matches the glob pattern
|
|
*/
|
|
bool match (const char *s) const;
|
|
|
|
/**
|
|
* @brief Match the given string and extract the bracket expressions into the vector of substrings
|
|
*/
|
|
bool match (const char *s, std::vector<std::string> &e) const;
|
|
|
|
private:
|
|
std::string m_p;
|
|
bool m_case_sensitive;
|
|
bool m_exact;
|
|
bool m_header_match;
|
|
};
|
|
|
|
} // namespace tl
|
|
|
|
#endif
|
|
|