regex_find_format.hpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Boost string_algo library regex_find_format.hpp header file ---------------------------//
  2. // Copyright Pavol Droba 2002-2003.
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. // See http://www.boost.org/ for updates, documentation, and revision history.
  8. #ifndef BOOST_STRING_REGEX_FIND_FORMAT_HPP
  9. #define BOOST_STRING_REGEX_FIND_FORMAT_HPP
  10. #include <boost/algorithm/string/config.hpp>
  11. #include <boost/regex.hpp>
  12. #include <boost/algorithm/string/detail/finder_regex.hpp>
  13. #include <boost/algorithm/string/detail/formatter_regex.hpp>
  14. /*! \file
  15. Defines the \c regex_finder and \c regex_formatter generators. These two functors
  16. are designed to work together. \c regex_formatter uses additional information
  17. about a match contained in the regex_finder search result.
  18. */
  19. namespace boost {
  20. namespace algorithm {
  21. // regex_finder -----------------------------------------------//
  22. //! "Regex" finder
  23. /*!
  24. Construct the \c regex_finder. Finder uses the regex engine to search
  25. for a match.
  26. Result is given in \c regex_search_result. This is an extension
  27. of the iterator_range. In addition it contains match results
  28. from the \c regex_search algorithm.
  29. \param Rx A regular expression
  30. \param MatchFlags Regex search options
  31. \return An instance of the \c regex_finder object
  32. */
  33. template<
  34. typename CharT,
  35. typename RegexTraitsT>
  36. inline detail::find_regexF< basic_regex<CharT, RegexTraitsT> >
  37. regex_finder(
  38. const basic_regex<CharT, RegexTraitsT>& Rx,
  39. match_flag_type MatchFlags=match_default )
  40. {
  41. return detail::
  42. find_regexF<
  43. basic_regex<CharT, RegexTraitsT> >( Rx, MatchFlags );
  44. }
  45. // regex_formater ---------------------------------------------//
  46. //! Regex formatter
  47. /*!
  48. Construct the \c regex_formatter. Regex formatter uses the regex engine to
  49. format a match found by the \c regex_finder.
  50. This formatted it designed to closely cooperate with \c regex_finder.
  51. \param Format Regex format definition
  52. \param Flags Format flags
  53. \return An instance of the \c regex_formatter functor
  54. */
  55. template<
  56. typename CharT,
  57. typename TraitsT, typename AllocT >
  58. inline detail::regex_formatF< std::basic_string< CharT, TraitsT, AllocT > >
  59. regex_formatter(
  60. const std::basic_string<CharT, TraitsT, AllocT>& Format,
  61. match_flag_type Flags=format_default )
  62. {
  63. return
  64. detail::regex_formatF< std::basic_string<CharT, TraitsT, AllocT> >(
  65. Format,
  66. Flags );
  67. }
  68. } // namespace algorithm
  69. // pull the names to the boost namespace
  70. using algorithm::regex_finder;
  71. using algorithm::regex_formatter;
  72. } // namespace boost
  73. #endif // BOOST_STRING_REGEX_FIND_FORMAT_HPP