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_SYNTAX_HIGHLIGHT_HPP)
10 #define BOOST_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP
11 
12 #include <boost/swap.hpp>
13 #include "fwd.hpp"
14 #include "iterator.hpp"
15 #include "phrase_tags.hpp"
16 
17 namespace quickbook
18 {
19     //
20     // source_mode_info
21     //
22     // The source mode is stored in a few places, so the order needs to also be
23     // stored to work out which is the current source mode.
24 
25     struct source_mode_info
26     {
27         source_mode_type source_mode;
28         unsigned order;
29 
source_mode_infoquickbook::source_mode_info30         source_mode_info() : source_mode(source_mode_tags::cpp), order(0) {}
31 
source_mode_infoquickbook::source_mode_info32         source_mode_info(source_mode_type source_mode_, unsigned order_)
33             : source_mode(source_mode_), order(order_)
34         {
35         }
36 
updatequickbook::source_mode_info37         void update(source_mode_info const& x)
38         {
39             if (x.order > order) {
40                 source_mode = x.source_mode;
41                 order = x.order;
42             }
43         }
44 
swapquickbook::source_mode_info45         void swap(source_mode_info& x)
46         {
47             boost::swap(source_mode, x.source_mode);
48             boost::swap(order, x.order);
49         }
50     };
51 
swap(source_mode_info & x,source_mode_info & y)52     inline void swap(source_mode_info& x, source_mode_info& y) { x.swap(y); }
53 
54     void syntax_highlight(
55         parse_iterator first,
56         parse_iterator last,
57         quickbook::state& state,
58         source_mode_type source_mode,
59         bool is_block);
60 }
61 
62 #endif
63