Include bind in ndnboost.
diff --git a/ndnboost/algorithm/string/compare.hpp b/ndnboost/algorithm/string/compare.hpp
new file mode 100644
index 0000000..e963120
--- /dev/null
+++ b/ndnboost/algorithm/string/compare.hpp
@@ -0,0 +1,199 @@
+// Boost string_algo library compare.hpp header file -------------------------//
+
+// Copyright Pavol Droba 2002-2006.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_COMPARE_HPP
+#define BOOST_STRING_COMPARE_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <locale>
+
+/*! \file
+ Defines element comparison predicates. Many algorithms in this library can
+ take an additional argument with a predicate used to compare elements.
+ This makes it possible, for instance, to have case insensitive versions
+ of the algorithms.
+*/
+
+namespace ndnboost {
+ namespace algorithm {
+
+ // is_equal functor -----------------------------------------------//
+
+ //! is_equal functor
+ /*!
+ Standard STL equal_to only handle comparison between arguments
+ of the same type. This is a less restrictive version which wraps operator ==.
+ */
+ struct is_equal
+ {
+ //! Function operator
+ /*!
+ Compare two operands for equality
+ */
+ template< typename T1, typename T2 >
+ bool operator()( const T1& Arg1, const T2& Arg2 ) const
+ {
+ return Arg1==Arg2;
+ }
+ };
+
+ //! case insensitive version of is_equal
+ /*!
+ Case insensitive comparison predicate. Comparison is done using
+ specified locales.
+ */
+ struct is_iequal
+ {
+ //! Constructor
+ /*!
+ \param Loc locales used for comparison
+ */
+ is_iequal( const std::locale& Loc=std::locale() ) :
+ m_Loc( Loc ) {}
+
+ //! Function operator
+ /*!
+ Compare two operands. Case is ignored.
+ */
+ template< typename T1, typename T2 >
+ bool operator()( const T1& Arg1, const T2& Arg2 ) const
+ {
+ #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
+ return std::toupper(Arg1)==std::toupper(Arg2);
+ #else
+ return std::toupper<T1>(Arg1,m_Loc)==std::toupper<T2>(Arg2,m_Loc);
+ #endif
+ }
+
+ private:
+ std::locale m_Loc;
+ };
+
+ // is_less functor -----------------------------------------------//
+
+ //! is_less functor
+ /*!
+ Convenient version of standard std::less. Operation is templated, therefore it is
+ not required to specify the exact types upon the construction
+ */
+ struct is_less
+ {
+ //! Functor operation
+ /*!
+ Compare two operands using > operator
+ */
+ template< typename T1, typename T2 >
+ bool operator()( const T1& Arg1, const T2& Arg2 ) const
+ {
+ return Arg1<Arg2;
+ }
+ };
+
+
+ //! case insensitive version of is_less
+ /*!
+ Case insensitive comparison predicate. Comparison is done using
+ specified locales.
+ */
+ struct is_iless
+ {
+ //! Constructor
+ /*!
+ \param Loc locales used for comparison
+ */
+ is_iless( const std::locale& Loc=std::locale() ) :
+ m_Loc( Loc ) {}
+
+ //! Function operator
+ /*!
+ Compare two operands. Case is ignored.
+ */
+ template< typename T1, typename T2 >
+ bool operator()( const T1& Arg1, const T2& Arg2 ) const
+ {
+ #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
+ return std::toupper(Arg1)<std::toupper(Arg2);
+ #else
+ return std::toupper<T1>(Arg1,m_Loc)<std::toupper<T2>(Arg2,m_Loc);
+ #endif
+ }
+
+ private:
+ std::locale m_Loc;
+ };
+
+ // is_not_greater functor -----------------------------------------------//
+
+ //! is_not_greater functor
+ /*!
+ Convenient version of standard std::not_greater_to. Operation is templated, therefore it is
+ not required to specify the exact types upon the construction
+ */
+ struct is_not_greater
+ {
+ //! Functor operation
+ /*!
+ Compare two operands using > operator
+ */
+ template< typename T1, typename T2 >
+ bool operator()( const T1& Arg1, const T2& Arg2 ) const
+ {
+ return Arg1<=Arg2;
+ }
+ };
+
+
+ //! case insensitive version of is_not_greater
+ /*!
+ Case insensitive comparison predicate. Comparison is done using
+ specified locales.
+ */
+ struct is_not_igreater
+ {
+ //! Constructor
+ /*!
+ \param Loc locales used for comparison
+ */
+ is_not_igreater( const std::locale& Loc=std::locale() ) :
+ m_Loc( Loc ) {}
+
+ //! Function operator
+ /*!
+ Compare two operands. Case is ignored.
+ */
+ template< typename T1, typename T2 >
+ bool operator()( const T1& Arg1, const T2& Arg2 ) const
+ {
+ #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
+ return std::toupper(Arg1)<=std::toupper(Arg2);
+ #else
+ return std::toupper<T1>(Arg1,m_Loc)<=std::toupper<T2>(Arg2,m_Loc);
+ #endif
+ }
+
+ private:
+ std::locale m_Loc;
+ };
+
+
+ } // namespace algorithm
+
+ // pull names to the boost namespace
+ using algorithm::is_equal;
+ using algorithm::is_iequal;
+ using algorithm::is_less;
+ using algorithm::is_iless;
+ using algorithm::is_not_greater;
+ using algorithm::is_not_igreater;
+
+} // namespace ndnboost
+
+
+#endif // BOOST_STRING_COMPARE_HPP
diff --git a/ndnboost/algorithm/string/concept.hpp b/ndnboost/algorithm/string/concept.hpp
new file mode 100644
index 0000000..31faa80
--- /dev/null
+++ b/ndnboost/algorithm/string/concept.hpp
@@ -0,0 +1,83 @@
+// Boost string_algo library concept.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_CONCEPT_HPP
+#define BOOST_STRING_CONCEPT_HPP
+
+#include <ndnboost/concept_check.hpp>
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/begin.hpp>
+#include <ndnboost/range/end.hpp>
+
+/*! \file
+ Defines concepts used in string_algo library
+*/
+
+namespace ndnboost {
+ namespace algorithm {
+
+ //! Finder concept
+ /*!
+ Defines the Finder concept. Finder is a functor which selects
+ an arbitrary part of a string. Search is performed on
+ the range specified by starting and ending iterators.
+
+ Result of the find operation must be convertible to iterator_range.
+ */
+ template<typename FinderT, typename IteratorT>
+ struct FinderConcept
+ {
+ private:
+ typedef iterator_range<IteratorT> range;
+ public:
+ void constraints()
+ {
+ // Operation
+ r=(*pF)(i,i);
+ }
+ private:
+ range r;
+ IteratorT i;
+ FinderT* pF;
+ }; // Finder_concept
+
+
+ //! Formatter concept
+ /*!
+ Defines the Formatter concept. Formatter is a functor, which
+ takes a result from a finder operation and transforms it
+ in a specific way.
+
+ Result must be a container supported by container_traits,
+ or a reference to it.
+ */
+ template<typename FormatterT, typename FinderT, typename IteratorT>
+ struct FormatterConcept
+ {
+ public:
+ void constraints()
+ {
+ // Operation
+ ::ndnboost::begin((*pFo)( (*pF)(i,i) ));
+ ::ndnboost::end((*pFo)( (*pF)(i,i) ));
+ }
+ private:
+ IteratorT i;
+ FinderT* pF;
+ FormatterT *pFo;
+ }; // FormatterConcept;
+
+ } // namespace algorithm
+} // namespace ndnboost
+
+
+
+
+#endif // BOOST_STRING_CONCEPT_HPP
diff --git a/ndnboost/algorithm/string/config.hpp b/ndnboost/algorithm/string/config.hpp
new file mode 100644
index 0000000..4ed3d05
--- /dev/null
+++ b/ndnboost/algorithm/string/config.hpp
@@ -0,0 +1,28 @@
+// Boost string_algo library config.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_CONFIG_HPP
+#define BOOST_STRING_CONFIG_HPP
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+#ifdef BOOST_STRING_DEDUCED_TYPENAME
+# error "macro already defined!"
+#endif
+
+#define BOOST_STRING_TYPENAME BOOST_DEDUCED_TYPENAME
+
+// Metrowerks workaround
+#if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) // 8.x
+#pragma parse_func_templ off
+#endif
+
+#endif // BOOST_STRING_CONFIG_HPP
diff --git a/ndnboost/algorithm/string/constants.hpp b/ndnboost/algorithm/string/constants.hpp
new file mode 100644
index 0000000..232d0d8
--- /dev/null
+++ b/ndnboost/algorithm/string/constants.hpp
@@ -0,0 +1,36 @@
+// Boost string_algo library constants.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_CONSTANTS_HPP
+#define BOOST_STRING_CONSTANTS_HPP
+
+namespace ndnboost {
+ namespace algorithm {
+
+ //! Token compression mode
+ /*!
+ Specifies token compression mode for the token_finder.
+ */
+ enum token_compress_mode_type
+ {
+ token_compress_on, //!< Compress adjacent tokens
+ token_compress_off //!< Do not compress adjacent tokens
+ };
+
+ } // namespace algorithm
+
+ // pull the names to the boost namespace
+ using algorithm::token_compress_on;
+ using algorithm::token_compress_off;
+
+} // namespace ndnboost
+
+#endif // BOOST_STRING_CONSTANTS_HPP
+
diff --git a/ndnboost/algorithm/string/detail/find_format.hpp b/ndnboost/algorithm/string/detail/find_format.hpp
new file mode 100644
index 0000000..395beaf
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/find_format.hpp
@@ -0,0 +1,204 @@
+// Boost string_algo library find_format.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FIND_FORMAT_DETAIL_HPP
+#define BOOST_STRING_FIND_FORMAT_DETAIL_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/const_iterator.hpp>
+#include <ndnboost/range/iterator.hpp>
+#include <ndnboost/algorithm/string/detail/find_format_store.hpp>
+#include <ndnboost/algorithm/string/detail/replace_storage.hpp>
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+// find_format_copy (iterator variant) implementation -------------------------------//
+
+ template<
+ typename OutputIteratorT,
+ typename InputT,
+ typename FormatterT,
+ typename FindResultT,
+ typename FormatResultT >
+ inline OutputIteratorT find_format_copy_impl2(
+ OutputIteratorT Output,
+ const InputT& Input,
+ FormatterT Formatter,
+ const FindResultT& FindResult,
+ const FormatResultT& FormatResult )
+ {
+ typedef find_format_store<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<InputT>::type,
+ FormatterT,
+ FormatResultT > store_type;
+
+ // Create store for the find result
+ store_type M( FindResult, FormatResult, Formatter );
+
+ if ( !M )
+ {
+ // Match not found - return original sequence
+ Output = std::copy( ::ndnboost::begin(Input), ::ndnboost::end(Input), Output );
+ return Output;
+ }
+
+ // Copy the beginning of the sequence
+ Output = std::copy( ::ndnboost::begin(Input), ::ndnboost::begin(M), Output );
+ // Format find result
+ // Copy formatted result
+ Output = std::copy( ::ndnboost::begin(M.format_result()), ::ndnboost::end(M.format_result()), Output );
+ // Copy the rest of the sequence
+ Output = std::copy( M.end(), ::ndnboost::end(Input), Output );
+
+ return Output;
+ }
+
+ template<
+ typename OutputIteratorT,
+ typename InputT,
+ typename FormatterT,
+ typename FindResultT >
+ inline OutputIteratorT find_format_copy_impl(
+ OutputIteratorT Output,
+ const InputT& Input,
+ FormatterT Formatter,
+ const FindResultT& FindResult )
+ {
+ if( ::ndnboost::algorithm::detail::check_find_result(Input, FindResult) ) {
+ return ::ndnboost::algorithm::detail::find_format_copy_impl2(
+ Output,
+ Input,
+ Formatter,
+ FindResult,
+ Formatter(FindResult) );
+ } else {
+ return std::copy( ::ndnboost::begin(Input), ::ndnboost::end(Input), Output );
+ }
+ }
+
+
+// find_format_copy implementation --------------------------------------------------//
+
+ template<
+ typename InputT,
+ typename FormatterT,
+ typename FindResultT,
+ typename FormatResultT >
+ inline InputT find_format_copy_impl2(
+ const InputT& Input,
+ FormatterT Formatter,
+ const FindResultT& FindResult,
+ const FormatResultT& FormatResult)
+ {
+ typedef find_format_store<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<InputT>::type,
+ FormatterT,
+ FormatResultT > store_type;
+
+ // Create store for the find result
+ store_type M( FindResult, FormatResult, Formatter );
+
+ if ( !M )
+ {
+ // Match not found - return original sequence
+ return InputT( Input );
+ }
+
+ InputT Output;
+ // Copy the beginning of the sequence
+ ndnboost::algorithm::detail::insert( Output, ::ndnboost::end(Output), ::ndnboost::begin(Input), M.begin() );
+ // Copy formatted result
+ ndnboost::algorithm::detail::insert( Output, ::ndnboost::end(Output), M.format_result() );
+ // Copy the rest of the sequence
+ ndnboost::algorithm::detail::insert( Output, ::ndnboost::end(Output), M.end(), ::ndnboost::end(Input) );
+
+ return Output;
+ }
+
+ template<
+ typename InputT,
+ typename FormatterT,
+ typename FindResultT >
+ inline InputT find_format_copy_impl(
+ const InputT& Input,
+ FormatterT Formatter,
+ const FindResultT& FindResult)
+ {
+ if( ::ndnboost::algorithm::detail::check_find_result(Input, FindResult) ) {
+ return ::ndnboost::algorithm::detail::find_format_copy_impl2(
+ Input,
+ Formatter,
+ FindResult,
+ Formatter(FindResult) );
+ } else {
+ return Input;
+ }
+ }
+
+ // replace implementation ----------------------------------------------------//
+
+ template<
+ typename InputT,
+ typename FormatterT,
+ typename FindResultT,
+ typename FormatResultT >
+ inline void find_format_impl2(
+ InputT& Input,
+ FormatterT Formatter,
+ const FindResultT& FindResult,
+ const FormatResultT& FormatResult)
+ {
+ typedef find_format_store<
+ BOOST_STRING_TYPENAME
+ range_iterator<InputT>::type,
+ FormatterT,
+ FormatResultT > store_type;
+
+ // Create store for the find result
+ store_type M( FindResult, FormatResult, Formatter );
+
+ if ( !M )
+ {
+ // Search not found - return original sequence
+ return;
+ }
+
+ // Replace match
+ ::ndnboost::algorithm::detail::replace( Input, M.begin(), M.end(), M.format_result() );
+ }
+
+ template<
+ typename InputT,
+ typename FormatterT,
+ typename FindResultT >
+ inline void find_format_impl(
+ InputT& Input,
+ FormatterT Formatter,
+ const FindResultT& FindResult)
+ {
+ if( ::ndnboost::algorithm::detail::check_find_result(Input, FindResult) ) {
+ ::ndnboost::algorithm::detail::find_format_impl2(
+ Input,
+ Formatter,
+ FindResult,
+ Formatter(FindResult) );
+ }
+ }
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+#endif // BOOST_STRING_FIND_FORMAT_DETAIL_HPP
diff --git a/ndnboost/algorithm/string/detail/find_format_all.hpp b/ndnboost/algorithm/string/detail/find_format_all.hpp
new file mode 100644
index 0000000..ee0312a
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/find_format_all.hpp
@@ -0,0 +1,273 @@
+// Boost string_algo library find_format_all.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
+#define BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/const_iterator.hpp>
+#include <ndnboost/range/value_type.hpp>
+#include <ndnboost/algorithm/string/detail/find_format_store.hpp>
+#include <ndnboost/algorithm/string/detail/replace_storage.hpp>
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+// find_format_all_copy (iterator variant) implementation ---------------------------//
+
+ template<
+ typename OutputIteratorT,
+ typename InputT,
+ typename FinderT,
+ typename FormatterT,
+ typename FindResultT,
+ typename FormatResultT >
+ inline OutputIteratorT find_format_all_copy_impl2(
+ OutputIteratorT Output,
+ const InputT& Input,
+ FinderT Finder,
+ FormatterT Formatter,
+ const FindResultT& FindResult,
+ const FormatResultT& FormatResult )
+ {
+ typedef BOOST_STRING_TYPENAME
+ range_const_iterator<InputT>::type input_iterator_type;
+
+ typedef find_format_store<
+ input_iterator_type,
+ FormatterT,
+ FormatResultT > store_type;
+
+ // Create store for the find result
+ store_type M( FindResult, FormatResult, Formatter );
+
+ // Initialize last match
+ input_iterator_type LastMatch=::ndnboost::begin(Input);
+
+ // Iterate through all matches
+ while( M )
+ {
+ // Copy the beginning of the sequence
+ Output = std::copy( LastMatch, M.begin(), Output );
+ // Copy formatted result
+ Output = std::copy( ::ndnboost::begin(M.format_result()), ::ndnboost::end(M.format_result()), Output );
+
+ // Proceed to the next match
+ LastMatch=M.end();
+ M=Finder( LastMatch, ::ndnboost::end(Input) );
+ }
+
+ // Copy the rest of the sequence
+ Output = std::copy( LastMatch, ::ndnboost::end(Input), Output );
+
+ return Output;
+ }
+
+ template<
+ typename OutputIteratorT,
+ typename InputT,
+ typename FinderT,
+ typename FormatterT,
+ typename FindResultT >
+ inline OutputIteratorT find_format_all_copy_impl(
+ OutputIteratorT Output,
+ const InputT& Input,
+ FinderT Finder,
+ FormatterT Formatter,
+ const FindResultT& FindResult )
+ {
+ if( ::ndnboost::algorithm::detail::check_find_result(Input, FindResult) ) {
+ return ::ndnboost::algorithm::detail::find_format_all_copy_impl2(
+ Output,
+ Input,
+ Finder,
+ Formatter,
+ FindResult,
+ Formatter(FindResult) );
+ } else {
+ return std::copy( ::ndnboost::begin(Input), ::ndnboost::end(Input), Output );
+ }
+ }
+
+ // find_format_all_copy implementation ----------------------------------------------//
+
+ template<
+ typename InputT,
+ typename FinderT,
+ typename FormatterT,
+ typename FindResultT,
+ typename FormatResultT >
+ inline InputT find_format_all_copy_impl2(
+ const InputT& Input,
+ FinderT Finder,
+ FormatterT Formatter,
+ const FindResultT& FindResult,
+ const FormatResultT& FormatResult)
+ {
+ typedef BOOST_STRING_TYPENAME
+ range_const_iterator<InputT>::type input_iterator_type;
+
+ typedef find_format_store<
+ input_iterator_type,
+ FormatterT,
+ FormatResultT > store_type;
+
+ // Create store for the find result
+ store_type M( FindResult, FormatResult, Formatter );
+
+ // Initialize last match
+ input_iterator_type LastMatch=::ndnboost::begin(Input);
+
+ // Output temporary
+ InputT Output;
+
+ // Iterate through all matches
+ while( M )
+ {
+ // Copy the beginning of the sequence
+ ndnboost::algorithm::detail::insert( Output, ::ndnboost::end(Output), LastMatch, M.begin() );
+ // Copy formatted result
+ ndnboost::algorithm::detail::insert( Output, ::ndnboost::end(Output), M.format_result() );
+
+ // Proceed to the next match
+ LastMatch=M.end();
+ M=Finder( LastMatch, ::ndnboost::end(Input) );
+ }
+
+ // Copy the rest of the sequence
+ ::ndnboost::algorithm::detail::insert( Output, ::ndnboost::end(Output), LastMatch, ::ndnboost::end(Input) );
+
+ return Output;
+ }
+
+ template<
+ typename InputT,
+ typename FinderT,
+ typename FormatterT,
+ typename FindResultT >
+ inline InputT find_format_all_copy_impl(
+ const InputT& Input,
+ FinderT Finder,
+ FormatterT Formatter,
+ const FindResultT& FindResult)
+ {
+ if( ::ndnboost::algorithm::detail::check_find_result(Input, FindResult) ) {
+ return ::ndnboost::algorithm::detail::find_format_all_copy_impl2(
+ Input,
+ Finder,
+ Formatter,
+ FindResult,
+ Formatter(FindResult) );
+ } else {
+ return Input;
+ }
+ }
+
+ // find_format_all implementation ------------------------------------------------//
+
+ template<
+ typename InputT,
+ typename FinderT,
+ typename FormatterT,
+ typename FindResultT,
+ typename FormatResultT >
+ inline void find_format_all_impl2(
+ InputT& Input,
+ FinderT Finder,
+ FormatterT Formatter,
+ FindResultT FindResult,
+ FormatResultT FormatResult)
+ {
+ typedef BOOST_STRING_TYPENAME
+ range_iterator<InputT>::type input_iterator_type;
+ typedef find_format_store<
+ input_iterator_type,
+ FormatterT,
+ FormatResultT > store_type;
+
+ // Create store for the find result
+ store_type M( FindResult, FormatResult, Formatter );
+
+ // Instantiate replacement storage
+ std::deque<
+ BOOST_STRING_TYPENAME range_value<InputT>::type> Storage;
+
+ // Initialize replacement iterators
+ input_iterator_type InsertIt=::ndnboost::begin(Input);
+ input_iterator_type SearchIt=::ndnboost::begin(Input);
+
+ while( M )
+ {
+ // process the segment
+ InsertIt=process_segment(
+ Storage,
+ Input,
+ InsertIt,
+ SearchIt,
+ M.begin() );
+
+ // Adjust search iterator
+ SearchIt=M.end();
+
+ // Copy formatted replace to the storage
+ ::ndnboost::algorithm::detail::copy_to_storage( Storage, M.format_result() );
+
+ // Find range for a next match
+ M=Finder( SearchIt, ::ndnboost::end(Input) );
+ }
+
+ // process the last segment
+ InsertIt=::ndnboost::algorithm::detail::process_segment(
+ Storage,
+ Input,
+ InsertIt,
+ SearchIt,
+ ::ndnboost::end(Input) );
+
+ if ( Storage.empty() )
+ {
+ // Truncate input
+ ::ndnboost::algorithm::detail::erase( Input, InsertIt, ::ndnboost::end(Input) );
+ }
+ else
+ {
+ // Copy remaining data to the end of input
+ ::ndnboost::algorithm::detail::insert( Input, ::ndnboost::end(Input), Storage.begin(), Storage.end() );
+ }
+ }
+
+ template<
+ typename InputT,
+ typename FinderT,
+ typename FormatterT,
+ typename FindResultT >
+ inline void find_format_all_impl(
+ InputT& Input,
+ FinderT Finder,
+ FormatterT Formatter,
+ FindResultT FindResult)
+ {
+ if( ::ndnboost::algorithm::detail::check_find_result(Input, FindResult) ) {
+ ::ndnboost::algorithm::detail::find_format_all_impl2(
+ Input,
+ Finder,
+ Formatter,
+ FindResult,
+ Formatter(FindResult) );
+ }
+ }
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+#endif // BOOST_STRING_FIND_FORMAT_ALL_DETAIL_HPP
diff --git a/ndnboost/algorithm/string/detail/find_format_store.hpp b/ndnboost/algorithm/string/detail/find_format_store.hpp
new file mode 100644
index 0000000..d0d38bf
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/find_format_store.hpp
@@ -0,0 +1,89 @@
+// Boost string_algo library find_format_store.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
+#define BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <ndnboost/range/iterator_range.hpp>
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+// temporary format and find result storage --------------------------------//
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(push)
+#pragma warning(disable:4512) //assignment operator could not be generated
+#endif
+ template<
+ typename ForwardIteratorT,
+ typename FormatterT,
+ typename FormatResultT >
+ class find_format_store :
+ public iterator_range<ForwardIteratorT>
+ {
+ public:
+ // typedefs
+ typedef iterator_range<ForwardIteratorT> base_type;
+ typedef FormatterT formatter_type;
+ typedef FormatResultT format_result_type;
+
+ public:
+ // Construction
+ find_format_store(
+ const base_type& FindResult,
+ const format_result_type& FormatResult,
+ const formatter_type& Formatter ) :
+ base_type(FindResult),
+ m_FormatResult(FormatResult),
+ m_Formatter(Formatter) {}
+
+ // Assignment
+ template< typename FindResultT >
+ find_format_store& operator=( FindResultT FindResult )
+ {
+ iterator_range<ForwardIteratorT>::operator=(FindResult);
+ if( !this->empty() ) {
+ m_FormatResult=m_Formatter(FindResult);
+ }
+
+ return *this;
+ }
+
+ // Retrieve format result
+ const format_result_type& format_result()
+ {
+ return m_FormatResult;
+ }
+
+ private:
+ format_result_type m_FormatResult;
+ const formatter_type& m_Formatter;
+ };
+
+ template<typename InputT, typename FindResultT>
+ bool check_find_result(InputT&, FindResultT& FindResult)
+ {
+ typedef BOOST_STRING_TYPENAME
+ range_const_iterator<InputT>::type input_iterator_type;
+ iterator_range<input_iterator_type> ResultRange(FindResult);
+ return !ResultRange.empty();
+ }
+
+#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
+#pragma warning(pop)
+#endif
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+#endif // BOOST_STRING_FIND_FORMAT_STORE_DETAIL_HPP
diff --git a/ndnboost/algorithm/string/detail/finder.hpp b/ndnboost/algorithm/string/detail/finder.hpp
new file mode 100644
index 0000000..330c7a5
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/finder.hpp
@@ -0,0 +1,646 @@
+// Boost string_algo library finder.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2006.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FINDER_DETAIL_HPP
+#define BOOST_STRING_FINDER_DETAIL_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <ndnboost/algorithm/string/constants.hpp>
+#include <ndnboost/detail/iterator.hpp>
+
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/begin.hpp>
+#include <ndnboost/range/end.hpp>
+#include <ndnboost/range/empty.hpp>
+#include <ndnboost/range/as_literal.hpp>
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+
+// find first functor -----------------------------------------------//
+
+ // find a subsequence in the sequence ( functor )
+ /*
+ Returns a pair <begin,end> marking the subsequence in the sequence.
+ If the find fails, functor returns <End,End>
+ */
+ template<typename SearchIteratorT,typename PredicateT>
+ struct first_finderF
+ {
+ typedef SearchIteratorT search_iterator_type;
+
+ // Construction
+ template< typename SearchT >
+ first_finderF( const SearchT& Search, PredicateT Comp ) :
+ m_Search(::ndnboost::begin(Search), ::ndnboost::end(Search)), m_Comp(Comp) {}
+ first_finderF(
+ search_iterator_type SearchBegin,
+ search_iterator_type SearchEnd,
+ PredicateT Comp ) :
+ m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {}
+
+ // Operation
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ operator()(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End ) const
+ {
+ typedef iterator_range<ForwardIteratorT> result_type;
+ typedef ForwardIteratorT input_iterator_type;
+
+ // Outer loop
+ for(input_iterator_type OuterIt=Begin;
+ OuterIt!=End;
+ ++OuterIt)
+ {
+ // Sanity check
+ if( ndnboost::empty(m_Search) )
+ return result_type( End, End );
+
+ input_iterator_type InnerIt=OuterIt;
+ search_iterator_type SubstrIt=m_Search.begin();
+ for(;
+ InnerIt!=End && SubstrIt!=m_Search.end();
+ ++InnerIt,++SubstrIt)
+ {
+ if( !( m_Comp(*InnerIt,*SubstrIt) ) )
+ break;
+ }
+
+ // Substring matching succeeded
+ if ( SubstrIt==m_Search.end() )
+ return result_type( OuterIt, InnerIt );
+ }
+
+ return result_type( End, End );
+ }
+
+ private:
+ iterator_range<search_iterator_type> m_Search;
+ PredicateT m_Comp;
+ };
+
+// find last functor -----------------------------------------------//
+
+ // find the last match a subsequence in the sequence ( functor )
+ /*
+ Returns a pair <begin,end> marking the subsequence in the sequence.
+ If the find fails, returns <End,End>
+ */
+ template<typename SearchIteratorT, typename PredicateT>
+ struct last_finderF
+ {
+ typedef SearchIteratorT search_iterator_type;
+ typedef first_finderF<
+ search_iterator_type,
+ PredicateT> first_finder_type;
+
+ // Construction
+ template< typename SearchT >
+ last_finderF( const SearchT& Search, PredicateT Comp ) :
+ m_Search(::ndnboost::begin(Search), ::ndnboost::end(Search)), m_Comp(Comp) {}
+ last_finderF(
+ search_iterator_type SearchBegin,
+ search_iterator_type SearchEnd,
+ PredicateT Comp ) :
+ m_Search(SearchBegin, SearchEnd), m_Comp(Comp) {}
+
+ // Operation
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ operator()(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End ) const
+ {
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ if( ndnboost::empty(m_Search) )
+ return result_type( End, End );
+
+ typedef BOOST_STRING_TYPENAME ndnboost::detail::
+ iterator_traits<ForwardIteratorT>::iterator_category category;
+
+ return findit( Begin, End, category() );
+ }
+
+ private:
+ // forward iterator
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ findit(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ std::forward_iterator_tag ) const
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ first_finder_type first_finder(
+ m_Search.begin(), m_Search.end(), m_Comp );
+
+ result_type M=first_finder( Begin, End );
+ result_type Last=M;
+
+ while( M )
+ {
+ Last=M;
+ M=first_finder( ::ndnboost::end(M), End );
+ }
+
+ return Last;
+ }
+
+ // bidirectional iterator
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ findit(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ std::bidirectional_iterator_tag ) const
+ {
+ typedef iterator_range<ForwardIteratorT> result_type;
+ typedef ForwardIteratorT input_iterator_type;
+
+ // Outer loop
+ for(input_iterator_type OuterIt=End;
+ OuterIt!=Begin; )
+ {
+ input_iterator_type OuterIt2=--OuterIt;
+
+ input_iterator_type InnerIt=OuterIt2;
+ search_iterator_type SubstrIt=m_Search.begin();
+ for(;
+ InnerIt!=End && SubstrIt!=m_Search.end();
+ ++InnerIt,++SubstrIt)
+ {
+ if( !( m_Comp(*InnerIt,*SubstrIt) ) )
+ break;
+ }
+
+ // Substring matching succeeded
+ if( SubstrIt==m_Search.end() )
+ return result_type( OuterIt2, InnerIt );
+ }
+
+ return result_type( End, End );
+ }
+
+ private:
+ iterator_range<search_iterator_type> m_Search;
+ PredicateT m_Comp;
+ };
+
+// find n-th functor -----------------------------------------------//
+
+ // find the n-th match of a subsequence in the sequence ( functor )
+ /*
+ Returns a pair <begin,end> marking the subsequence in the sequence.
+ If the find fails, returns <End,End>
+ */
+ template<typename SearchIteratorT, typename PredicateT>
+ struct nth_finderF
+ {
+ typedef SearchIteratorT search_iterator_type;
+ typedef first_finderF<
+ search_iterator_type,
+ PredicateT> first_finder_type;
+ typedef last_finderF<
+ search_iterator_type,
+ PredicateT> last_finder_type;
+
+ // Construction
+ template< typename SearchT >
+ nth_finderF(
+ const SearchT& Search,
+ int Nth,
+ PredicateT Comp) :
+ m_Search(::ndnboost::begin(Search), ::ndnboost::end(Search)),
+ m_Nth(Nth),
+ m_Comp(Comp) {}
+ nth_finderF(
+ search_iterator_type SearchBegin,
+ search_iterator_type SearchEnd,
+ int Nth,
+ PredicateT Comp) :
+ m_Search(SearchBegin, SearchEnd),
+ m_Nth(Nth),
+ m_Comp(Comp) {}
+
+ // Operation
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ operator()(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End ) const
+ {
+ if(m_Nth>=0)
+ {
+ return find_forward(Begin, End, m_Nth);
+ }
+ else
+ {
+ return find_backward(Begin, End, -m_Nth);
+ }
+
+ }
+
+ private:
+ // Implementation helpers
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ find_forward(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N) const
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ // Sanity check
+ if( ndnboost::empty(m_Search) )
+ return result_type( End, End );
+
+ // Instantiate find functor
+ first_finder_type first_finder(
+ m_Search.begin(), m_Search.end(), m_Comp );
+
+ result_type M( Begin, Begin );
+
+ for( unsigned int n=0; n<=N; ++n )
+ {
+ // find next match
+ M=first_finder( ::ndnboost::end(M), End );
+
+ if ( !M )
+ {
+ // Subsequence not found, return
+ return M;
+ }
+ }
+
+ return M;
+ }
+
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ find_backward(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N) const
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ // Sanity check
+ if( ndnboost::empty(m_Search) )
+ return result_type( End, End );
+
+ // Instantiate find functor
+ last_finder_type last_finder(
+ m_Search.begin(), m_Search.end(), m_Comp );
+
+ result_type M( End, End );
+
+ for( unsigned int n=1; n<=N; ++n )
+ {
+ // find next match
+ M=last_finder( Begin, ::ndnboost::begin(M) );
+
+ if ( !M )
+ {
+ // Subsequence not found, return
+ return M;
+ }
+ }
+
+ return M;
+ }
+
+
+ private:
+ iterator_range<search_iterator_type> m_Search;
+ int m_Nth;
+ PredicateT m_Comp;
+ };
+
+// find head/tail implementation helpers ---------------------------//
+
+ template<typename ForwardIteratorT>
+ iterator_range<ForwardIteratorT>
+ find_head_impl(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N,
+ std::forward_iterator_tag )
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ input_iterator_type It=Begin;
+ for(
+ unsigned int Index=0;
+ Index<N && It!=End; ++Index,++It ) {};
+
+ return result_type( Begin, It );
+ }
+
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ find_head_impl(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N,
+ std::random_access_iterator_tag )
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
+ return result_type( Begin, End );
+
+ return result_type(Begin,Begin+N);
+ }
+
+ // Find head implementation
+ template<typename ForwardIteratorT>
+ iterator_range<ForwardIteratorT>
+ find_head_impl(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N )
+ {
+ typedef BOOST_STRING_TYPENAME ndnboost::detail::
+ iterator_traits<ForwardIteratorT>::iterator_category category;
+
+ return ::ndnboost::algorithm::detail::find_head_impl( Begin, End, N, category() );
+ }
+
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ find_tail_impl(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N,
+ std::forward_iterator_tag )
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ unsigned int Index=0;
+ input_iterator_type It=Begin;
+ input_iterator_type It2=Begin;
+
+ // Advance It2 by N increments
+ for( Index=0; Index<N && It2!=End; ++Index,++It2 ) {};
+
+ // Advance It, It2 to the end
+ for(; It2!=End; ++It,++It2 ) {};
+
+ return result_type( It, It2 );
+ }
+
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ find_tail_impl(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N,
+ std::bidirectional_iterator_tag )
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ input_iterator_type It=End;
+ for(
+ unsigned int Index=0;
+ Index<N && It!=Begin; ++Index,--It ) {};
+
+ return result_type( It, End );
+ }
+
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ find_tail_impl(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N,
+ std::random_access_iterator_tag )
+ {
+ typedef ForwardIteratorT input_iterator_type;
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ if ( (End<=Begin) || ( static_cast<unsigned int>(End-Begin) < N ) )
+ return result_type( Begin, End );
+
+ return result_type( End-N, End );
+ }
+
+ // Operation
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ find_tail_impl(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End,
+ unsigned int N )
+ {
+ typedef BOOST_STRING_TYPENAME ndnboost::detail::
+ iterator_traits<ForwardIteratorT>::iterator_category category;
+
+ return ::ndnboost::algorithm::detail::find_tail_impl( Begin, End, N, category() );
+ }
+
+
+
+// find head functor -----------------------------------------------//
+
+
+ // find a head in the sequence ( functor )
+ /*
+ This functor find a head of the specified range. For
+ a specified N, the head is a subsequence of N starting
+ elements of the range.
+ */
+ struct head_finderF
+ {
+ // Construction
+ head_finderF( int N ) : m_N(N) {}
+
+ // Operation
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ operator()(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End ) const
+ {
+ if(m_N>=0)
+ {
+ return ::ndnboost::algorithm::detail::find_head_impl( Begin, End, m_N );
+ }
+ else
+ {
+ iterator_range<ForwardIteratorT> Res=
+ ::ndnboost::algorithm::detail::find_tail_impl( Begin, End, -m_N );
+
+ return ::ndnboost::make_iterator_range(Begin, Res.begin());
+ }
+ }
+
+ private:
+ int m_N;
+ };
+
+// find tail functor -----------------------------------------------//
+
+
+ // find a tail in the sequence ( functor )
+ /*
+ This functor find a tail of the specified range. For
+ a specified N, the head is a subsequence of N starting
+ elements of the range.
+ */
+ struct tail_finderF
+ {
+ // Construction
+ tail_finderF( int N ) : m_N(N) {}
+
+ // Operation
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ operator()(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End ) const
+ {
+ if(m_N>=0)
+ {
+ return ::ndnboost::algorithm::detail::find_tail_impl( Begin, End, m_N );
+ }
+ else
+ {
+ iterator_range<ForwardIteratorT> Res=
+ ::ndnboost::algorithm::detail::find_head_impl( Begin, End, -m_N );
+
+ return ::ndnboost::make_iterator_range(Res.end(), End);
+ }
+ }
+
+ private:
+ int m_N;
+ };
+
+// find token functor -----------------------------------------------//
+
+ // find a token in a sequence ( functor )
+ /*
+ This find functor finds a token specified be a predicate
+ in a sequence. It is equivalent of std::find algorithm,
+ with an exception that it return range instead of a single
+ iterator.
+
+ If bCompress is set to true, adjacent matching tokens are
+ concatenated into one match.
+ */
+ template< typename PredicateT >
+ struct token_finderF
+ {
+ // Construction
+ token_finderF(
+ PredicateT Pred,
+ token_compress_mode_type eCompress=token_compress_off ) :
+ m_Pred(Pred), m_eCompress(eCompress) {}
+
+ // Operation
+ template< typename ForwardIteratorT >
+ iterator_range<ForwardIteratorT>
+ operator()(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End ) const
+ {
+ typedef iterator_range<ForwardIteratorT> result_type;
+
+ ForwardIteratorT It=std::find_if( Begin, End, m_Pred );
+
+ if( It==End )
+ {
+ return result_type( End, End );
+ }
+ else
+ {
+ ForwardIteratorT It2=It;
+
+ if( m_eCompress==token_compress_on )
+ {
+ // Find first non-matching character
+ while( It2!=End && m_Pred(*It2) ) ++It2;
+ }
+ else
+ {
+ // Advance by one position
+ ++It2;
+ }
+
+ return result_type( It, It2 );
+ }
+ }
+
+ private:
+ PredicateT m_Pred;
+ token_compress_mode_type m_eCompress;
+ };
+
+// find range functor -----------------------------------------------//
+
+ // find a range in the sequence ( functor )
+ /*
+ This functor actually does not perform any find operation.
+ It always returns given iterator range as a result.
+ */
+ template<typename ForwardIterator1T>
+ struct range_finderF
+ {
+ typedef ForwardIterator1T input_iterator_type;
+ typedef iterator_range<input_iterator_type> result_type;
+
+ // Construction
+ range_finderF(
+ input_iterator_type Begin,
+ input_iterator_type End ) : m_Range(Begin, End) {}
+
+ range_finderF(const iterator_range<input_iterator_type>& Range) :
+ m_Range(Range) {}
+
+ // Operation
+ template< typename ForwardIterator2T >
+ iterator_range<ForwardIterator2T>
+ operator()(
+ ForwardIterator2T,
+ ForwardIterator2T ) const
+ {
+#if BOOST_WORKAROUND( __MWERKS__, <= 0x3003 )
+ return iterator_range<const ForwardIterator2T>(this->m_Range);
+#elif BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+ return iterator_range<ForwardIterator2T>(m_Range.begin(), m_Range.end());
+#else
+ return m_Range;
+#endif
+ }
+
+ private:
+ iterator_range<input_iterator_type> m_Range;
+ };
+
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+#endif // BOOST_STRING_FINDER_DETAIL_HPP
diff --git a/ndnboost/algorithm/string/detail/formatter.hpp b/ndnboost/algorithm/string/detail/formatter.hpp
new file mode 100644
index 0000000..0307310
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/formatter.hpp
@@ -0,0 +1,119 @@
+// Boost string_algo library formatter.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FORMATTER_DETAIL_HPP
+#define BOOST_STRING_FORMATTER_DETAIL_HPP
+
+
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/begin.hpp>
+#include <ndnboost/range/end.hpp>
+#include <ndnboost/range/const_iterator.hpp>
+
+#include <ndnboost/algorithm/string/detail/util.hpp>
+
+// generic replace functors -----------------------------------------------//
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+// const format functor ----------------------------------------------------//
+
+ // constant format functor
+ template<typename RangeT>
+ struct const_formatF
+ {
+ private:
+ typedef BOOST_STRING_TYPENAME
+ range_const_iterator<RangeT>::type format_iterator;
+ typedef iterator_range<format_iterator> result_type;
+
+ public:
+ // Construction
+ const_formatF(const RangeT& Format) :
+ m_Format(::ndnboost::begin(Format), ::ndnboost::end(Format)) {}
+
+ // Operation
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
+ template<typename Range2T>
+ result_type& operator()(const Range2T&)
+ {
+ return m_Format;
+ }
+#endif
+
+ template<typename Range2T>
+ const result_type& operator()(const Range2T&) const
+ {
+ return m_Format;
+ }
+
+ private:
+ result_type m_Format;
+ };
+
+// identity format functor ----------------------------------------------------//
+
+ // identity format functor
+ template<typename RangeT>
+ struct identity_formatF
+ {
+ // Operation
+ template< typename Range2T >
+ const RangeT& operator()(const Range2T& Replace) const
+ {
+ return RangeT(::ndnboost::begin(Replace), ::ndnboost::end(Replace));
+ }
+ };
+
+// empty format functor ( used by erase ) ------------------------------------//
+
+ // empty format functor
+ template< typename CharT >
+ struct empty_formatF
+ {
+ template< typename ReplaceT >
+ empty_container<CharT> operator()(const ReplaceT&) const
+ {
+ return empty_container<CharT>();
+ }
+ };
+
+// dissect format functor ----------------------------------------------------//
+
+ // dissect format functor
+ template<typename FinderT>
+ struct dissect_formatF
+ {
+ public:
+ // Construction
+ dissect_formatF(FinderT Finder) :
+ m_Finder(Finder) {}
+
+ // Operation
+ template<typename RangeT>
+ inline iterator_range<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
+ operator()(const RangeT& Replace) const
+ {
+ return m_Finder(::ndnboost::begin(Replace), ::ndnboost::end(Replace));
+ }
+
+ private:
+ FinderT m_Finder;
+ };
+
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+#endif // BOOST_STRING_FORMATTER_DETAIL_HPP
diff --git a/ndnboost/algorithm/string/detail/replace_storage.hpp b/ndnboost/algorithm/string/detail/replace_storage.hpp
new file mode 100644
index 0000000..6fb6c54
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/replace_storage.hpp
@@ -0,0 +1,159 @@
+// Boost string_algo library replace_storage.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
+#define BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <algorithm>
+#include <ndnboost/mpl/bool.hpp>
+#include <ndnboost/algorithm/string/sequence_traits.hpp>
+#include <ndnboost/algorithm/string/detail/sequence.hpp>
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+// storage handling routines -----------------------------------------------//
+
+ template< typename StorageT, typename OutputIteratorT >
+ inline OutputIteratorT move_from_storage(
+ StorageT& Storage,
+ OutputIteratorT DestBegin,
+ OutputIteratorT DestEnd )
+ {
+ OutputIteratorT OutputIt=DestBegin;
+
+ while( !Storage.empty() && OutputIt!=DestEnd )
+ {
+ *OutputIt=Storage.front();
+ Storage.pop_front();
+ ++OutputIt;
+ }
+
+ return OutputIt;
+ }
+
+ template< typename StorageT, typename WhatT >
+ inline void copy_to_storage(
+ StorageT& Storage,
+ const WhatT& What )
+ {
+ Storage.insert( Storage.end(), ::ndnboost::begin(What), ::ndnboost::end(What) );
+ }
+
+
+// process segment routine -----------------------------------------------//
+
+ template< bool HasStableIterators >
+ struct process_segment_helper
+ {
+ // Optimized version of process_segment for generic sequence
+ template<
+ typename StorageT,
+ typename InputT,
+ typename ForwardIteratorT >
+ ForwardIteratorT operator()(
+ StorageT& Storage,
+ InputT& /*Input*/,
+ ForwardIteratorT InsertIt,
+ ForwardIteratorT SegmentBegin,
+ ForwardIteratorT SegmentEnd )
+ {
+ // Copy data from the storage until the beginning of the segment
+ ForwardIteratorT It=::ndnboost::algorithm::detail::move_from_storage( Storage, InsertIt, SegmentBegin );
+
+ // 3 cases are possible :
+ // a) Storage is empty, It==SegmentBegin
+ // b) Storage is empty, It!=SegmentBegin
+ // c) Storage is not empty
+
+ if( Storage.empty() )
+ {
+ if( It==SegmentBegin )
+ {
+ // Case a) everything is grand, just return end of segment
+ return SegmentEnd;
+ }
+ else
+ {
+ // Case b) move the segment backwards
+ return std::copy( SegmentBegin, SegmentEnd, It );
+ }
+ }
+ else
+ {
+ // Case c) -> shift the segment to the left and keep the overlap in the storage
+ while( It!=SegmentEnd )
+ {
+ // Store value into storage
+ Storage.push_back( *It );
+ // Get the top from the storage and put it here
+ *It=Storage.front();
+ Storage.pop_front();
+
+ // Advance
+ ++It;
+ }
+
+ return It;
+ }
+ }
+ };
+
+ template<>
+ struct process_segment_helper< true >
+ {
+ // Optimized version of process_segment for list-like sequence
+ template<
+ typename StorageT,
+ typename InputT,
+ typename ForwardIteratorT >
+ ForwardIteratorT operator()(
+ StorageT& Storage,
+ InputT& Input,
+ ForwardIteratorT InsertIt,
+ ForwardIteratorT SegmentBegin,
+ ForwardIteratorT SegmentEnd )
+
+ {
+ // Call replace to do the job
+ ::ndnboost::algorithm::detail::replace( Input, InsertIt, SegmentBegin, Storage );
+ // Empty the storage
+ Storage.clear();
+ // Iterators were not changed, simply return the end of segment
+ return SegmentEnd;
+ }
+ };
+
+ // Process one segment in the replace_all algorithm
+ template<
+ typename StorageT,
+ typename InputT,
+ typename ForwardIteratorT >
+ inline ForwardIteratorT process_segment(
+ StorageT& Storage,
+ InputT& Input,
+ ForwardIteratorT InsertIt,
+ ForwardIteratorT SegmentBegin,
+ ForwardIteratorT SegmentEnd )
+ {
+ return
+ process_segment_helper<
+ has_stable_iterators<InputT>::value>()(
+ Storage, Input, InsertIt, SegmentBegin, SegmentEnd );
+ }
+
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+#endif // BOOST_STRING_REPLACE_STORAGE_DETAIL_HPP
diff --git a/ndnboost/algorithm/string/detail/sequence.hpp b/ndnboost/algorithm/string/detail/sequence.hpp
new file mode 100644
index 0000000..0b39a8b
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/sequence.hpp
@@ -0,0 +1,200 @@
+// Boost string_algo library sequence.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_DETAIL_SEQUENCE_HPP
+#define BOOST_STRING_DETAIL_SEQUENCE_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <ndnboost/mpl/bool.hpp>
+#include <ndnboost/mpl/logical.hpp>
+#include <ndnboost/range/begin.hpp>
+#include <ndnboost/range/end.hpp>
+
+#include <ndnboost/algorithm/string/sequence_traits.hpp>
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+// insert helpers -------------------------------------------------//
+
+ template< typename InputT, typename ForwardIteratorT >
+ inline void insert(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator At,
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ Input.insert( At, Begin, End );
+ }
+
+ template< typename InputT, typename InsertT >
+ inline void insert(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator At,
+ const InsertT& Insert )
+ {
+ ::ndnboost::algorithm::detail::insert( Input, At, ::ndnboost::begin(Insert), ::ndnboost::end(Insert) );
+ }
+
+// erase helper ---------------------------------------------------//
+
+ // Erase a range in the sequence
+ /*
+ Returns the iterator pointing just after the erase subrange
+ */
+ template< typename InputT >
+ inline typename InputT::iterator erase(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator From,
+ BOOST_STRING_TYPENAME InputT::iterator To )
+ {
+ return Input.erase( From, To );
+ }
+
+// replace helper implementation ----------------------------------//
+
+ // Optimized version of replace for generic sequence containers
+ // Assumption: insert and erase are expensive
+ template< bool HasConstTimeOperations >
+ struct replace_const_time_helper
+ {
+ template< typename InputT, typename ForwardIteratorT >
+ void operator()(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator From,
+ BOOST_STRING_TYPENAME InputT::iterator To,
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ // Copy data to the container ( as much as possible )
+ ForwardIteratorT InsertIt=Begin;
+ BOOST_STRING_TYPENAME InputT::iterator InputIt=From;
+ for(; InsertIt!=End && InputIt!=To; InsertIt++, InputIt++ )
+ {
+ *InputIt=*InsertIt;
+ }
+
+ if ( InsertIt!=End )
+ {
+ // Replace sequence is longer, insert it
+ Input.insert( InputIt, InsertIt, End );
+ }
+ else
+ {
+ if ( InputIt!=To )
+ {
+ // Replace sequence is shorter, erase the rest
+ Input.erase( InputIt, To );
+ }
+ }
+ }
+ };
+
+ template<>
+ struct replace_const_time_helper< true >
+ {
+ // Const-time erase and insert methods -> use them
+ template< typename InputT, typename ForwardIteratorT >
+ void operator()(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator From,
+ BOOST_STRING_TYPENAME InputT::iterator To,
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ BOOST_STRING_TYPENAME InputT::iterator At=Input.erase( From, To );
+ if ( Begin!=End )
+ {
+ if(!Input.empty())
+ {
+ Input.insert( At, Begin, End );
+ }
+ else
+ {
+ Input.insert( Input.begin(), Begin, End );
+ }
+ }
+ }
+ };
+
+ // No native replace method
+ template< bool HasNative >
+ struct replace_native_helper
+ {
+ template< typename InputT, typename ForwardIteratorT >
+ void operator()(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator From,
+ BOOST_STRING_TYPENAME InputT::iterator To,
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ replace_const_time_helper<
+ ndnboost::mpl::and_<
+ has_const_time_insert<InputT>,
+ has_const_time_erase<InputT> >::value >()(
+ Input, From, To, Begin, End );
+ }
+ };
+
+ // Container has native replace method
+ template<>
+ struct replace_native_helper< true >
+ {
+ template< typename InputT, typename ForwardIteratorT >
+ void operator()(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator From,
+ BOOST_STRING_TYPENAME InputT::iterator To,
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ Input.replace( From, To, Begin, End );
+ }
+ };
+
+// replace helper -------------------------------------------------//
+
+ template< typename InputT, typename ForwardIteratorT >
+ inline void replace(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator From,
+ BOOST_STRING_TYPENAME InputT::iterator To,
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ replace_native_helper< has_native_replace<InputT>::value >()(
+ Input, From, To, Begin, End );
+ }
+
+ template< typename InputT, typename InsertT >
+ inline void replace(
+ InputT& Input,
+ BOOST_STRING_TYPENAME InputT::iterator From,
+ BOOST_STRING_TYPENAME InputT::iterator To,
+ const InsertT& Insert )
+ {
+ if(From!=To)
+ {
+ ::ndnboost::algorithm::detail::replace( Input, From, To, ::ndnboost::begin(Insert), ::ndnboost::end(Insert) );
+ }
+ else
+ {
+ ::ndnboost::algorithm::detail::insert( Input, From, ::ndnboost::begin(Insert), ::ndnboost::end(Insert) );
+ }
+ }
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+
+#endif // BOOST_STRING_DETAIL_SEQUENCE_HPP
diff --git a/ndnboost/algorithm/string/detail/util.hpp b/ndnboost/algorithm/string/detail/util.hpp
new file mode 100644
index 0000000..fa34548
--- /dev/null
+++ b/ndnboost/algorithm/string/detail/util.hpp
@@ -0,0 +1,106 @@
+// Boost string_algo library util.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_UTIL_DETAIL_HPP
+#define BOOST_STRING_UTIL_DETAIL_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+#include <functional>
+#include <ndnboost/range/iterator_range.hpp>
+
+namespace ndnboost {
+ namespace algorithm {
+ namespace detail {
+
+// empty container -----------------------------------------------//
+
+ // empty_container
+ /*
+ This class represents always empty container,
+ containing elements of type CharT.
+
+ It is supposed to be used in a const version only
+ */
+ template< typename CharT >
+ struct empty_container
+ {
+ typedef empty_container<CharT> type;
+ typedef CharT value_type;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef const value_type& reference;
+ typedef const value_type& const_reference;
+ typedef const value_type* iterator;
+ typedef const value_type* const_iterator;
+
+
+ // Operations
+ const_iterator begin() const
+ {
+ return reinterpret_cast<const_iterator>(0);
+ }
+
+ const_iterator end() const
+ {
+ return reinterpret_cast<const_iterator>(0);
+ }
+
+ bool empty() const
+ {
+ return false;
+ }
+
+ size_type size() const
+ {
+ return 0;
+ }
+ };
+
+// bounded copy algorithm -----------------------------------------------//
+
+ // Bounded version of the std::copy algorithm
+ template<typename InputIteratorT, typename OutputIteratorT>
+ inline OutputIteratorT bounded_copy(
+ InputIteratorT First,
+ InputIteratorT Last,
+ OutputIteratorT DestFirst,
+ OutputIteratorT DestLast )
+ {
+ InputIteratorT InputIt=First;
+ OutputIteratorT OutputIt=DestFirst;
+ for(; InputIt!=Last && OutputIt!=DestLast; InputIt++, OutputIt++ )
+ {
+ *OutputIt=*InputIt;
+ }
+
+ return OutputIt;
+ }
+
+// iterator range utilities -----------------------------------------//
+
+ // copy range functor
+ template<
+ typename SeqT,
+ typename IteratorT=BOOST_STRING_TYPENAME SeqT::const_iterator >
+ struct copy_iterator_rangeF :
+ public std::unary_function< iterator_range<IteratorT>, SeqT >
+ {
+ SeqT operator()( const iterator_range<IteratorT>& Range ) const
+ {
+ return copy_range<SeqT>(Range);
+ }
+ };
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace ndnboost
+
+
+#endif // BOOST_STRING_UTIL_DETAIL_HPP
diff --git a/ndnboost/algorithm/string/find_format.hpp b/ndnboost/algorithm/string/find_format.hpp
new file mode 100644
index 0000000..5352eba
--- /dev/null
+++ b/ndnboost/algorithm/string/find_format.hpp
@@ -0,0 +1,287 @@
+// Boost string_algo library find_format.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FIND_FORMAT_HPP
+#define BOOST_STRING_FIND_FORMAT_HPP
+
+#include <deque>
+#include <ndnboost/detail/iterator.hpp>
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/begin.hpp>
+#include <ndnboost/range/end.hpp>
+#include <ndnboost/range/const_iterator.hpp>
+#include <ndnboost/range/as_literal.hpp>
+
+#include <ndnboost/algorithm/string/concept.hpp>
+#include <ndnboost/algorithm/string/detail/find_format.hpp>
+#include <ndnboost/algorithm/string/detail/find_format_all.hpp>
+
+/*! \file
+ Defines generic replace algorithms. Each algorithm replaces
+ part(s) of the input. The part to be replaced is looked up using a Finder object.
+ Result of finding is then used by a Formatter object to generate the replacement.
+*/
+
+namespace ndnboost {
+ namespace algorithm {
+
+// generic replace -----------------------------------------------------------------//
+
+ //! Generic replace algorithm
+ /*!
+ Use the Finder to search for a substring. Use the Formatter to format
+ this substring and replace it in the input.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input sequence
+ \param Finder A Finder object used to search for a match to be replaced
+ \param Formatter A Formatter object used to format a match
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename RangeT,
+ typename FinderT,
+ typename FormatterT>
+ inline OutputIteratorT find_format_copy(
+ OutputIteratorT Output,
+ const RangeT& Input,
+ FinderT Finder,
+ FormatterT Formatter )
+ {
+ // Concept check
+ BOOST_CONCEPT_ASSERT((
+ FinderConcept<
+ FinderT,
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ FormatterConcept<
+ FormatterT,
+ FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
+ ));
+
+ iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::ndnboost::as_literal(Input));
+
+ return detail::find_format_copy_impl(
+ Output,
+ lit_input,
+ Formatter,
+ Finder( ::ndnboost::begin(lit_input), ::ndnboost::end(lit_input) ) );
+ }
+
+ //! Generic replace algorithm
+ /*!
+ \overload
+ */
+ template<
+ typename SequenceT,
+ typename FinderT,
+ typename FormatterT>
+ inline SequenceT find_format_copy(
+ const SequenceT& Input,
+ FinderT Finder,
+ FormatterT Formatter )
+ {
+ // Concept check
+ BOOST_CONCEPT_ASSERT((
+ FinderConcept<
+ FinderT,
+ BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ FormatterConcept<
+ FormatterT,
+ FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+
+ return detail::find_format_copy_impl(
+ Input,
+ Formatter,
+ Finder(::ndnboost::begin(Input), ::ndnboost::end(Input)));
+ }
+
+ //! Generic replace algorithm
+ /*!
+ Use the Finder to search for a substring. Use the Formatter to format
+ this substring and replace it in the input. The input is modified in-place.
+
+ \param Input An input sequence
+ \param Finder A Finder object used to search for a match to be replaced
+ \param Formatter A Formatter object used to format a match
+ */
+ template<
+ typename SequenceT,
+ typename FinderT,
+ typename FormatterT>
+ inline void find_format(
+ SequenceT& Input,
+ FinderT Finder,
+ FormatterT Formatter)
+ {
+ // Concept check
+ BOOST_CONCEPT_ASSERT((
+ FinderConcept<
+ FinderT,
+ BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ FormatterConcept<
+ FormatterT,
+ FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+
+ detail::find_format_impl(
+ Input,
+ Formatter,
+ Finder(::ndnboost::begin(Input), ::ndnboost::end(Input)));
+ }
+
+
+// find_format_all generic ----------------------------------------------------------------//
+
+ //! Generic replace all algorithm
+ /*!
+ Use the Finder to search for a substring. Use the Formatter to format
+ this substring and replace it in the input. Repeat this for all matching
+ substrings.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input sequence
+ \param Finder A Finder object used to search for a match to be replaced
+ \param Formatter A Formatter object used to format a match
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename RangeT,
+ typename FinderT,
+ typename FormatterT>
+ inline OutputIteratorT find_format_all_copy(
+ OutputIteratorT Output,
+ const RangeT& Input,
+ FinderT Finder,
+ FormatterT Formatter)
+ {
+ // Concept check
+ BOOST_CONCEPT_ASSERT((
+ FinderConcept<
+ FinderT,
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ FormatterConcept<
+ FormatterT,
+ FinderT,BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type>
+ ));
+
+ iterator_range<BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> lit_input(::ndnboost::as_literal(Input));
+
+ return detail::find_format_all_copy_impl(
+ Output,
+ lit_input,
+ Finder,
+ Formatter,
+ Finder(::ndnboost::begin(lit_input), ::ndnboost::end(lit_input)));
+ }
+
+ //! Generic replace all algorithm
+ /*!
+ \overload
+ */
+ template<
+ typename SequenceT,
+ typename FinderT,
+ typename FormatterT >
+ inline SequenceT find_format_all_copy(
+ const SequenceT& Input,
+ FinderT Finder,
+ FormatterT Formatter )
+ {
+ // Concept check
+ BOOST_CONCEPT_ASSERT((
+ FinderConcept<
+ FinderT,
+ BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ FormatterConcept<
+ FormatterT,
+ FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+
+ return detail::find_format_all_copy_impl(
+ Input,
+ Finder,
+ Formatter,
+ Finder( ::ndnboost::begin(Input), ::ndnboost::end(Input) ) );
+ }
+
+ //! Generic replace all algorithm
+ /*!
+ Use the Finder to search for a substring. Use the Formatter to format
+ this substring and replace it in the input. Repeat this for all matching
+ substrings.The input is modified in-place.
+
+ \param Input An input sequence
+ \param Finder A Finder object used to search for a match to be replaced
+ \param Formatter A Formatter object used to format a match
+ */
+ template<
+ typename SequenceT,
+ typename FinderT,
+ typename FormatterT >
+ inline void find_format_all(
+ SequenceT& Input,
+ FinderT Finder,
+ FormatterT Formatter )
+ {
+ // Concept check
+ BOOST_CONCEPT_ASSERT((
+ FinderConcept<
+ FinderT,
+ BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+ BOOST_CONCEPT_ASSERT((
+ FormatterConcept<
+ FormatterT,
+ FinderT,BOOST_STRING_TYPENAME range_const_iterator<SequenceT>::type>
+ ));
+
+ detail::find_format_all_impl(
+ Input,
+ Finder,
+ Formatter,
+ Finder(::ndnboost::begin(Input), ::ndnboost::end(Input)));
+
+ }
+
+ } // namespace algorithm
+
+ // pull the names to the boost namespace
+ using algorithm::find_format_copy;
+ using algorithm::find_format;
+ using algorithm::find_format_all_copy;
+ using algorithm::find_format_all;
+
+} // namespace ndnboost
+
+
+#endif // BOOST_STRING_FIND_FORMAT_HPP
diff --git a/ndnboost/algorithm/string/finder.hpp b/ndnboost/algorithm/string/finder.hpp
new file mode 100644
index 0000000..420e015
--- /dev/null
+++ b/ndnboost/algorithm/string/finder.hpp
@@ -0,0 +1,270 @@
+// Boost string_algo library finder.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2006.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FINDER_HPP
+#define BOOST_STRING_FINDER_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/begin.hpp>
+#include <ndnboost/range/end.hpp>
+#include <ndnboost/range/iterator.hpp>
+#include <ndnboost/range/const_iterator.hpp>
+
+#include <ndnboost/algorithm/string/constants.hpp>
+#include <ndnboost/algorithm/string/detail/finder.hpp>
+#include <ndnboost/algorithm/string/compare.hpp>
+
+/*! \file
+ Defines Finder generators. Finder object is a functor which is able to
+ find a substring matching a specific criteria in the input.
+ Finders are used as a pluggable components for replace, find
+ and split facilities. This header contains generator functions
+ for finders provided in this library.
+*/
+
+namespace ndnboost {
+ namespace algorithm {
+
+// Finder generators ------------------------------------------//
+
+ //! "First" finder
+ /*!
+ Construct the \c first_finder. The finder searches for the first
+ occurrence of the string in a given input.
+ The result is given as an \c iterator_range delimiting the match.
+
+ \param Search A substring to be searched for.
+ \param Comp An element comparison predicate
+ \return An instance of the \c first_finder object
+ */
+ template<typename RangeT>
+ inline detail::first_finderF<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
+ is_equal>
+ first_finder( const RangeT& Search )
+ {
+ return
+ detail::first_finderF<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<RangeT>::type,
+ is_equal>( ::ndnboost::as_literal(Search), is_equal() ) ;
+ }
+
+ //! "First" finder
+ /*!
+ \overload
+ */
+ template<typename RangeT,typename PredicateT>
+ inline detail::first_finderF<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
+ PredicateT>
+ first_finder(
+ const RangeT& Search, PredicateT Comp )
+ {
+ return
+ detail::first_finderF<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<RangeT>::type,
+ PredicateT>( ::ndnboost::as_literal(Search), Comp );
+ }
+
+ //! "Last" finder
+ /*!
+ Construct the \c last_finder. The finder searches for the last
+ occurrence of the string in a given input.
+ The result is given as an \c iterator_range delimiting the match.
+
+ \param Search A substring to be searched for.
+ \param Comp An element comparison predicate
+ \return An instance of the \c last_finder object
+ */
+ template<typename RangeT>
+ inline detail::last_finderF<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
+ is_equal>
+ last_finder( const RangeT& Search )
+ {
+ return
+ detail::last_finderF<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<RangeT>::type,
+ is_equal>( ::ndnboost::as_literal(Search), is_equal() );
+ }
+ //! "Last" finder
+ /*!
+ \overload
+ */
+ template<typename RangeT, typename PredicateT>
+ inline detail::last_finderF<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
+ PredicateT>
+ last_finder( const RangeT& Search, PredicateT Comp )
+ {
+ return
+ detail::last_finderF<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<RangeT>::type,
+ PredicateT>( ::ndnboost::as_literal(Search), Comp ) ;
+ }
+
+ //! "Nth" finder
+ /*!
+ Construct the \c nth_finder. The finder searches for the n-th (zero-indexed)
+ occurrence of the string in a given input.
+ The result is given as an \c iterator_range delimiting the match.
+
+ \param Search A substring to be searched for.
+ \param Nth An index of the match to be find
+ \param Comp An element comparison predicate
+ \return An instance of the \c nth_finder object
+ */
+ template<typename RangeT>
+ inline detail::nth_finderF<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
+ is_equal>
+ nth_finder(
+ const RangeT& Search,
+ int Nth)
+ {
+ return
+ detail::nth_finderF<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<RangeT>::type,
+ is_equal>( ::ndnboost::as_literal(Search), Nth, is_equal() ) ;
+ }
+ //! "Nth" finder
+ /*!
+ \overload
+ */
+ template<typename RangeT, typename PredicateT>
+ inline detail::nth_finderF<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type,
+ PredicateT>
+ nth_finder(
+ const RangeT& Search,
+ int Nth,
+ PredicateT Comp )
+ {
+ return
+ detail::nth_finderF<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<RangeT>::type,
+ PredicateT>( ::ndnboost::as_literal(Search), Nth, Comp );
+ }
+
+ //! "Head" finder
+ /*!
+ Construct the \c head_finder. The finder returns a head of a given
+ input. The head is a prefix of a string up to n elements in
+ size. If an input has less then n elements, whole input is
+ considered a head.
+ The result is given as an \c iterator_range delimiting the match.
+
+ \param N The size of the head
+ \return An instance of the \c head_finder object
+ */
+ inline detail::head_finderF
+ head_finder( int N )
+ {
+ return detail::head_finderF(N);
+ }
+
+ //! "Tail" finder
+ /*!
+ Construct the \c tail_finder. The finder returns a tail of a given
+ input. The tail is a suffix of a string up to n elements in
+ size. If an input has less then n elements, whole input is
+ considered a head.
+ The result is given as an \c iterator_range delimiting the match.
+
+ \param N The size of the head
+ \return An instance of the \c tail_finder object
+ */
+ inline detail::tail_finderF
+ tail_finder( int N )
+ {
+ return detail::tail_finderF(N);
+ }
+
+ //! "Token" finder
+ /*!
+ Construct the \c token_finder. The finder searches for a token
+ specified by a predicate. It is similar to std::find_if
+ algorithm, with an exception that it return a range of
+ instead of a single iterator.
+
+ If "compress token mode" is enabled, adjacent matching tokens are
+ concatenated into one match. Thus the finder can be used to
+ search for continuous segments of characters satisfying the
+ given predicate.
+
+ The result is given as an \c iterator_range delimiting the match.
+
+ \param Pred An element selection predicate
+ \param eCompress Compress flag
+ \return An instance of the \c token_finder object
+ */
+ template< typename PredicateT >
+ inline detail::token_finderF<PredicateT>
+ token_finder(
+ PredicateT Pred,
+ token_compress_mode_type eCompress=token_compress_off )
+ {
+ return detail::token_finderF<PredicateT>( Pred, eCompress );
+ }
+
+ //! "Range" finder
+ /*!
+ Construct the \c range_finder. The finder does not perform
+ any operation. It simply returns the given range for
+ any input.
+
+ \param Begin Beginning of the range
+ \param End End of the range
+ \param Range The range.
+ \return An instance of the \c range_finger object
+ */
+ template< typename ForwardIteratorT >
+ inline detail::range_finderF<ForwardIteratorT>
+ range_finder(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ return detail::range_finderF<ForwardIteratorT>( Begin, End );
+ }
+
+ //! "Range" finder
+ /*!
+ \overload
+ */
+ template< typename ForwardIteratorT >
+ inline detail::range_finderF<ForwardIteratorT>
+ range_finder( iterator_range<ForwardIteratorT> Range )
+ {
+ return detail::range_finderF<ForwardIteratorT>( Range );
+ }
+
+ } // namespace algorithm
+
+ // pull the names to the boost namespace
+ using algorithm::first_finder;
+ using algorithm::last_finder;
+ using algorithm::nth_finder;
+ using algorithm::head_finder;
+ using algorithm::tail_finder;
+ using algorithm::token_finder;
+ using algorithm::range_finder;
+
+} // namespace ndnboost
+
+
+#endif // BOOST_STRING_FINDER_HPP
diff --git a/ndnboost/algorithm/string/formatter.hpp b/ndnboost/algorithm/string/formatter.hpp
new file mode 100644
index 0000000..5739b40
--- /dev/null
+++ b/ndnboost/algorithm/string/formatter.hpp
@@ -0,0 +1,120 @@
+// Boost string_algo library formatter.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FORMATTER_HPP
+#define BOOST_STRING_FORMATTER_HPP
+
+#include <ndnboost/detail/iterator.hpp>
+#include <ndnboost/range/value_type.hpp>
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/as_literal.hpp>
+
+#include <ndnboost/algorithm/string/detail/formatter.hpp>
+
+/*! \file
+ Defines Formatter generators. Formatter is a functor which formats
+ a string according to given parameters. A Formatter works
+ in conjunction with a Finder. A Finder can provide additional information
+ for a specific Formatter. An example of such a cooperation is regex_finder
+ and regex_formatter.
+
+ Formatters are used as pluggable components for replace facilities.
+ This header contains generator functions for the Formatters provided in this library.
+*/
+
+namespace ndnboost {
+ namespace algorithm {
+
+// generic formatters ---------------------------------------------------------------//
+
+ //! Constant formatter
+ /*!
+ Constructs a \c const_formatter. Const formatter always returns
+ the same value, regardless of the parameter.
+
+ \param Format A predefined value used as a result for formatting
+ \return An instance of the \c const_formatter object.
+ */
+ template<typename RangeT>
+ inline detail::const_formatF<
+ iterator_range<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
+ const_formatter(const RangeT& Format)
+ {
+ return detail::const_formatF<
+ iterator_range<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >(::ndnboost::as_literal(Format));
+ }
+
+ //! Identity formatter
+ /*!
+ Constructs an \c identity_formatter. Identity formatter always returns
+ the parameter.
+
+ \return An instance of the \c identity_formatter object.
+ */
+ template<typename RangeT>
+ inline detail::identity_formatF<
+ iterator_range<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >
+ identity_formatter()
+ {
+ return detail::identity_formatF<
+ iterator_range<
+ BOOST_STRING_TYPENAME range_const_iterator<RangeT>::type> >();
+ }
+
+ //! Empty formatter
+ /*!
+ Constructs an \c empty_formatter. Empty formatter always returns an empty
+ sequence.
+
+ \param Input container used to select a correct value_type for the
+ resulting empty_container<>.
+ \return An instance of the \c empty_formatter object.
+ */
+ template<typename RangeT>
+ inline detail::empty_formatF<
+ BOOST_STRING_TYPENAME range_value<RangeT>::type>
+ empty_formatter(const RangeT&)
+ {
+ return detail::empty_formatF<
+ BOOST_STRING_TYPENAME range_value<RangeT>::type>();
+ }
+
+ //! Empty formatter
+ /*!
+ Constructs a \c dissect_formatter. Dissect formatter uses a specified finder
+ to extract a portion of the formatted sequence. The first finder's match is returned
+ as a result
+
+ \param Finder a finder used to select a portion of the formatted sequence
+ \return An instance of the \c dissect_formatter object.
+ */
+ template<typename FinderT>
+ inline detail::dissect_formatF< FinderT >
+ dissect_formatter(const FinderT& Finder)
+ {
+ return detail::dissect_formatF<FinderT>(Finder);
+ }
+
+
+ } // namespace algorithm
+
+ // pull the names to the boost namespace
+ using algorithm::const_formatter;
+ using algorithm::identity_formatter;
+ using algorithm::empty_formatter;
+ using algorithm::dissect_formatter;
+
+} // namespace ndnboost
+
+
+#endif // BOOST_FORMATTER_HPP
diff --git a/ndnboost/algorithm/string/replace.hpp b/ndnboost/algorithm/string/replace.hpp
new file mode 100644
index 0000000..11afce4
--- /dev/null
+++ b/ndnboost/algorithm/string/replace.hpp
@@ -0,0 +1,928 @@
+// Boost string_algo library replace.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2006.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_REPLACE_HPP
+#define BOOST_STRING_REPLACE_HPP
+
+#include <ndnboost/algorithm/string/config.hpp>
+
+#include <ndnboost/range/iterator_range.hpp>
+#include <ndnboost/range/begin.hpp>
+#include <ndnboost/range/end.hpp>
+#include <ndnboost/range/iterator.hpp>
+#include <ndnboost/range/const_iterator.hpp>
+
+#include <ndnboost/algorithm/string/find_format.hpp>
+#include <ndnboost/algorithm/string/finder.hpp>
+#include <ndnboost/algorithm/string/formatter.hpp>
+#include <ndnboost/algorithm/string/compare.hpp>
+
+/*! \file
+ Defines various replace algorithms. Each algorithm replaces
+ part(s) of the input according to set of searching and replace criteria.
+*/
+
+namespace ndnboost {
+ namespace algorithm {
+
+// replace_range --------------------------------------------------------------------//
+
+ //! Replace range algorithm
+ /*!
+ Replace the given range in the input string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param SearchRange A range in the input to be substituted
+ \param Format A substitute string
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T>
+ inline OutputIteratorT replace_range_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const iterator_range<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<Range1T>::type>& SearchRange,
+ const Range2T& Format)
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::range_finder(SearchRange),
+ ::ndnboost::algorithm::const_formatter(Format));
+ }
+
+ //! Replace range algorithm
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename RangeT>
+ inline SequenceT replace_range_copy(
+ const SequenceT& Input,
+ const iterator_range<
+ BOOST_STRING_TYPENAME
+ range_const_iterator<SequenceT>::type>& SearchRange,
+ const RangeT& Format)
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::range_finder(SearchRange),
+ ::ndnboost::algorithm::const_formatter(Format));
+ }
+
+ //! Replace range algorithm
+ /*!
+ Replace the given range in the input string.
+ The input sequence is modified in-place.
+
+ \param Input An input string
+ \param SearchRange A range in the input to be substituted
+ \param Format A substitute string
+ */
+ template<typename SequenceT, typename RangeT>
+ inline void replace_range(
+ SequenceT& Input,
+ const iterator_range<
+ BOOST_STRING_TYPENAME
+ range_iterator<SequenceT>::type>& SearchRange,
+ const RangeT& Format)
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::range_finder(SearchRange),
+ ::ndnboost::algorithm::const_formatter(Format));
+ }
+
+// replace_first --------------------------------------------------------------------//
+
+ //! Replace first algorithm
+ /*!
+ Replace the first match of the search substring in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT replace_first_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ const Range3T& Format)
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::first_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace first algorithm
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline SequenceT replace_first_copy(
+ const SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace first algorithm
+ /*!
+ replace the first match of the search substring in the input
+ with the format string. The input sequence is modified in-place.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void replace_first(
+ SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_first ( case insensitive ) ---------------------------------------------//
+
+ //! Replace first algorithm ( case insensitive )
+ /*!
+ Replace the first match of the search substring in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+ Searching is case insensitive.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT ireplace_first_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ const Range3T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::first_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace first algorithm ( case insensitive )
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range2T, typename Range1T>
+ inline SequenceT ireplace_first_copy(
+ const SequenceT& Input,
+ const Range2T& Search,
+ const Range1T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace first algorithm ( case insensitive )
+ /*!
+ Replace the first match of the search substring in the input
+ with the format string. Input sequence is modified in-place.
+ Searching is case insensitive.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void ireplace_first(
+ SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_last --------------------------------------------------------------------//
+
+ //! Replace last algorithm
+ /*!
+ Replace the last match of the search string in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT replace_last_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ const Range3T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::last_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace last algorithm
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline SequenceT replace_last_copy(
+ const SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::last_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace last algorithm
+ /*!
+ Replace the last match of the search string in the input
+ with the format string. Input sequence is modified in-place.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void replace_last(
+ SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::last_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_last ( case insensitive ) -----------------------------------------------//
+
+ //! Replace last algorithm ( case insensitive )
+ /*!
+ Replace the last match of the search string in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+ Searching is case insensitive.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT ireplace_last_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ const Range3T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::last_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace last algorithm ( case insensitive )
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline SequenceT ireplace_last_copy(
+ const SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::last_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace last algorithm ( case insensitive )
+ /*!
+ Replace the last match of the search string in the input
+ with the format string.The input sequence is modified in-place.
+ Searching is case insensitive.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ \return A reference to the modified input
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void ireplace_last(
+ SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::last_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_nth --------------------------------------------------------------------//
+
+ //! Replace nth algorithm
+ /*!
+ Replace an Nth (zero-indexed) match of the search string in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Nth An index of the match to be replaced. The index is 0-based.
+ For negative N, matches are counted from the end of string.
+ \param Format A substitute string
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT replace_nth_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ int Nth,
+ const Range3T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::nth_finder(Search, Nth),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace nth algorithm
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline SequenceT replace_nth_copy(
+ const SequenceT& Input,
+ const Range1T& Search,
+ int Nth,
+ const Range2T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::nth_finder(Search, Nth),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace nth algorithm
+ /*!
+ Replace an Nth (zero-indexed) match of the search string in the input
+ with the format string. Input sequence is modified in-place.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Nth An index of the match to be replaced. The index is 0-based.
+ For negative N, matches are counted from the end of string.
+ \param Format A substitute string
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void replace_nth(
+ SequenceT& Input,
+ const Range1T& Search,
+ int Nth,
+ const Range2T& Format )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::nth_finder(Search, Nth),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_nth ( case insensitive ) -----------------------------------------------//
+
+ //! Replace nth algorithm ( case insensitive )
+ /*!
+ Replace an Nth (zero-indexed) match of the search string in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+ Searching is case insensitive.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Nth An index of the match to be replaced. The index is 0-based.
+ For negative N, matches are counted from the end of string.
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT ireplace_nth_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ int Nth,
+ const Range3T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::nth_finder(Search, Nth, is_iequal(Loc) ),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace nth algorithm ( case insensitive )
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline SequenceT ireplace_nth_copy(
+ const SequenceT& Input,
+ const Range1T& Search,
+ int Nth,
+ const Range2T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace nth algorithm ( case insensitive )
+ /*!
+ Replace an Nth (zero-indexed) match of the search string in the input
+ with the format string. Input sequence is modified in-place.
+ Searching is case insensitive.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Nth An index of the match to be replaced. The index is 0-based.
+ For negative N, matches are counted from the end of string.
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void ireplace_nth(
+ SequenceT& Input,
+ const Range1T& Search,
+ int Nth,
+ const Range2T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::nth_finder(Search, Nth, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_all --------------------------------------------------------------------//
+
+ //! Replace all algorithm
+ /*!
+ Replace all occurrences of the search string in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT replace_all_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ const Range3T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_all_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::first_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace all algorithm
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline SequenceT replace_all_copy(
+ const SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_all_copy(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace all algorithm
+ /*!
+ Replace all occurrences of the search string in the input
+ with the format string. The input sequence is modified in-place.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \return A reference to the modified input
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void replace_all(
+ SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format )
+ {
+ ::ndnboost::algorithm::find_format_all(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_all ( case insensitive ) -----------------------------------------------//
+
+ //! Replace all algorithm ( case insensitive )
+ /*!
+ Replace all occurrences of the search string in the input
+ with the format string.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+ Searching is case insensitive.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T,
+ typename Range3T>
+ inline OutputIteratorT ireplace_all_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ const Range2T& Search,
+ const Range3T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_all_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::first_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace all algorithm ( case insensitive )
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline SequenceT ireplace_all_copy(
+ const SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ return ::ndnboost::algorithm::find_format_all_copy(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace all algorithm ( case insensitive )
+ /*!
+ Replace all occurrences of the search string in the input
+ with the format string.The input sequence is modified in-place.
+ Searching is case insensitive.
+
+ \param Input An input string
+ \param Search A substring to be searched for
+ \param Format A substitute string
+ \param Loc A locale used for case insensitive comparison
+ */
+ template<typename SequenceT, typename Range1T, typename Range2T>
+ inline void ireplace_all(
+ SequenceT& Input,
+ const Range1T& Search,
+ const Range2T& Format,
+ const std::locale& Loc=std::locale() )
+ {
+ ::ndnboost::algorithm::find_format_all(
+ Input,
+ ::ndnboost::algorithm::first_finder(Search, is_iequal(Loc)),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_head --------------------------------------------------------------------//
+
+ //! Replace head algorithm
+ /*!
+ Replace the head of the input with the given format string.
+ The head is a prefix of a string of given size.
+ If the sequence is shorter then required, whole string if
+ considered to be the head.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param N Length of the head.
+ For N>=0, at most N characters are extracted.
+ For N<0, size(Input)-|N| characters are extracted.
+ \param Format A substitute string
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T>
+ inline OutputIteratorT replace_head_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ int N,
+ const Range2T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::head_finder(N),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace head algorithm
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename RangeT>
+ inline SequenceT replace_head_copy(
+ const SequenceT& Input,
+ int N,
+ const RangeT& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::head_finder(N),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace head algorithm
+ /*!
+ Replace the head of the input with the given format string.
+ The head is a prefix of a string of given size.
+ If the sequence is shorter then required, the whole string is
+ considered to be the head. The input sequence is modified in-place.
+
+ \param Input An input string
+ \param N Length of the head.
+ For N>=0, at most N characters are extracted.
+ For N<0, size(Input)-|N| characters are extracted.
+ \param Format A substitute string
+ */
+ template<typename SequenceT, typename RangeT>
+ inline void replace_head(
+ SequenceT& Input,
+ int N,
+ const RangeT& Format )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::head_finder(N),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+// replace_tail --------------------------------------------------------------------//
+
+ //! Replace tail algorithm
+ /*!
+ Replace the tail of the input with the given format string.
+ The tail is a suffix of a string of given size.
+ If the sequence is shorter then required, whole string is
+ considered to be the tail.
+ The result is a modified copy of the input. It is returned as a sequence
+ or copied to the output iterator.
+
+ \param Output An output iterator to which the result will be copied
+ \param Input An input string
+ \param N Length of the tail.
+ For N>=0, at most N characters are extracted.
+ For N<0, size(Input)-|N| characters are extracted.
+ \param Format A substitute string
+ \return An output iterator pointing just after the last inserted character or
+ a modified copy of the input
+
+ \note The second variant of this function provides the strong exception-safety guarantee
+ */
+ template<
+ typename OutputIteratorT,
+ typename Range1T,
+ typename Range2T>
+ inline OutputIteratorT replace_tail_copy(
+ OutputIteratorT Output,
+ const Range1T& Input,
+ int N,
+ const Range2T& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Output,
+ Input,
+ ::ndnboost::algorithm::tail_finder(N),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace tail algorithm
+ /*!
+ \overload
+ */
+ template<typename SequenceT, typename RangeT>
+ inline SequenceT replace_tail_copy(
+ const SequenceT& Input,
+ int N,
+ const RangeT& Format )
+ {
+ return ::ndnboost::algorithm::find_format_copy(
+ Input,
+ ::ndnboost::algorithm::tail_finder(N),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ //! Replace tail algorithm
+ /*!
+ Replace the tail of the input with the given format sequence.
+ The tail is a suffix of a string of given size.
+ If the sequence is shorter then required, the whole string is
+ considered to be the tail. The input sequence is modified in-place.
+
+ \param Input An input string
+ \param N Length of the tail.
+ For N>=0, at most N characters are extracted.
+ For N<0, size(Input)-|N| characters are extracted.
+ \param Format A substitute string
+ */
+ template<typename SequenceT, typename RangeT>
+ inline void replace_tail(
+ SequenceT& Input,
+ int N,
+ const RangeT& Format )
+ {
+ ::ndnboost::algorithm::find_format(
+ Input,
+ ::ndnboost::algorithm::tail_finder(N),
+ ::ndnboost::algorithm::const_formatter(Format) );
+ }
+
+ } // namespace algorithm
+
+ // pull names to the boost namespace
+ using algorithm::replace_range_copy;
+ using algorithm::replace_range;
+ using algorithm::replace_first_copy;
+ using algorithm::replace_first;
+ using algorithm::ireplace_first_copy;
+ using algorithm::ireplace_first;
+ using algorithm::replace_last_copy;
+ using algorithm::replace_last;
+ using algorithm::ireplace_last_copy;
+ using algorithm::ireplace_last;
+ using algorithm::replace_nth_copy;
+ using algorithm::replace_nth;
+ using algorithm::ireplace_nth_copy;
+ using algorithm::ireplace_nth;
+ using algorithm::replace_all_copy;
+ using algorithm::replace_all;
+ using algorithm::ireplace_all_copy;
+ using algorithm::ireplace_all;
+ using algorithm::replace_head_copy;
+ using algorithm::replace_head;
+ using algorithm::replace_tail_copy;
+ using algorithm::replace_tail;
+
+} // namespace ndnboost
+
+#endif // BOOST_REPLACE_HPP
diff --git a/ndnboost/algorithm/string/sequence_traits.hpp b/ndnboost/algorithm/string/sequence_traits.hpp
new file mode 100644
index 0000000..5ef46af
--- /dev/null
+++ b/ndnboost/algorithm/string/sequence_traits.hpp
@@ -0,0 +1,193 @@
+// Boost string_algo library sequence_traits.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_SEQUENCE_TRAITS_HPP
+#define BOOST_STRING_SEQUENCE_TRAITS_HPP
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/mpl/bool.hpp>
+#include <ndnboost/algorithm/string/yes_no_type.hpp>
+
+/*! \file
+ Traits defined in this header are used by various algorithms to achieve
+ better performance for specific containers.
+ Traits provide fail-safe defaults. If a container supports some of these
+ features, it is possible to specialize the specific trait for this container.
+ For lacking compilers, it is possible of define an override for a specific tester
+ function.
+
+ Due to a language restriction, it is not currently possible to define specializations for
+ stl containers without including the corresponding header. To decrease the overhead
+ needed by this inclusion, user can selectively include a specialization
+ header for a specific container. They are located in boost/algorithm/string/stl
+ directory. Alternatively she can include boost/algorithm/string/std_collection_traits.hpp
+ header which contains specializations for all stl containers.
+*/
+
+namespace ndnboost {
+ namespace algorithm {
+
+// sequence traits -----------------------------------------------//
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ //! Native replace tester
+ /*!
+ Declare an override of this tester function with return
+ type ndnboost::string_algo::yes_type for a sequence with this property.
+
+ \return yes_type if the container has basic_string like native replace
+ method.
+ */
+ no_type has_native_replace_tester(...);
+
+ //! Stable iterators tester
+ /*!
+ Declare an override of this tester function with return
+ type ndnboost::string_algo::yes_type for a sequence with this property.
+
+ \return yes_type if the sequence's insert/replace/erase methods do not invalidate
+ existing iterators.
+ */
+ no_type has_stable_iterators_tester(...);
+
+ //! const time insert tester
+ /*!
+ Declare an override of this tester function with return
+ type ndnboost::string_algo::yes_type for a sequence with this property.
+
+ \return yes_type if the sequence's insert method is working in constant time
+ */
+ no_type has_const_time_insert_tester(...);
+
+ //! const time erase tester
+ /*!
+ Declare an override of this tester function with return
+ type ndnboost::string_algo::yes_type for a sequence with this property.
+
+ \return yes_type if the sequence's erase method is working in constant time
+ */
+ no_type has_const_time_erase_tester(...);
+
+#endif //BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ //! Native replace trait
+ /*!
+ This trait specifies that the sequence has \c std::string like replace method
+ */
+ template< typename T >
+ class has_native_replace
+ {
+
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ private:
+ static T* t;
+ public:
+ BOOST_STATIC_CONSTANT(bool, value=(
+ sizeof(has_native_replace_tester(t))==sizeof(yes_type) ) );
+#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ public:
+# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+ enum { value = false };
+# else
+ BOOST_STATIC_CONSTANT(bool, value=false);
+# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+
+ typedef mpl::bool_<has_native_replace<T>::value> type;
+ };
+
+
+ //! Stable iterators trait
+ /*!
+ This trait specifies that the sequence has stable iterators. It means
+ that operations like insert/erase/replace do not invalidate iterators.
+ */
+ template< typename T >
+ class has_stable_iterators
+ {
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ private:
+ static T* t;
+ public:
+ BOOST_STATIC_CONSTANT(bool, value=(
+ sizeof(has_stable_iterators_tester(t))==sizeof(yes_type) ) );
+#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ public:
+# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+ enum { value = false };
+# else
+ BOOST_STATIC_CONSTANT(bool, value=false);
+# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ typedef mpl::bool_<has_stable_iterators<T>::value> type;
+ };
+
+
+ //! Const time insert trait
+ /*!
+ This trait specifies that the sequence's insert method has
+ constant time complexity.
+ */
+ template< typename T >
+ class has_const_time_insert
+ {
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ private:
+ static T* t;
+ public:
+ BOOST_STATIC_CONSTANT(bool, value=(
+ sizeof(has_const_time_insert_tester(t))==sizeof(yes_type) ) );
+#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ public:
+# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+ enum { value = false };
+# else
+ BOOST_STATIC_CONSTANT(bool, value=false);
+# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ typedef mpl::bool_<has_const_time_insert<T>::value> type;
+ };
+
+
+ //! Const time erase trait
+ /*!
+ This trait specifies that the sequence's erase method has
+ constant time complexity.
+ */
+ template< typename T >
+ class has_const_time_erase
+ {
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ private:
+ static T* t;
+ public:
+ BOOST_STATIC_CONSTANT(bool, value=(
+ sizeof(has_const_time_erase_tester(t))==sizeof(yes_type) ) );
+#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+ public:
+# if BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+ enum { value = false };
+# else
+ BOOST_STATIC_CONSTANT(bool, value=false);
+# endif // BOOST_WORKAROUND( __IBMCPP__, <= 600 )
+#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+
+ typedef mpl::bool_<has_const_time_erase<T>::value> type;
+ };
+
+ } // namespace algorithm
+} // namespace ndnboost
+
+
+#endif // BOOST_STRING_SEQUENCE_TRAITS_HPP
diff --git a/ndnboost/algorithm/string/yes_no_type.hpp b/ndnboost/algorithm/string/yes_no_type.hpp
new file mode 100644
index 0000000..740c7b1
--- /dev/null
+++ b/ndnboost/algorithm/string/yes_no_type.hpp
@@ -0,0 +1,33 @@
+// Boost string_algo library yes_no_type.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// Distributed under 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
+#define BOOST_STRING_YES_NO_TYPE_DETAIL_HPP
+
+namespace ndnboost {
+ namespace algorithm {
+
+ // taken from boost mailing-list
+ // when yes_no_type will become officially
+ // a part of boost distribution, this header
+ // will be deprecated
+ template<int I> struct size_descriptor
+ {
+ typedef char (& type)[I];
+ };
+
+ typedef size_descriptor<1>::type yes_type;
+ typedef size_descriptor<2>::type no_type;
+
+ } // namespace algorithm
+} // namespace ndnboost
+
+
+#endif // BOOST_STRING_YES_NO_TYPE_DETAIL_HPP