summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/RegularExpression.hxx.in
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-11-09 14:23:18 (GMT)
committerBrad King <brad.king@kitware.com>2016-11-09 14:23:18 (GMT)
commit95a97a40e48a0db2b206c4560d6962be3666812c (patch)
treee7f6f0e6ffca54ee18f8c276735e8a60e45f8833 /Source/kwsys/RegularExpression.hxx.in
parent666bb0e3fa0d212c03f785bd9f6bc05d29925e1f (diff)
parent773b36e5d4af3ac040625e0ea16bcfd30fcdeb6d (diff)
downloadCMake-95a97a40e48a0db2b206c4560d6962be3666812c.zip
CMake-95a97a40e48a0db2b206c4560d6962be3666812c.tar.gz
CMake-95a97a40e48a0db2b206c4560d6962be3666812c.tar.bz2
Merge branch 'upstream-KWSys' into update-kwsys
* upstream-KWSys: KWSys 2016-11-09 (18c65411)
Diffstat (limited to 'Source/kwsys/RegularExpression.hxx.in')
-rw-r--r--Source/kwsys/RegularExpression.hxx.in148
1 files changed, 65 insertions, 83 deletions
diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in
index 0bb700f..606e3da 100644
--- a/Source/kwsys/RegularExpression.hxx.in
+++ b/Source/kwsys/RegularExpression.hxx.in
@@ -1,14 +1,5 @@
-/*============================================================================
- 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.
-============================================================================*/
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
// Original Copyright notice:
// Copyright (C) 1991 Texas Instruments Incorporated.
//
@@ -38,11 +29,10 @@
/* Disable useless Borland warnings. KWSys tries not to force things
on its includers, but there is no choice here. */
#if defined(__BORLANDC__)
-# pragma warn -8027 /* function not inlined. */
+#pragma warn - 8027 /* function not inlined. */
#endif
-namespace @KWSYS_NAMESPACE@
-{
+namespace @KWSYS_NAMESPACE@ {
/** \class RegularExpression
* \brief Implements pattern matching with regular expressions.
@@ -68,10 +58,10 @@ namespace @KWSYS_NAMESPACE@
* and utilities.
*
* Example: The perl code
- *
+ *
* $filename =~ m"([a-z]+)\.cc";
* print $1;
- *
+ *
* Is written as follows in C++
*
* RegularExpression re("([a-z]+)\\.cc");
@@ -181,28 +171,28 @@ namespace @KWSYS_NAMESPACE@
* the line. It would match "drepa qrepb" in "rep drepa qrepb".
*
*/
-class @KWSYS_NAMESPACE@_EXPORT RegularExpression
+class @KWSYS_NAMESPACE@_EXPORT RegularExpression
{
public:
/**
* Instantiate RegularExpression with program=NULL.
*/
- inline RegularExpression ();
+ inline RegularExpression();
/**
* Instantiate RegularExpression with compiled char*.
*/
- inline RegularExpression (char const*);
+ inline RegularExpression(char const*);
/**
* Instantiate RegularExpression as a copy of another regular expression.
*/
- RegularExpression (RegularExpression const&);
+ RegularExpression(RegularExpression const&);
/**
* Instantiate RegularExpression with compiled string.
*/
- inline RegularExpression (std::string const&);
+ inline RegularExpression(std::string const&);
/**
* Destructor.
@@ -213,25 +203,25 @@ public:
* Compile a regular expression into internal code
* for later pattern matching.
*/
- bool compile (char const*);
+ bool compile(char const*);
/**
* Compile a regular expression into internal code
* for later pattern matching.
*/
- inline bool compile (std::string const&);
+ inline bool compile(std::string const&);
/**
* Matches the regular expression to the given string.
* Returns true if found, and sets start and end indexes accordingly.
*/
- bool find (char const*);
+ bool find(char const*);
/**
* Matches the regular expression to the given std string.
* Returns true if found, and sets start and end indexes accordingly.
*/
- inline bool find (std::string const&);
+ inline bool find(std::string const&);
/**
* Index to start of first find.
@@ -246,26 +236,26 @@ public:
/**
* Copy the given regular expression.
*/
- RegularExpression& operator= (const RegularExpression& rxp);
+ RegularExpression& operator=(const RegularExpression& rxp);
/**
* Returns true if two regular expressions have the same
* compiled program for pattern matching.
*/
- bool operator== (RegularExpression const&) const;
+ bool operator==(RegularExpression const&) const;
/**
* Returns true if two regular expressions have different
* compiled program for pattern matching.
*/
- inline bool operator!= (RegularExpression const&) const;
+ inline bool operator!=(RegularExpression const&) const;
/**
* Returns true if have the same compiled regular expressions
* and the same start and end pointers.
*/
- bool deep_equal (RegularExpression const&) const;
-
+ bool deep_equal(RegularExpression const&) const;
+
/**
* True if the compiled regexp is valid.
*/
@@ -274,7 +264,7 @@ public:
/**
* Marks the regular expression as invalid.
*/
- inline void set_invalid();
+ inline void set_invalid();
/**
* Destructor.
@@ -283,25 +273,29 @@ public:
std::string::size_type start(int n) const;
std::string::size_type end(int n) const;
std::string match(int n) const;
-
- enum { NSUBEXP = 10 };
-private:
+
+ enum
+ {
+ NSUBEXP = 10
+ };
+
+private:
const char* startp[NSUBEXP];
const char* endp[NSUBEXP];
- char regstart; // Internal use only
- char reganch; // Internal use only
- const char* regmust; // Internal use only
- std::string::size_type regmlen; // Internal use only
- char* program;
- int progsize;
+ char regstart; // Internal use only
+ char reganch; // Internal use only
+ const char* regmust; // Internal use only
+ std::string::size_type regmlen; // Internal use only
+ char* program;
+ int progsize;
const char* searchstring;
};
/**
* Create an empty regular expression.
*/
-inline RegularExpression::RegularExpression ()
-{
+inline RegularExpression::RegularExpression()
+{
this->program = 0;
}
@@ -309,20 +303,19 @@ inline RegularExpression::RegularExpression ()
* Creates a regular expression from string s, and
* compiles s.
*/
-inline RegularExpression::RegularExpression (const char* s)
-{
+inline RegularExpression::RegularExpression(const char* s)
+{
this->program = 0;
- if ( s )
- {
+ if (s) {
this->compile(s);
- }
+ }
}
/**
* Creates a regular expression from string s, and
* compiles s.
*/
-inline RegularExpression::RegularExpression (const std::string& s)
+inline RegularExpression::RegularExpression(const std::string& s)
{
this->program = 0;
this->compile(s);
@@ -331,18 +324,18 @@ inline RegularExpression::RegularExpression (const std::string& s)
/**
* Destroys and frees space allocated for the regular expression.
*/
-inline RegularExpression::~RegularExpression ()
+inline RegularExpression::~RegularExpression()
{
-//#ifndef _WIN32
- delete [] this->program;
-//#endif
+ //#ifndef _WIN32
+ delete[] this->program;
+ //#endif
}
/**
* Compile a regular expression into internal code
* for later pattern matching.
*/
-inline bool RegularExpression::compile (std::string const& s)
+inline bool RegularExpression::compile(std::string const& s)
{
return this->compile(s.c_str());
}
@@ -351,7 +344,7 @@ inline bool RegularExpression::compile (std::string const& s)
* Matches the regular expression to the given std string.
* Returns true if found, and sets start and end indexes accordingly.
*/
-inline bool RegularExpression::find (std::string const& s)
+inline bool RegularExpression::find(std::string const& s)
{
return this->find(s.c_str());
}
@@ -359,46 +352,42 @@ inline bool RegularExpression::find (std::string const& s)
/**
* Set the start position for the regular expression.
*/
-inline std::string::size_type RegularExpression::start () const
+inline std::string::size_type RegularExpression::start() const
{
- return static_cast<std::string::size_type>(
- this->startp[0] - searchstring);
+ return static_cast<std::string::size_type>(this->startp[0] - searchstring);
}
-
/**
* Returns the start/end index of the last item found.
*/
-inline std::string::size_type RegularExpression::end () const
+inline std::string::size_type RegularExpression::end() const
{
- return static_cast<std::string::size_type>(
- this->endp[0] - searchstring);
+ return static_cast<std::string::size_type>(this->endp[0] - searchstring);
}
/**
* Returns true if two regular expressions have different
* compiled program for pattern matching.
*/
-inline bool RegularExpression::operator!= (const RegularExpression& r) const
+inline bool RegularExpression::operator!=(const RegularExpression& r) const
{
- return(!(*this == r));
+ return (!(*this == r));
}
/**
* Returns true if a valid regular expression is compiled
* and ready for pattern matching.
*/
-inline bool RegularExpression::is_valid () const
+inline bool RegularExpression::is_valid() const
{
return (this->program != 0);
}
-
-inline void RegularExpression::set_invalid ()
+inline void RegularExpression::set_invalid()
{
-//#ifndef _WIN32
- delete [] this->program;
-//#endif
+ //#ifndef _WIN32
+ delete[] this->program;
+ //#endif
this->program = 0;
}
@@ -407,18 +396,15 @@ inline void RegularExpression::set_invalid ()
*/
inline std::string::size_type RegularExpression::start(int n) const
{
- return static_cast<std::string::size_type>(
- this->startp[n] - searchstring);
+ return static_cast<std::string::size_type>(this->startp[n] - searchstring);
}
-
/**
* Return end index of nth submatch. end(0) is the end of the full match.
*/
inline std::string::size_type RegularExpression::end(int n) const
{
- return static_cast<std::string::size_type>(
- this->endp[n] - searchstring);
+ return static_cast<std::string::size_type>(this->endp[n] - searchstring);
}
/**
@@ -426,16 +412,12 @@ inline std::string::size_type RegularExpression::end(int n) const
*/
inline std::string RegularExpression::match(int n) const
{
- if (this->startp[n]==0)
- {
+ if (this->startp[n] == 0) {
return std::string("");
- }
- else
- {
- return std::string(this->startp[n],
- static_cast<std::string::size_type>(
- this->endp[n] - this->startp[n]));
- }
+ } else {
+ return std::string(this->startp[n], static_cast<std::string::size_type>(
+ this->endp[n] - this->startp[n]));
+ }
}
} // namespace @KWSYS_NAMESPACE@