Blame view

3rdparty/boost_1_81_0/tools/inspect/inspector.hpp 2.87 KB
73ef4ff3   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  //  inspector header  --------------------------------------------------------//
  
  //  Copyright Beman Dawes 2002.
  //  Copyright Rene Rivera 2004.
  //  Copyright Gennaro Prota 2006.
  //
  //  Distributed under the Boost Software License, Version 1.0.
  //  (See accompanying file LICENSE_1_0.txt or copy at
  //  http://www.boost.org/LICENSE_1_0.txt)
  
  #ifndef BOOST_INSPECTOR_HPP
  #define BOOST_INSPECTOR_HPP
  
  #include <set>
  #include <iostream>
  #include <ostream>
  #include <string>
  #include "boost/filesystem/path.hpp"
  
  using std::string;
  using boost::filesystem::path;
  
  namespace boost
  {
    namespace inspect
    {
      typedef std::set< string > string_set;
  
      const char * line_break();
  
      path search_root_path();
  
      class inspector
      {
      protected:
          inspector() {}
  
      public:
        virtual ~inspector() {}
  
        virtual const char * name() const = 0; // example: "tab-check"
        virtual const char * desc() const = 0; // example: "verify no tabs"
  
        // always called:
        virtual void inspect(
          const string & /*library_name*/, // "filesystem"
          const path & /*full_path*/ ) {}  // "c:/foo/boost/filesystem/path.hpp"
  
        // called only for registered leaf() signatures:
        virtual void inspect(
          const string & library_name, // "filesystem"
          const path & full_path,      // "c:/foo/boost/filesystem/path.hpp"
          const string & contents )    // contents of file
        = 0
        ;
  
        // called after all paths visited, but still in time to call error():
        virtual void close() {}
  
        // callback used by constructor to register leaf() signature.
        // Signature can be a full file name (Jamfile) or partial (.cpp)
        void register_signature( const string & signature );
        const string_set & signatures() const { return m_signatures; }
  
        // report error callback (from inspect(), close() ):
        void error(
          const string & library_name,
          const path & full_path,
          const string & msg,
          int line_number =0 );  // 0 if not available or not applicable
  
      private:
        string_set m_signatures;
      };
  
      // for inspection of source code of one form or other
      class source_inspector : public inspector
      {
      public:
        // registers the basic set of known source signatures
        source_inspector();
      };
  
      // for inspection of hypertext, specifically html
      class hypertext_inspector : public inspector
      {
      public:
        // registers the set of known html source signatures
        hypertext_inspector();
      };
  
      inline string relative_to( const path & src_arg, const path & base_arg )
      {
        path base( base_arg );
        base.normalize();
        string::size_type pos( base.string().size() );
        path src( src_arg.string().substr(pos) );
        src.normalize();
        return src.string().substr(1);
      }
  
      string impute_library( const path & full_dir_path );
  
    }
  }
  
  #endif // BOOST_INSPECTOR_HPP