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_ACTIONS_CLASS_HPP) 11 #define BOOST_SPIRIT_ACTIONS_CLASS_HPP 12 13 #include <map> 14 #include <boost/scoped_ptr.hpp> 15 #include "collector.hpp" 16 #include "dependency_tracker.hpp" 17 #include "include_paths.hpp" 18 #include "parsers.hpp" 19 #include "symbols.hpp" 20 #include "syntax_highlight.hpp" 21 #include "template_stack.hpp" 22 #include "values_parse.hpp" 23 24 namespace quickbook 25 { 26 namespace cl = boost::spirit::classic; 27 namespace fs = boost::filesystem; 28 29 struct state 30 { 31 state( 32 fs::path const& filein_, 33 fs::path const& xinclude_base, 34 string_stream& out_, 35 document_state&); 36 37 private: 38 boost::scoped_ptr<quickbook_grammar> grammar_; 39 40 public: 41 /////////////////////////////////////////////////////////////////////////// 42 // State 43 /////////////////////////////////////////////////////////////////////////// 44 45 typedef std::vector<std::string> string_list; 46 47 static int const max_template_depth = 100; 48 49 // global state 50 unsigned order_pos; 51 fs::path xinclude_base; 52 template_stack templates; 53 int error_count; 54 string_list anchors; 55 bool warned_about_breaks; 56 bool conditional; 57 document_state& document; 58 value_builder callouts; // callouts are global as 59 int callout_depth; // they don't nest. 60 dependency_tracker dependencies; 61 bool explicit_list; // set when using a list 62 bool strict_mode; 63 64 // state saved for files and templates. 65 bool imported; 66 string_symbols macro; 67 source_mode_info source_mode; 68 source_mode_type source_mode_next; 69 value source_mode_next_pos; 70 std::vector<source_mode_info> tagged_source_mode_stack; 71 file_ptr current_file; 72 quickbook_path current_path; 73 74 // state saved for templates. 75 int template_depth; 76 int min_section_level; 77 78 // output state - scoped by templates and grammar 79 bool in_list; // generating a list 80 std::stack<bool> in_list_save; // save the in_list state 81 collector out; // main output stream 82 collector phrase; // phrase output stream 83 84 // values state - scoped by everything. 85 value_parser values; // parsed values 86 87 quickbook_grammar& grammar() const; 88 89 /////////////////////////////////////////////////////////////////////////// 90 // actions 91 /////////////////////////////////////////////////////////////////////////// 92 93 void update_filename_macro(); 94 95 unsigned get_new_order_pos(); 96 97 void push_output(); 98 void pop_output(); 99 100 void start_list(char mark); 101 void end_list(char mark); 102 void start_list_item(); 103 void end_list_item(); 104 105 void start_callouts(); 106 std::string add_callout(value); 107 std::string end_callouts(); 108 109 source_mode_info current_source_mode() const; 110 source_mode_info tagged_source_mode() const; 111 void change_source_mode(source_mode_type); 112 void push_tagged_source_mode(source_mode_type); 113 void pop_tagged_source_mode(); 114 }; 115 116 extern unsigned 117 qbk_version_n; // qbk_major_version * 100 + qbk_minor_version 118 extern char const* quickbook_get_date; 119 extern char const* quickbook_get_time; 120 } 121 122 #endif // BOOST_SPIRIT_ACTIONS_CLASS_HPP 123