• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2002 2004 2006 Joel de Guzman
3     Copyright (c) 2004 Eric Niebler
4     Copyright (c) 2005 Thomas Guest
5     Copyright (c) 2013 Daniel James
6 
7     Use, modification and distribution is subject to the Boost Software
8     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9     http://www.boost.org/LICENSE_1_0.txt)
10 =============================================================================*/
11 
12 #if !defined(BOOST_QUICKBOOK_INCLUDE_PATHS_HPP)
13 #define BOOST_QUICKBOOK_INCLUDE_PATHS_HPP
14 
15 // Classes and functions for dealing with the values from include, import and
16 // xinclude elements.
17 
18 #include <set>
19 #include <string>
20 #include <boost/filesystem/path.hpp>
21 #include "fwd.hpp"
22 #include "values.hpp"
23 
24 namespace quickbook
25 {
26     struct path_parameter
27     {
28         // Will possibly add 'url' to this list later:
29         enum path_type
30         {
31             invalid,
32             path,
33             glob
34         };
35 
36         std::string value;
37         path_type type;
38 
path_parameterquickbook::path_parameter39         path_parameter(std::string const& value_, path_type type_)
40             : value(value_), type(type_)
41         {
42         }
43     };
44 
45     path_parameter check_path(value const& path, quickbook::state& state);
46     path_parameter check_xinclude_path(value const&, quickbook::state&);
47 
48     struct quickbook_path
49     {
quickbook_pathquickbook::quickbook_path50         quickbook_path(fs::path const& x, unsigned offset, fs::path const& y)
51             : file_path(x), include_path_offset(offset), abstract_file_path(y)
52         {
53         }
54 
55         friend void swap(quickbook_path&, quickbook_path&);
56 
57         quickbook_path parent_path() const;
58 
59         bool operator<(quickbook_path const& other) const;
60         quickbook_path operator/(quickbook::string_view) const;
61         quickbook_path& operator/=(quickbook::string_view);
62 
63         // The actual location of the file.
64         fs::path file_path;
65 
66         // The member of the include path that this file is relative to.
67         // (1-indexed, 0 == original quickbook file)
68         unsigned include_path_offset;
69 
70         // A machine independent representation of the file's
71         // path - not unique per-file
72         fs::path abstract_file_path;
73     };
74 
75     std::set<quickbook_path> include_search(
76         path_parameter const&, quickbook::state& state, string_iterator pos);
77 
78     quickbook_path resolve_xinclude_path(
79         std::string const&, quickbook::state&, bool is_file = false);
80 }
81 
82 #endif
83