-/*\r
- *\r
- * Copyright (c) 2003\r
- * John Maddock\r
- *\r
- * Use, modification and distribution are subject to the \r
- * Boost Software License, Version 1.0. (See accompanying file \r
- * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
- *\r
- */\r
-\r
- /*\r
- * LOCATION: see http://www.boost.org for most recent version.\r
- * FILE u32regex_iterator.hpp\r
- * VERSION see <boost/version.hpp>\r
- * DESCRIPTION: Provides u32regex_iterator implementation.\r
- */\r
-\r
-#ifndef BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP\r
-#define BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP\r
-\r
-namespace boost{\r
-\r
-#ifdef BOOST_HAS_ABI_HEADERS\r
-# include BOOST_ABI_PREFIX\r
-#endif\r
-\r
-template <class BidirectionalIterator>\r
-class u32regex_iterator_implementation \r
-{\r
- typedef u32regex regex_type;\r
-\r
- match_results<BidirectionalIterator> what; // current match\r
- BidirectionalIterator base; // start of sequence\r
- BidirectionalIterator end; // end of sequence\r
- const regex_type re; // the expression\r
- match_flag_type flags; // flags for matching\r
-\r
-public:\r
- u32regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f)\r
- : base(), end(last), re(*p), flags(f){}\r
- bool init(BidirectionalIterator first)\r
- {\r
- base = first;\r
- return u32regex_search(first, end, what, re, flags, base);\r
- }\r
- bool compare(const u32regex_iterator_implementation& that)\r
- {\r
- if(this == &that) return true;\r
- return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second);\r
- }\r
- const match_results<BidirectionalIterator>& get()\r
- { return what; }\r
- bool next()\r
- {\r
- //if(what.prefix().first != what[0].second)\r
- // flags |= match_prev_avail;\r
- BidirectionalIterator next_start = what[0].second;\r
- match_flag_type f(flags);\r
- if(!what.length())\r
- f |= regex_constants::match_not_initial_null;\r
- //if(base != next_start)\r
- // f |= regex_constants::match_not_bob;\r
- bool result = u32regex_search(next_start, end, what, re, f, base);\r
- if(result)\r
- what.set_base(base);\r
- return result;\r
- }\r
-private:\r
- u32regex_iterator_implementation& operator=(const u32regex_iterator_implementation&);\r
-};\r
-\r
-template <class BidirectionalIterator>\r
-class u32regex_iterator \r
-#ifndef BOOST_NO_STD_ITERATOR\r
- : public std::iterator<\r
- std::forward_iterator_tag, \r
- match_results<BidirectionalIterator>,\r
- typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type,\r
- const match_results<BidirectionalIterator>*,\r
- const match_results<BidirectionalIterator>& > \r
-#endif\r
-{\r
-private:\r
- typedef u32regex_iterator_implementation<BidirectionalIterator> impl;\r
- typedef shared_ptr<impl> pimpl;\r
-public:\r
- typedef u32regex regex_type;\r
- typedef match_results<BidirectionalIterator> value_type;\r
- typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type \r
- difference_type;\r
- typedef const value_type* pointer;\r
- typedef const value_type& reference; \r
- typedef std::forward_iterator_tag iterator_category;\r
- \r
- u32regex_iterator(){}\r
- u32regex_iterator(BidirectionalIterator a, BidirectionalIterator b, \r
- const regex_type& re, \r
- match_flag_type m = match_default)\r
- : pdata(new impl(&re, b, m))\r
- {\r
- if(!pdata->init(a))\r
- {\r
- pdata.reset();\r
- }\r
- }\r
- u32regex_iterator(const u32regex_iterator& that)\r
- : pdata(that.pdata) {}\r
- u32regex_iterator& operator=(const u32regex_iterator& that)\r
- {\r
- pdata = that.pdata;\r
- return *this;\r
- }\r
- bool operator==(const u32regex_iterator& that)const\r
- { \r
- if((pdata.get() == 0) || (that.pdata.get() == 0))\r
- return pdata.get() == that.pdata.get();\r
- return pdata->compare(*(that.pdata.get())); \r
- }\r
- bool operator!=(const u32regex_iterator& that)const\r
- { return !(*this == that); }\r
- const value_type& operator*()const\r
- { return pdata->get(); }\r
- const value_type* operator->()const\r
- { return &(pdata->get()); }\r
- u32regex_iterator& operator++()\r
- {\r
- cow();\r
- if(0 == pdata->next())\r
- {\r
- pdata.reset();\r
- }\r
- return *this;\r
- }\r
- u32regex_iterator operator++(int)\r
- {\r
- u32regex_iterator result(*this);\r
- ++(*this);\r
- return result;\r
- }\r
-private:\r
-\r
- pimpl pdata;\r
-\r
- void cow()\r
- {\r
- // copy-on-write\r
- if(pdata.get() && !pdata.unique())\r
- {\r
- pdata.reset(new impl(*(pdata.get())));\r
- }\r
- }\r
-};\r
-\r
-typedef u32regex_iterator<const char*> utf8regex_iterator;\r
-typedef u32regex_iterator<const UChar*> utf16regex_iterator;\r
-typedef u32regex_iterator<const UChar32*> utf32regex_iterator;\r
-\r
-inline u32regex_iterator<const char*> make_u32regex_iterator(const char* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)\r
-{\r
- return u32regex_iterator<const char*>(p, p+std::strlen(p), e, m);\r
-}\r
-#ifndef BOOST_NO_WREGEX\r
-inline u32regex_iterator<const wchar_t*> make_u32regex_iterator(const wchar_t* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)\r
-{\r
- return u32regex_iterator<const wchar_t*>(p, p+std::wcslen(p), e, m);\r
-}\r
-#endif\r
-#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2)\r
-inline u32regex_iterator<const UChar*> make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)\r
-{\r
- return u32regex_iterator<const UChar*>(p, p+u_strlen(p), e, m);\r
-}\r
-#endif\r
-template <class charT, class Traits, class Alloc>\r
-inline u32regex_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)\r
-{\r
- typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;\r
- return u32regex_iterator<iter_type>(p.begin(), p.end(), e, m);\r
-}\r
-inline u32regex_iterator<const UChar*> make_u32regex_iterator(const UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)\r
-{\r
- return u32regex_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, m);\r
-}\r
-\r
-#ifdef BOOST_HAS_ABI_HEADERS\r
-# include BOOST_ABI_SUFFIX\r
-#endif\r
-\r
-} // namespace boost\r
-\r
-#endif // BOOST_REGEX_V4_REGEX_ITERATOR_HPP\r
-\r
+/*
+ *
+ * Copyright (c) 2003
+ * John Maddock
+ *
+ * Use, modification and distribution are subject to the
+ * Boost Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ *
+ */
+
+ /*
+ * LOCATION: see http://www.boost.org for most recent version.
+ * FILE u32regex_iterator.hpp
+ * VERSION see <boost/version.hpp>
+ * DESCRIPTION: Provides u32regex_iterator implementation.
+ */
+
+#ifndef BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP
+#define BOOST_REGEX_V4_U32REGEX_ITERATOR_HPP
+
+namespace boost{
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+template <class BidirectionalIterator>
+class u32regex_iterator_implementation
+{
+ typedef u32regex regex_type;
+
+ match_results<BidirectionalIterator> what; // current match
+ BidirectionalIterator base; // start of sequence
+ BidirectionalIterator end; // end of sequence
+ const regex_type re; // the expression
+ match_flag_type flags; // flags for matching
+
+public:
+ u32regex_iterator_implementation(const regex_type* p, BidirectionalIterator last, match_flag_type f)
+ : base(), end(last), re(*p), flags(f){}
+ bool init(BidirectionalIterator first)
+ {
+ base = first;
+ return u32regex_search(first, end, what, re, flags, base);
+ }
+ bool compare(const u32regex_iterator_implementation& that)
+ {
+ if(this == &that) return true;
+ return (&re.get_data() == &that.re.get_data()) && (end == that.end) && (flags == that.flags) && (what[0].first == that.what[0].first) && (what[0].second == that.what[0].second);
+ }
+ const match_results<BidirectionalIterator>& get()
+ { return what; }
+ bool next()
+ {
+ //if(what.prefix().first != what[0].second)
+ // flags |= match_prev_avail;
+ BidirectionalIterator next_start = what[0].second;
+ match_flag_type f(flags);
+ if(!what.length())
+ f |= regex_constants::match_not_initial_null;
+ //if(base != next_start)
+ // f |= regex_constants::match_not_bob;
+ bool result = u32regex_search(next_start, end, what, re, f, base);
+ if(result)
+ what.set_base(base);
+ return result;
+ }
+private:
+ u32regex_iterator_implementation& operator=(const u32regex_iterator_implementation&);
+};
+
+template <class BidirectionalIterator>
+class u32regex_iterator
+#ifndef BOOST_NO_STD_ITERATOR
+ : public std::iterator<
+ std::forward_iterator_tag,
+ match_results<BidirectionalIterator>,
+ typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type,
+ const match_results<BidirectionalIterator>*,
+ const match_results<BidirectionalIterator>& >
+#endif
+{
+private:
+ typedef u32regex_iterator_implementation<BidirectionalIterator> impl;
+ typedef shared_ptr<impl> pimpl;
+public:
+ typedef u32regex regex_type;
+ typedef match_results<BidirectionalIterator> value_type;
+ typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type
+ difference_type;
+ typedef const value_type* pointer;
+ typedef const value_type& reference;
+ typedef std::forward_iterator_tag iterator_category;
+
+ u32regex_iterator(){}
+ u32regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+ const regex_type& re,
+ match_flag_type m = match_default)
+ : pdata(new impl(&re, b, m))
+ {
+ if(!pdata->init(a))
+ {
+ pdata.reset();
+ }
+ }
+ u32regex_iterator(const u32regex_iterator& that)
+ : pdata(that.pdata) {}
+ u32regex_iterator& operator=(const u32regex_iterator& that)
+ {
+ pdata = that.pdata;
+ return *this;
+ }
+ bool operator==(const u32regex_iterator& that)const
+ {
+ if((pdata.get() == 0) || (that.pdata.get() == 0))
+ return pdata.get() == that.pdata.get();
+ return pdata->compare(*(that.pdata.get()));
+ }
+ bool operator!=(const u32regex_iterator& that)const
+ { return !(*this == that); }
+ const value_type& operator*()const
+ { return pdata->get(); }
+ const value_type* operator->()const
+ { return &(pdata->get()); }
+ u32regex_iterator& operator++()
+ {
+ cow();
+ if(0 == pdata->next())
+ {
+ pdata.reset();
+ }
+ return *this;
+ }
+ u32regex_iterator operator++(int)
+ {
+ u32regex_iterator result(*this);
+ ++(*this);
+ return result;
+ }
+private:
+
+ pimpl pdata;
+
+ void cow()
+ {
+ // copy-on-write
+ if(pdata.get() && !pdata.unique())
+ {
+ pdata.reset(new impl(*(pdata.get())));
+ }
+ }
+};
+
+typedef u32regex_iterator<const char*> utf8regex_iterator;
+typedef u32regex_iterator<const UChar*> utf16regex_iterator;
+typedef u32regex_iterator<const UChar32*> utf32regex_iterator;
+
+inline u32regex_iterator<const char*> make_u32regex_iterator(const char* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
+{
+ return u32regex_iterator<const char*>(p, p+std::strlen(p), e, m);
+}
+#ifndef BOOST_NO_WREGEX
+inline u32regex_iterator<const wchar_t*> make_u32regex_iterator(const wchar_t* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
+{
+ return u32regex_iterator<const wchar_t*>(p, p+std::wcslen(p), e, m);
+}
+#endif
+#if !defined(U_WCHAR_IS_UTF16) && (U_SIZEOF_WCHAR_T != 2)
+inline u32regex_iterator<const UChar*> make_u32regex_iterator(const UChar* p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
+{
+ return u32regex_iterator<const UChar*>(p, p+u_strlen(p), e, m);
+}
+#endif
+template <class charT, class Traits, class Alloc>
+inline u32regex_iterator<typename std::basic_string<charT, Traits, Alloc>::const_iterator> make_u32regex_iterator(const std::basic_string<charT, Traits, Alloc>& p, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
+{
+ typedef typename std::basic_string<charT, Traits, Alloc>::const_iterator iter_type;
+ return u32regex_iterator<iter_type>(p.begin(), p.end(), e, m);
+}
+inline u32regex_iterator<const UChar*> make_u32regex_iterator(const UnicodeString& s, const u32regex& e, regex_constants::match_flag_type m = regex_constants::match_default)
+{
+ return u32regex_iterator<const UChar*>(s.getBuffer(), s.getBuffer() + s.length(), e, m);
+}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+} // namespace boost
+
+#endif // BOOST_REGEX_V4_REGEX_ITERATOR_HPP
+