/usr/include/shevek/regexp.hh is in libshevek-dev 1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | /* regexp.hh - regular expressions
* Copyright 2004 Bas Wijnen <wijnen@debian.org>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHEVEK_REGEXP_HH
#define SHEVEK_REGEXP_HH
#include <glibmm.h>
#include <sys/types.h>
#include <regex.h>
#include "debug.hh"
namespace shevek
{
/// Use regular expressions.
class regexp
{
regex_t m_buffer;
bool m_case_sensitive;
regmatch_t *m_match;
unsigned m_size;
std::string m_pattern, m_data;
void l_setup (std::string const &pattern, bool destroy);
public:
/// Create a new object, and optionally fill it with a pattern.
regexp (std::string const &pattern = std::string (),
bool case_sensitive = false);
/// Set a pattern, removing the previous one.
regexp &operator= (std::string const &pattern);
/// Copy a regexp.
regexp (regexp const &that);
/// Copy a regexp.
regexp &operator= (regexp const &that);
/// Set whether the evaluation should be case sensitive.
void case_sensitive (bool value = true);
/// Destructor, this cleans up internal structures.
~regexp ();
/// Check whether the pattern matches a string, and fill internal match structures if it does.
bool operator() (std::string const &data);
/// Retrieve the value of a subexpression from the last matched string.
/** This throws an exception if the subexpression is not valid.
*/
std::string operator[] (unsigned idx) const;
/// Test whether a subexpression was filled by the last matching string.
bool valid (unsigned idx) const;
/// Get the number of subexpression.
unsigned size () const;
/// Transform a string with \-codes according to the last matching string.
std::string transform (std::string const &data) const;
/// Get the current pattern.
std::string const &pattern () const;
};
}
#endif
|