Blame GNU/GNURegex.h

Packit a4aae4
Packit a4aae4
// -*- mode: c++; c-basic-offset:4 -*-
Packit a4aae4
Packit a4aae4
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
Packit a4aae4
// Access Protocol.
Packit a4aae4
Packit a4aae4
// Copyright (c) 2005 OPeNDAP, Inc.
Packit a4aae4
// Author: James Gallagher <jgallagher@opendap.org>
Packit a4aae4
//
Packit a4aae4
// This library is free software; you can redistribute it and/or
Packit a4aae4
// modify it under the terms of the GNU Lesser General Public
Packit a4aae4
// License as published by the Free Software Foundation; either
Packit a4aae4
// version 2.1 of the License, or (at your option) any later version.
Packit a4aae4
// 
Packit a4aae4
// This library is distributed in the hope that it will be useful,
Packit a4aae4
// but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a4aae4
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a4aae4
// Lesser General Public License for more details.
Packit a4aae4
// 
Packit a4aae4
// You should have received a copy of the GNU Lesser General Public
Packit a4aae4
// License along with this library; if not, write to the Free Software
Packit a4aae4
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit a4aae4
//
Packit a4aae4
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
Packit a4aae4
Packit a4aae4
#ifndef _Regex_h
Packit a4aae4
#define _Regex_h 1
Packit a4aae4
Packit a4aae4
namespace libdap
Packit a4aae4
{
Packit a4aae4
Packit a4aae4
/** a C++ interface to POSIX regular expression functions.
Packit a4aae4
Packit a4aae4
    @author James Gallagher <jgallagher@opendap.org> */
Packit a4aae4
class Regex
Packit a4aae4
{
Packit a4aae4
private:
Packit a4aae4
    // d_preg was a regex_t* but I needed to include both regex.h and config.h
Packit a4aae4
    // to make the gnulib code work. Because this header is installed (and is
Packit a4aae4
    // used by other libraries) it cannot include config.h, so I moved the 
Packit a4aae4
    // regex.h and config.h (among other) includes to the implementation. It
Packit a4aae4
    // would be cleaner to use a special class, but for one field that seems
Packit a4aae4
    // like overkill.
Packit a4aae4
    void *d_preg;
Packit a4aae4
    void init(const char *t);
Packit a4aae4
    
Packit a4aae4
public:
Packit a4aae4
    Regex(const char *t);
Packit a4aae4
    Regex(const char *t, int dummy);
Packit a4aae4
    ~Regex();
Packit a4aae4
Packit a4aae4
    /// Does the pattern match.
Packit a4aae4
    int match(const char* s, int len, int pos = 0);
Packit a4aae4
    /// How much of the string does the pattern match.
Packit a4aae4
    int search(const char* s, int len, int& matchlen, int pos = 0);
Packit a4aae4
};
Packit a4aae4
Packit a4aae4
} // namespace libdap
Packit a4aae4
Packit a4aae4
#endif