// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WREGEXP_H_
#define WREGEXP_H_

#include <Wt/WObject>
#include <Wt/WString>

#ifdef WT_HAVE_GNU_REGEX
#include <regex.h>
#else
#include <boost/regex.hpp>
#endif // WT_HAVE_GNU_REGEX

namespace Wt {

class WT_API WRegExp {
public:
  WRegExp();
  WRegExp(const WT_USTRING& pattern);
  ~WRegExp();

  void setPattern(const WT_USTRING& pattern, WFlags<RegExpFlag> flags);
  WT_USTRING pattern() const;
  WFlags<RegExpFlag> flags() const { return flags_; }

  bool isValid() const;

  bool exactMatch(const WT_USTRING& s) const;

private:
  WFlags<RegExpFlag> flags_;

#ifndef WT_HAVE_GNU_REGEX
  boost::regex rx_;
#else
  regex_t    rx_;
  WT_USTRING pattern_;
  bool       valid_;
#endif // WT_HAVE_GNU_REGEX
};

}

#endif // WREGEXP_H_
