1 /*============================================================================= 2 Copyright (c) 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(QUICKBOOK_DEPENDENCY_TRACKER_HPP) 10 #define QUICKBOOK_DEPENDENCY_TRACKER_HPP 11 12 #include <iosfwd> 13 #include <map> 14 #include <set> 15 #include <boost/filesystem/path.hpp> 16 17 namespace quickbook 18 { 19 namespace fs = boost::filesystem; 20 21 struct dependency_tracker 22 { 23 private: 24 typedef std::map<fs::path, bool> dependency_list; 25 typedef std::map<fs::path, std::set<fs::path> > glob_list; 26 27 dependency_list dependencies; 28 glob_list glob_dependencies; 29 glob_list::iterator last_glob; 30 31 public: 32 enum flags 33 { 34 default_ = 0, 35 checked = 1, 36 escaped = 2 37 }; 38 39 dependency_tracker(); 40 41 // Call this before loading any file so that it will be included in the 42 // list of dependencies. Returns true if file exists. 43 bool add_dependency(fs::path const&); 44 45 void add_glob(fs::path const&); 46 void add_glob_match(fs::path const&); 47 48 void write_dependencies(fs::path const&, flags = default_); 49 void write_dependencies(std::ostream&, flags = default_); 50 }; 51 } 52 53 #endif 54