]>
Commit | Line | Data |
---|---|---|
1 | // Boost string_algo library formatter_regex.hpp header file ---------------------------// | |
2 | ||
3 | // Copyright Pavol Droba 2002-2003. | |
4 | // | |
5 | // Distributed under the Boost Software License, Version 1.0. | |
6 | // (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | // See http://www.boost.org/ for updates, documentation, and revision history. | |
10 | ||
11 | #ifndef BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP | |
12 | #define BOOST_STRING_FORMATTER_REGEX_DETAIL_HPP | |
13 | ||
14 | #include <boost/algorithm/string/config.hpp> | |
15 | #include <string> | |
16 | #include <boost/regex.hpp> | |
17 | #include <boost/algorithm/string/detail/finder_regex.hpp> | |
18 | ||
19 | namespace boost { | |
20 | namespace algorithm { | |
21 | namespace detail { | |
22 | ||
23 | // regex format functor -----------------------------------------// | |
24 | ||
25 | // regex format functor | |
26 | template<typename StringT> | |
27 | struct regex_formatF | |
28 | { | |
29 | private: | |
30 | typedef StringT result_type; | |
31 | typedef BOOST_STRING_TYPENAME StringT::value_type char_type; | |
32 | ||
33 | public: | |
34 | // Construction | |
35 | regex_formatF( const StringT& Fmt, match_flag_type Flags=format_default ) : | |
36 | m_Fmt(Fmt), m_Flags( Flags ) {} | |
37 | ||
38 | template<typename InputIteratorT> | |
39 | result_type operator()( | |
40 | const regex_search_result<InputIteratorT>& Replace ) const | |
41 | { | |
42 | if ( Replace.empty() ) | |
43 | { | |
44 | return result_type(); | |
45 | } | |
46 | else | |
47 | { | |
48 | return Replace.match_results().format( m_Fmt, m_Flags ); | |
49 | } | |
50 | } | |
51 | private: | |
52 | const StringT& m_Fmt; | |
53 | match_flag_type m_Flags; | |
54 | }; | |
55 | ||
56 | ||
57 | } // namespace detail | |
58 | } // namespace algorithm | |
59 | } // namespace boost | |
60 | ||
61 | #endif // BOOST_STRING_FORMATTER_DETAIL_HPP |