-/* $Id$
-
-This file is part of libmspstrings
-Copyright © 2007 Mikko Rasa
-Distributed under the LGPL
-*/
#ifndef MSP_STRINGS_REGEX_H_
#define MSP_STRINGS_REGEX_H_
+#include <stdexcept>
#include <string>
#include "regmatch.h"
namespace Msp {
+class bad_regex: public std::logic_error
+{
+public:
+ bad_regex(const std::string &, const std::string &, const std::string::const_iterator &);
+ virtual ~bad_regex() throw() { }
+
+private:
+ std::string make_where(const std::string &, const std::string::const_iterator &);
+};
+
+
/**
This class provides regular expression matching. It supports a subset of
POSIX.2 extended regex syntax. Character classes, equivalence classes and
class Regex
{
private:
- typedef std::string Code;
+ typedef std::basic_string<unsigned char> Code;
typedef unsigned short Count;
typedef short Offset;
typedef unsigned short Index;
Code parse_atom(const std::string &, std::string::const_iterator &i, unsigned &);
Code parse_brackets(const std::string &, std::string::const_iterator &);
- bool parse_repeat(std::string::const_iterator &, Count &, Count &);
+ bool parse_repeat(const std::string &, std::string::const_iterator &, Count &, Count &);
public:
/** Matches the regex against a string. Refer to RegMatch documentation for