Imported Upstream version 1.51.0
[platform/upstream/boost.git] / tools / quickbook / src / id_manager.hpp
1 /*=============================================================================
2     Copyright (c) 2011 Daniel James
3
4     Use, modification and distribution is subject to the Boost Software
5     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6     http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8
9 #if !defined(BOOST_QUICKBOOK_ID_MANAGER_HPP)
10 #define BOOST_QUICKBOOK_ID_MANAGER_HPP
11
12 #include <boost/scoped_ptr.hpp>
13 #include <string>
14 #include "values.hpp"
15
16 namespace quickbook
17 {
18     // id_category
19     //
20     // Higher categories get priority over lower ones.
21
22     struct id_category
23     {
24         enum categories
25         {
26             default_category = 0,
27             numbered,           // Just used to avoid random docbook ids
28             generated,          // Generated ids for other elements.
29             generated_heading,  // Generated ids for headings.
30             generated_section,  // Generated ids for sections.
31             generated_doc,      // Generated ids for document.
32             explicit_id,        // Explicitly given by user
33             explicit_section_id,
34             explicit_anchor_id
35         };
36
37         id_category() : c(default_category) {}
38         id_category(categories c) : c(c) {}
39         explicit id_category(int c) : c(categories(c)) {}
40
41         bool operator==(id_category rhs) const { return c == rhs.c; }
42
43         categories c;
44     };
45
46     struct id_state;
47     struct section_manager;
48
49     struct id_manager
50     {
51         id_manager();
52         ~id_manager();
53
54         std::string start_file_with_docinfo(
55                 unsigned compatibility_version,
56                 std::string const& include_doc_id,
57                 std::string const& id,
58                 value const& title);
59
60         void start_file(
61                 unsigned compatibility_version,
62                 std::string const& include_doc_id,
63                 std::string const& id,
64                 value const& title);
65
66         void end_file();
67
68         std::string begin_section(std::string const&, id_category);
69         void end_section();
70         int section_level() const;
71
72         std::string old_style_id(std::string const&, id_category);
73         std::string add_id(std::string const&, id_category);
74         std::string add_anchor(std::string const&, id_category);
75
76         std::string replace_placeholders_with_unresolved_ids(
77                 std::string const&) const;
78         std::string replace_placeholders(std::string const&) const;
79         
80         unsigned compatibility_version() const;
81     private:
82         boost::scoped_ptr<id_state> state;
83     };
84 }
85
86 #endif