X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstrings%2Fregex.h;h=67925023e544e76cd3f594addd0693d2b860d2c4;hp=70f9ebb7f592a4e161c9b5df45430a676e738466;hb=817e584903996a041692640720a5a272d847a3c7;hpb=b42ed73a1b241c0e93ee03c43c4584b41c549bac diff --git a/source/strings/regex.h b/source/strings/regex.h index 70f9ebb..6792502 100644 --- a/source/strings/regex.h +++ b/source/strings/regex.h @@ -1,17 +1,23 @@ -/* $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 #include #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 @@ -67,7 +73,7 @@ The MATCH_ANY instruction consumes the input character and always succeeds. class Regex { private: - typedef std::string Code; + typedef std::basic_string Code; typedef unsigned short Count; typedef short Offset; typedef unsigned short Index; @@ -114,7 +120,7 @@ private: 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