## Class template pattern_replacer

boost::log::expressions::pattern_replacer

## Synopsis

    // In header: <boost/log/expressions/formatters/char_decorator.hpp>

    template<typename CharT>
    class pattern_replacer {
    public:
      // types
      typedef void                           result_type;  // Result type.
      typedef CharT                          char_type;    // Character type.
      typedef std::basic_string< char_type > string_type;  // String type.

      // member classes/structs/unions

      // Lengths of source pattern and replacement.

      struct string_lengths {

        // public data members
        unsigned int from_len;
        unsigned int to_len;
      };

      // construct/copy/destruct
      template<typename RangeT> explicit pattern_replacer(RangeT const &);
      template<typename FromRangeT, typename ToRangeT>
        pattern_replacer(FromRangeT const &, ToRangeT const &);
      pattern_replacer(pattern_replacer const &);

      // public member functions
      result_type operator()(string_type &, typename string_type::size_type = 0) const;

      // private static functions
      static char_type * string_begin(char_type *);
      static const char_type * string_begin(const char_type *);
      template<typename RangeT>
        static range_const_iterator< RangeT >::type string_begin(RangeT const &);
      static char_type * string_end(char_type *);
      static const char_type * string_end(const char_type *);
      template<typename RangeT>
        static range_const_iterator< RangeT >::type string_end(RangeT const &);
    };

## Description

A simple character decorator implementation. This implementation replaces string patterns in the source string with the fixed replacements. Source patterns and replacements can be specified at the object construction.

### `pattern_replacer` public construct/copy/destruct

1.     template<typename RangeT>
         explicit pattern_replacer(RangeT const & decorations);

   Initializing constructor. Creates a pattern replacer with the specified decorations. The provided decorations must be a sequence of `std::pair` of strings. The first element of each pair is the source pattern, and the second one is the corresponding replacement.

2.     template<typename FromRangeT, typename ToRangeT>
         pattern_replacer(FromRangeT const & from, ToRangeT const & to);

   Initializing constructor. Creates a pattern replacer with decorations specified in form of two same-sized string sequences. Each `i`'th decoration will be `from[i]` -> `to[i]`.

3.     pattern_replacer(pattern_replacer const & that);

   Copy constructor.

### `pattern_replacer` public member functions

1.     result_type operator()(string_type & str,
                              typename string_type::size_type start_pos = 0) const;

   Applies string replacements starting from the specified position.

### `pattern_replacer` private static functions

1.     static char_type * string_begin(char_type * p);

2.     static const char_type * string_begin(const char_type * p);

3.     template<typename RangeT>
         static range_const_iterator< RangeT >::type string_begin(RangeT const & r);

4.     static char_type * string_end(char_type * p);

5.     static const char_type * string_end(const char_type * p);

6.     template<typename RangeT>
         static range_const_iterator< RangeT >::type string_end(RangeT const & r);