Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function template replace_all_occurrences_with_wildcards

boost::unit_test::utils::replace_all_occurrences_with_wildcards — This algorithm replaces all occurrences of a string with basic wildcards with another (optionally containing wildcards as well).

Synopsis

// In header: <boost/test/utils/algorithm.hpp>


template<typename StringClass, typename ForwardIterator> 
  StringClass replace_all_occurrences_with_wildcards(StringClass str, 
                                                     ForwardIterator it_string_to_find, 
                                                     ForwardIterator it_string_to_find_end, 
                                                     ForwardIterator it_string_to_replace, 
                                                     ForwardIterator it_string_to_replace_end);

Description

The wildcard is the symbol '*'. Only a unique wildcard per string is supported. The replacement string may also contain a wildcard, in which case it is considered as a placeholder to the content of the wildcard in the source string. Example:

  • In order to replace the occurrences of 'time="some-variable-value"' to a constant string, one may use 'time="*"' as the string to search for, and 'time="0.0"' as the replacement string.

  • In order to replace the occurrences of 'file.cpp(XX)' per 'file.cpp:XX', where XX is a variable to keep, on may use 'file.cpp(*)' as the string to search for, and 'file.cpp:*' as the replacement string.

Parameters:

it_string_to_find

- iterator to the beginning of the substrings to replace

it_string_to_find_end

- iterator to the end of the substrings to replace

it_string_to_replace

- iterator to the beginning of the substrings to replace with

it_string_to_replace_end

- iterator to the end of the substrings to replace with

str

- string to transform


PrevUpHomeNext