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 <string> 13 #include <boost/scoped_ptr.hpp> 14 #include "string_view.hpp" 15 #include "syntax_highlight.hpp" 16 #include "values.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 id_categoryquickbook::id_category39 id_category() : c(default_category) {} id_categoryquickbook::id_category40 id_category(categories c_) : c(c_) {} id_categoryquickbook::id_category41 explicit id_category(int c_) : c(categories(c_)) {} 42 operator ==quickbook::id_category43 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( 70 value const&, 71 quickbook::string_view, 72 id_category, 73 source_mode_info const&); 74 void end_section(); 75 int section_level() const; 76 value const& explicit_id() const; 77 source_mode_info section_source_mode() const; 78 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); 82 83 std::string replace_placeholders_with_unresolved_ids( 84 quickbook::string_view) const; 85 std::string replace_placeholders(quickbook::string_view) const; 86 87 unsigned compatibility_version() const; 88 89 private: 90 boost::scoped_ptr<document_state_impl> state; 91 }; 92 } 93 94 #endif 95