]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/regex/mfc.hpp
boost: update to 1.42.0
[lyx.git] / boost / boost / regex / mfc.hpp
index 900d9a78e1f6100b604a5a295e6ac2c0ab0c765b..02502f950480d7eacd71ef517d41ea852674e161 100644 (file)
-/*\r
- *\r
- * Copyright (c) 2004\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         mfc.hpp\r
-  *   VERSION      see <boost/version.hpp>\r
-  *   DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex.\r
-  */\r
-\r
-#ifndef BOOST_REGEX_MFC_HPP\r
-#define BOOST_REGEX_MFC_HPP\r
-\r
-#include <atlsimpstr.h>\r
-#include <boost/regex.hpp>\r
-\r
-namespace boost{\r
-\r
-//\r
-// define the types used for TCHAR's:\r
-typedef basic_regex<TCHAR> tregex;\r
-typedef match_results<TCHAR const*> tmatch;\r
-typedef regex_iterator<TCHAR const*> tregex_iterator;\r
-typedef regex_token_iterator<TCHAR const*> tregex_token_iterator;\r
-\r
-#if _MSC_VER >= 1310\r
-#define SIMPLE_STRING_PARAM class B, bool b\r
-#define SIMPLE_STRING_ARG_LIST B, b\r
-#else\r
-#define SIMPLE_STRING_PARAM class B\r
-#define SIMPLE_STRING_ARG_LIST B\r
-#endif\r
-\r
-//\r
-// define regex creation functions:\r
-//\r
-template <SIMPLE_STRING_PARAM>\r
-inline basic_regex<B> \r
-make_regex(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal)\r
-{\r
-   basic_regex<B> result(s.GetString(), s.GetString() + s.GetLength(), f);\r
-   return result;\r
-}\r
-//\r
-// regex_match overloads:\r
-//\r
-template <SIMPLE_STRING_PARAM, class A, class T>\r
-inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,\r
-                 match_results<const B*, A>& what,\r
-                 const basic_regex<B, T>& e,\r
-                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   return ::boost::regex_match(s.GetString(),\r
-                               s.GetString() + s.GetLength(),\r
-                               what,\r
-                               e,\r
-                               f);\r
-}\r
-\r
-template <SIMPLE_STRING_PARAM, class T>\r
-inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,\r
-                 const basic_regex<B, T>& e,\r
-                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   return ::boost::regex_match(s.GetString(),\r
-                               s.GetString() + s.GetLength(),\r
-                               e,\r
-                               f);\r
-}\r
-//\r
-// regex_search overloads:\r
-//\r
-template <SIMPLE_STRING_PARAM, class A, class T>\r
-inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,\r
-                 match_results<const B*, A>& what,\r
-                 const basic_regex<B, T>& e,\r
-                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   return ::boost::regex_search(s.GetString(),\r
-                               s.GetString() + s.GetLength(),\r
-                               what,\r
-                               e,\r
-                               f);\r
-}\r
-\r
-template <SIMPLE_STRING_PARAM, class T>\r
-inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,\r
-                 const basic_regex<B, T>& e,\r
-                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   return ::boost::regex_search(s.GetString(),\r
-                               s.GetString() + s.GetLength(),\r
-                               e,\r
-                               f);\r
-}\r
-//\r
-// regex_iterator creation:\r
-//\r
-template <SIMPLE_STRING_PARAM>\r
-inline regex_iterator<B const*> \r
-make_regex_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   regex_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, f);\r
-   return result;\r
-}\r
-\r
-template <SIMPLE_STRING_PARAM>\r
-inline regex_token_iterator<B const*> \r
-   make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, int sub = 0, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f);\r
-   return result;\r
-}\r
-\r
-template <SIMPLE_STRING_PARAM>\r
-inline regex_token_iterator<B const*> \r
-make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const std::vector<int>& subs, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);\r
-   return result;\r
-}\r
-\r
-template <SIMPLE_STRING_PARAM, std::size_t N>\r
-inline regex_token_iterator<B const*> \r
-make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const int (& subs)[N], ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)\r
-{\r
-   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);\r
-   return result;\r
-}\r
-\r
-template <class OutputIterator, class BidirectionalIterator, class traits,\r
-          SIMPLE_STRING_PARAM>\r
-OutputIterator regex_replace(OutputIterator out,\r
-                           BidirectionalIterator first,\r
-                           BidirectionalIterator last,\r
-                           const basic_regex<B, traits>& e,\r
-                           const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,\r
-                           match_flag_type flags = match_default)\r
-{\r
-   return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags);\r
-}\r
-\r
-namespace re_detail{\r
-\r
-template <SIMPLE_STRING_PARAM>\r
-class mfc_string_out_iterator\r
-{\r
-   ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>* out;\r
-public:\r
-   mfc_string_out_iterator(ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s) : out(&s) {}\r
-   mfc_string_out_iterator& operator++() { return *this; }\r
-   mfc_string_out_iterator& operator++(int) { return *this; }\r
-   mfc_string_out_iterator& operator*() { return *this; }\r
-   mfc_string_out_iterator& operator=(B v) \r
-   { \r
-      out->AppendChar(v); \r
-      return *this; \r
-   }\r
-   typedef std::ptrdiff_t difference_type;\r
-   typedef B value_type;\r
-   typedef value_type* pointer;\r
-   typedef value_type& reference;\r
-   typedef std::output_iterator_tag iterator_category;\r
-};\r
-\r
-}\r
-\r
-template <class traits, SIMPLE_STRING_PARAM>\r
-ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> regex_replace(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,\r
-                            const basic_regex<B, traits>& e,\r
-                            const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,\r
-                            match_flag_type flags = match_default)\r
-{\r
-   ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> result(s.GetManager());\r
-   re_detail::mfc_string_out_iterator<SIMPLE_STRING_ARG_LIST> i(result);\r
-   regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags);\r
-   return result;\r
-}\r
-\r
-} // namespace boost.\r
-\r
-#endif\r
+/*
+ *
+ * Copyright (c) 2004
+ * 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         mfc.hpp
+  *   VERSION      see <boost/version.hpp>
+  *   DESCRIPTION: Overloads and helpers for using MFC/ATL string types with Boost.Regex.
+  */
+
+#ifndef BOOST_REGEX_MFC_HPP
+#define BOOST_REGEX_MFC_HPP
+
+#include <atlsimpstr.h>
+#include <boost/regex.hpp>
+
+namespace boost{
+
+//
+// define the types used for TCHAR's:
+typedef basic_regex<TCHAR> tregex;
+typedef match_results<TCHAR const*> tmatch;
+typedef regex_iterator<TCHAR const*> tregex_iterator;
+typedef regex_token_iterator<TCHAR const*> tregex_token_iterator;
+
+#if _MSC_VER >= 1310
+#define SIMPLE_STRING_PARAM class B, bool b
+#define SIMPLE_STRING_ARG_LIST B, b
+#else
+#define SIMPLE_STRING_PARAM class B
+#define SIMPLE_STRING_ARG_LIST B
+#endif
+
+//
+// define regex creation functions:
+//
+template <SIMPLE_STRING_PARAM>
+inline basic_regex<B> 
+make_regex(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, ::boost::regex_constants::syntax_option_type f = boost::regex_constants::normal)
+{
+   basic_regex<B> result(s.GetString(), s.GetString() + s.GetLength(), f);
+   return result;
+}
+//
+// regex_match overloads:
+//
+template <SIMPLE_STRING_PARAM, class A, class T>
+inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
+                 match_results<const B*, A>& what,
+                 const basic_regex<B, T>& e,
+                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   return ::boost::regex_match(s.GetString(),
+                               s.GetString() + s.GetLength(),
+                               what,
+                               e,
+                               f);
+}
+
+template <SIMPLE_STRING_PARAM, class T>
+inline bool regex_match(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
+                 const basic_regex<B, T>& e,
+                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   return ::boost::regex_match(s.GetString(),
+                               s.GetString() + s.GetLength(),
+                               e,
+                               f);
+}
+//
+// regex_search overloads:
+//
+template <SIMPLE_STRING_PARAM, class A, class T>
+inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
+                 match_results<const B*, A>& what,
+                 const basic_regex<B, T>& e,
+                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   return ::boost::regex_search(s.GetString(),
+                               s.GetString() + s.GetLength(),
+                               what,
+                               e,
+                               f);
+}
+
+template <SIMPLE_STRING_PARAM, class T>
+inline bool regex_search(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
+                 const basic_regex<B, T>& e,
+                 boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   return ::boost::regex_search(s.GetString(),
+                               s.GetString() + s.GetLength(),
+                               e,
+                               f);
+}
+//
+// regex_iterator creation:
+//
+template <SIMPLE_STRING_PARAM>
+inline regex_iterator<B const*> 
+make_regex_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   regex_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, f);
+   return result;
+}
+
+template <SIMPLE_STRING_PARAM>
+inline regex_token_iterator<B const*> 
+   make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, int sub = 0, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, sub, f);
+   return result;
+}
+
+template <SIMPLE_STRING_PARAM>
+inline regex_token_iterator<B const*> 
+make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const std::vector<int>& subs, ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
+   return result;
+}
+
+template <SIMPLE_STRING_PARAM, std::size_t N>
+inline regex_token_iterator<B const*> 
+make_regex_token_iterator(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s, const basic_regex<B>& e, const int (& subs)[N], ::boost::regex_constants::match_flag_type f = boost::regex_constants::match_default)
+{
+   regex_token_iterator<B const*> result(s.GetString(), s.GetString() + s.GetLength(), e, subs, f);
+   return result;
+}
+
+template <class OutputIterator, class BidirectionalIterator, class traits,
+          SIMPLE_STRING_PARAM>
+OutputIterator regex_replace(OutputIterator out,
+                           BidirectionalIterator first,
+                           BidirectionalIterator last,
+                           const basic_regex<B, traits>& e,
+                           const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
+                           match_flag_type flags = match_default)
+{
+   return ::boost::regex_replace(out, first, last, e, fmt.GetString(), flags);
+}
+
+namespace re_detail{
+
+template <SIMPLE_STRING_PARAM>
+class mfc_string_out_iterator
+{
+   ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>* out;
+public:
+   mfc_string_out_iterator(ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s) : out(&s) {}
+   mfc_string_out_iterator& operator++() { return *this; }
+   mfc_string_out_iterator& operator++(int) { return *this; }
+   mfc_string_out_iterator& operator*() { return *this; }
+   mfc_string_out_iterator& operator=(B v) 
+   { 
+      out->AppendChar(v); 
+      return *this; 
+   }
+   typedef std::ptrdiff_t difference_type;
+   typedef B value_type;
+   typedef value_type* pointer;
+   typedef value_type& reference;
+   typedef std::output_iterator_tag iterator_category;
+};
+
+}
+
+template <class traits, SIMPLE_STRING_PARAM>
+ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> regex_replace(const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& s,
+                            const basic_regex<B, traits>& e,
+                            const ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST>& fmt,
+                            match_flag_type flags = match_default)
+{
+   ATL::CSimpleStringT<SIMPLE_STRING_ARG_LIST> result(s.GetManager());
+   re_detail::mfc_string_out_iterator<SIMPLE_STRING_ARG_LIST> i(result);
+   regex_replace(i, s.GetString(), s.GetString() + s.GetLength(), e, fmt.GetString(), flags);
+   return result;
+}
+
+} // namespace boost.
+
+#endif