]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
11fdf7f2 | 12 | #include <string> |
7c673cae | 13 | #include <boost/scoped_ptr.hpp> |
b32b8144 | 14 | #include "string_view.hpp" |
7c673cae | 15 | #include "syntax_highlight.hpp" |
11fdf7f2 | 16 | #include "values.hpp" |
7c673cae FG |
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, | |
11fdf7f2 TL |
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 | |
7c673cae FG |
35 | explicit_section_id, |
36 | explicit_anchor_id | |
37 | }; | |
38 | ||
39 | id_category() : c(default_category) {} | |
b32b8144 FG |
40 | id_category(categories c_) : c(c_) {} |
41 | explicit id_category(int c_) : c(categories(c_)) {} | |
7c673cae FG |
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( | |
11fdf7f2 TL |
56 | unsigned compatibility_version, |
57 | quickbook::string_view include_doc_id, | |
58 | quickbook::string_view id, | |
59 | value const& title); | |
7c673cae FG |
60 | |
61 | void start_file( | |
11fdf7f2 TL |
62 | unsigned compatibility_version, |
63 | quickbook::string_view include_doc_id, | |
64 | quickbook::string_view id, | |
65 | value const& title); | |
7c673cae FG |
66 | |
67 | void end_file(); | |
68 | ||
11fdf7f2 TL |
69 | std::string begin_section( |
70 | value const&, | |
71 | quickbook::string_view, | |
72 | id_category, | |
73 | source_mode_info const&); | |
7c673cae FG |
74 | void end_section(); |
75 | int section_level() const; | |
b32b8144 | 76 | value const& explicit_id() const; |
7c673cae FG |
77 | source_mode_info section_source_mode() const; |
78 | ||
b32b8144 FG |
79 | std::string old_style_id(quickbook::string_view, id_category); |
80 | std::string add_id(quickbook::string_view, id_category); | |
81 | std::string add_anchor(quickbook::string_view, id_category); | |
7c673cae FG |
82 | |
83 | std::string replace_placeholders_with_unresolved_ids( | |
11fdf7f2 | 84 | quickbook::string_view) const; |
b32b8144 | 85 | std::string replace_placeholders(quickbook::string_view) const; |
7c673cae FG |
86 | |
87 | unsigned compatibility_version() const; | |
11fdf7f2 TL |
88 | |
89 | private: | |
7c673cae FG |
90 | boost::scoped_ptr<document_state_impl> state; |
91 | }; | |
92 | } | |
93 | ||
94 | #endif |