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