• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  link_check header  -------------------------------------------------------//
2 
3 //  Copyright Beman Dawes 2002
4 //  Copyright Rene Rivera 2004.
5 //  Distributed under the Boost Software License, Version 1.0.
6 //  (See accompanying file LICENSE_1_0.txt or copy at
7 //  http://www.boost.org/LICENSE_1_0.txt)
8 
9 #ifndef BOOST_LINK_CHECK_HPP
10 #define BOOST_LINK_CHECK_HPP
11 
12 #include <map>
13 
14 #include "inspector.hpp"
15 
16 namespace boost
17 {
18   namespace inspect
19   {
20     const int m_linked_to = 1;
21     const int m_present = 2;
22     const int m_nounlinked_errors = 4;
23 
24     class link_check : public hypertext_inspector
25     {
26       long m_broken_errors;
27       long m_unlinked_errors;
28       long m_invalid_errors;
29       long m_bookmark_errors;
30       long m_duplicate_bookmark_errors;
31 
32       typedef std::map< string, int > m_path_map;
33       m_path_map m_paths; // first() is relative to search_root_path()
34 
35       void do_url( const string & url, const string & library_name,
36         const path & full_source_path, bool no_link_errors,
37         bool allow_external_links,
38         std::string::const_iterator contents_begin, std::string::const_iterator url_start);
39     public:
40 
41       link_check();
name() const42       virtual const char * name() const { return "*LINK*"; }
desc() const43       virtual const char * desc() const
44       { return "invalid bookmarks, duplicate bookmarks,"
45                " invalid urls, broken links, unlinked files"; }
46 
47       virtual void inspect(
48         const std::string & library_name,
49         const path & full_path );
50 
51       virtual void inspect(
52         const std::string & library_name,
53         const path & full_path,
54         const std::string & contents );
55 
56       virtual void close();
57 
~link_check()58       virtual ~link_check()
59         {
60           std::cout << "  " << m_bookmark_errors
61                     << " bookmarks with invalid characters" << line_break();
62           std::cout << "  " << m_duplicate_bookmark_errors
63                     << " duplicate bookmarks" << line_break();
64           std::cout << "  " << m_invalid_errors << " invalid urls" << line_break();
65           std::cout << "  " << m_broken_errors << " broken links" << line_break();
66           std::cout << "  " << m_unlinked_errors << " unlinked files" << line_break();
67         }
68     };
69   }
70 }
71 
72 #endif // BOOST_LINK_CHECK_HPP
73