]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/quickbook/src/utils.hpp
3f5c5455dc9324933cb0e6a5d26eda8615b5a4ea
[ceph.git] / ceph / src / boost / tools / quickbook / src / utils.hpp
1 /*=============================================================================
2 Copyright (c) 2002 2004 2006 Joel de Guzman
3 Copyright (c) 2004 Eric Niebler
4 http://spirit.sourceforge.net/
5
6 Use, modification and distribution is subject to the Boost Software
7 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 http://www.boost.org/LICENSE_1_0.txt)
9 =============================================================================*/
10 #if !defined(BOOST_SPIRIT_QUICKBOOK_UTILS_HPP)
11 #define BOOST_SPIRIT_QUICKBOOK_UTILS_HPP
12
13 #include <string>
14 #include <ostream>
15 #include <boost/range/algorithm_ext/push_back.hpp>
16 #include <boost/range/adaptor/transformed.hpp>
17 #include <boost/utility/string_ref.hpp>
18
19 namespace quickbook { namespace detail {
20 std::string encode_string(boost::string_ref);
21 void print_char(char ch, std::ostream& out);
22 void print_string(boost::string_ref str, std::ostream& out);
23 char filter_identifier_char(char ch);
24
25 template <typename Range>
26 inline std::string
27 make_identifier(Range const& range)
28 {
29 std::string out_name;
30
31 boost::push_back(out_name,
32 range | boost::adaptors::transformed(filter_identifier_char));
33
34 return out_name;
35 }
36
37 // URI escape string
38 std::string escape_uri(std::string uri);
39 inline std::string escape_uri(boost::string_ref uri) {
40 return escape_uri(std::string(uri.begin(), uri.end()));
41 }
42
43 // URI escape string, leaving characters generally used in URIs.
44 std::string partially_escape_uri(std::string uri);
45 inline std::string partially_escape_uri(boost::string_ref uri) {
46 return escape_uri(std::string(uri.begin(), uri.end()));
47 }
48
49 inline std::string to_s(boost::string_ref x) {
50 return std::string(x.begin(), x.end());
51 }
52 }}
53
54 #endif // BOOST_SPIRIT_QUICKBOOK_UTILS_HPP
55