diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-06-01 08:48:42 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-06-01 09:24:28 (GMT) |
commit | 2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch) | |
tree | d46294f35150c4f0f43deaf2d31fceaf945ae715 /3rdParty/Boost/boost/regex/v4/regex_replace.hpp | |
download | swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip swift-contrib-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2 |
Import.
Diffstat (limited to '3rdParty/Boost/boost/regex/v4/regex_replace.hpp')
-rw-r--r-- | 3rdParty/Boost/boost/regex/v4/regex_replace.hpp | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/3rdParty/Boost/boost/regex/v4/regex_replace.hpp b/3rdParty/Boost/boost/regex/v4/regex_replace.hpp new file mode 100644 index 0000000..c4544c0 --- /dev/null +++ b/3rdParty/Boost/boost/regex/v4/regex_replace.hpp @@ -0,0 +1,122 @@ +/* + * + * Copyright (c) 1998-2002 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + /* + * LOCATION: see http://www.boost.org for most recent version. + * FILE regex_format.hpp + * VERSION see <boost/version.hpp> + * DESCRIPTION: Provides formatting output routines for search and replace + * operations. Note this is an internal header file included + * by regex.hpp, do not include on its own. + */ + +#ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP +#define BOOST_REGEX_V4_REGEX_REPLACE_HPP + + +namespace boost{ + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +template <class OutputIterator, class BidirectionalIterator, class traits, class charT> +OutputIterator regex_replace(OutputIterator out, + BidirectionalIterator first, + BidirectionalIterator last, + const basic_regex<charT, traits>& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags); + regex_iterator<BidirectionalIterator, charT, traits> j; + if(i == j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(first, last, out); + } + else + { + BidirectionalIterator last_m(first); + while(i != j) + { + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(i->prefix().first, i->prefix().second, out); + out = i->format(out, fmt, flags, e); + last_m = (*i)[0].second; + if(flags & regex_constants::format_first_only) + break; + ++i; + } + if(!(flags & regex_constants::format_no_copy)) + out = re_detail::copy(last_m, last, out); + } + return out; +} + +template <class OutputIterator, class Iterator, class traits, class charT> +inline OutputIterator regex_replace(OutputIterator out, + Iterator first, + Iterator last, + const basic_regex<charT, traits>& e, + const std::basic_string<charT>& fmt, + match_flag_type flags = match_default) +{ + return regex_replace(out, first, last, e, fmt.c_str(), flags); +} + +template <class traits, class charT> +std::basic_string<charT> regex_replace(const std::basic_string<charT>& s, + const basic_regex<charT, traits>& e, + const charT* fmt, + match_flag_type flags = match_default) +{ + std::basic_string<charT> result; + re_detail::string_out_iterator<std::basic_string<charT> > i(result); + regex_replace(i, s.begin(), s.end(), e, fmt, flags); + return result; +} + +template <class traits, class charT> +std::basic_string<charT> regex_replace(const std::basic_string<charT>& s, + const basic_regex<charT, traits>& e, + const std::basic_string<charT>& fmt, + match_flag_type flags = match_default) +{ + std::basic_string<charT> result; + re_detail::string_out_iterator<std::basic_string<charT> > i(result); + regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags); + return result; +} + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable: 4103) +#endif +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace boost + +#endif // BOOST_REGEX_V4_REGEX_REPLACE_HPP + + |