Update of /cvsroot/boost/boost/boost/xpressive
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29334/boost/xpressive
Modified Files:
regex_compiler.hpp
Log Message:
use regex_compiler::operator[] to register named regexes, so a dynamic regex
can invoke a static one
Index: regex_compiler.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_compiler.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- regex_compiler.hpp 12 Mar 2007 22:11:29 -0000 1.11
+++ regex_compiler.hpp 13 Mar 2007 06:41:51 -0000 1.12
@@ -16,6 +16,7 @@
#endif
#include <map>
+#include <stdexcept>
#include <boost/xpressive/basic_regex.hpp>
#include <boost/xpressive/detail/dynamic/parser.hpp>
#include <boost/xpressive/detail/dynamic/parse_charset.hpp>
@@ -105,7 +106,7 @@
string_iterator begin = pat.begin(), end = pat.end(), tmp = begin;
// Check if this regex is a named rule:
- std::string name;
+ string_type name;
if(token_group_begin == this->traits_.get_token(tmp, end) &&
detail::ensure(tmp != end, error_paren, "mismatched parenthesis") &&
token_rule_assign == this->traits_.get_group_type(tmp, end, name))
@@ -142,6 +143,35 @@
return *prex;
}
+ ///////////////////////////////////////////////////////////////////////////
+ // operator[]
+ /// Return a reference to the named regular expression. If no such named
+ /// regular expression exists, create a new regular expression and return
+ /// a reference to it.
+ ///
+ /// \param name A std::string containing the name of the regular
expression.
+ /// \pre The string is not empty.
+ /// \throw bad_alloc on allocation failure, invalid_argument for empty
string.
+ basic_regex<BidiIter> &operator [](string_type const &name)
+ {
+ if(name.empty())
+ {
+ throw std::invalid_argument("bad regular expression name");
+ }
+ return this->rules_[name];
+ }
+
+ /// \overload
+ ///
+ basic_regex<BidiIter> const &operator [](string_type const &name) const
+ {
+ if(name.empty())
+ {
+ throw std::invalid_argument("bad regular expression name");
+ }
+ return this->rules_[name];
+ }
+
private:
typedef typename string_type::const_iterator string_iterator;
@@ -211,7 +241,7 @@
bool lookahead = false;
bool lookbehind = false;
bool negative = false;
- std::string name;
+ string_type name;
detail::sequence<BidiIter> seq, seq_end;
string_iterator tmp = string_iterator();
@@ -593,7 +623,7 @@
CompilerTraits traits_;
typename RegexTraits::char_class_type upper_;
shared_ptr<detail::regex_impl<BidiIter> > self_;
- std::map<std::string, basic_regex<BidiIter> > rules_;
+ std::map<string_type, basic_regex<BidiIter> > rules_;
};
}} // namespace boost::xpressive
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs