#ifndef _included_boost_algorithm_quote_hpp_ #define _included_boost_algorithm_quote_hpp_ // Boost string_algo library quote.hpp header file // Copyright Robert Stewart 2010. // // 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. #include #include #include #include #include namespace boost { namespace algorithm { template OutIt quote(OutIt _out, Range & _input, Char _delimiter = '"', Char _escape = '\\'); template inline Sequence quote(Sequence const & _input); template inline Sequence quote(Sequence const & _input, Char _delimiter = '"', Char _escape = '\\'); } } template OutIt boost::algorithm::quote(OutIt _out, Range & _input, Char _delimiter, Char _escape) { typedef typename boost::range_iterator::type iterator_type; typedef typename boost::range_value::type value_type; *_out++ = _delimiter; for (iterator_type it(boost::begin(_input)), end(boost::end(_input)); it != end; ++it) { value_type const ch(*it); if (ch == _delimiter || ch == _escape) { *_out++ = _escape; } *_out++ = ch; } *_out++ = _delimiter; return _out; } template inline Sequence boost::algorithm::quote(Sequence const & _input, Char _delimiter, Char _escape) { Sequence result; quote(std::back_inserter(result), _input, _delimiter, _escape); return result; } template inline Sequence boost::algorithm::quote(Sequence const & _input) { return quote(_input, '"', '\\'); } #endif