Imported Upstream version 1.64.0
[platform/upstream/boost.git] / tools / quickbook / src / document_state.hpp
1 /*=============================================================================
2     Copyright (c) 2011,2013 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_DOCUMENT_STATE_HPP)
10 #define BOOST_QUICKBOOK_DOCUMENT_STATE_HPP
11
12 #include <boost/scoped_ptr.hpp>
13 #include "string_view.hpp"
14 #include <string>
15 #include "values.hpp"
16 #include "syntax_highlight.hpp"
17
18 namespace quickbook
19 {
20     // id_category
21     //
22     // Higher categories get priority over lower ones.
23
24     struct id_category
25     {
26         enum categories
27         {
28             default_category = 0,
29             numbered,           // Just used to avoid random docbook ids
30             generated,          // Generated ids for other elements.
31             generated_heading,  // Generated ids for headings.
32             generated_section,  // Generated ids for sections.
33             generated_doc,      // Generated ids for document.
34             explicit_id,        // Explicitly given by user
35             explicit_section_id,
36             explicit_anchor_id
37         };
38
39         id_category() : c(default_category) {}
40         id_category(categories c) : c(c) {}
41         explicit id_category(int c) : c(categories(c)) {}
42
43         bool operator==(id_category rhs) const { return c == rhs.c; }
44
45         categories c;
46     };
47
48     struct document_state_impl;
49
50     struct document_state
51     {
52         document_state();
53         ~document_state();
54
55         std::string start_file_with_docinfo(
56                 unsigned compatibility_version,
57                 quickbook::string_view include_doc_id,
58                 quickbook::string_view id,
59                 value const& title);
60
61         void start_file(
62                 unsigned compatibility_version,
63                 quickbook::string_view include_doc_id,
64                 quickbook::string_view id,
65                 value const& title);
66
67         void end_file();
68
69         std::string begin_section(quickbook::string_view, id_category,
70             source_mode_info const&);
71         void end_section();
72         int section_level() const;
73         source_mode_info section_source_mode() const;
74
75         std::string old_style_id(quickbook::string_view, id_category);
76         std::string add_id(quickbook::string_view, id_category);
77         std::string add_anchor(quickbook::string_view, id_category);
78
79         std::string replace_placeholders_with_unresolved_ids(
80                 quickbook::string_view) const;
81         std::string replace_placeholders(quickbook::string_view) const;
82
83         unsigned compatibility_version() const;
84     private:
85         boost::scoped_ptr<document_state_impl> state;
86     };
87 }
88
89 #endif