LifeV
inspector.hpp
Go to the documentation of this file.
1 // inspector 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_INSPECTOR_HPP
10 #define BOOST_INSPECTOR_HPP
11 
12 #include <string>
13 #include <iostream>
14 #include <set>
15 #include <boost/filesystem/path.hpp>
16 
17 using std::string;
18 using boost::filesystem::path;
19 
20 namespace boost
21 {
22 namespace inspect
23 {
24 typedef std::set< string > string_set;
25 
26 class inspector
27 {
28 public:
29  virtual ~inspector() {}
30 
31  virtual const char* name() const = 0; // example: "tab-check"
32  virtual const char* desc() const = 0; // example: "verify no tabs"
33 
34  // always called:
35  virtual void inspect (
36  const string& library_name, // "filesystem"
37  const path& full_path ) {} // "c:/foo/boost/filesystem/path.hpp"
38 
39  // called only for registered leaf() signatures:
40  virtual void inspect (
41  const string& library_name, // "filesystem"
42  const path& full_path, // "c:/foo/boost/filesystem/path.hpp"
43  const string& contents ) {} // contents of file
44 
45  // called after all paths visited, but still in time to call error():
46  virtual void close() {}
47 
48  // callback used by constructor to register leaf() signature.
49  // Signature can be a full file name (Jamfile) or partial (.cpp)
50  void register_signature ( const string& signature );
51  const string_set& signatures() const
52  {
53  return m_signatures;
54  }
55 
56  // report error callback (from inspect(), close() ):
57  void error (
58  const string& library_name,
59  const path& full_path,
60  const string& msg );
61 
62 private:
64 };
65 
66 // for inspection of source code of one form or other
68 {
69 public:
70  // registers the basic set of known source signatures
72 };
73 
74 // for inspection of hypertext, specifically html
76 {
77 public:
78  // registers the set of known html source signatures
80 };
81 
82 inline string relative_to ( const path& src_arg, const path& base_arg )
83 {
84  path src ( src_arg );
85  src.normalize();
86  path base ( base_arg );
87  base.normalize();
88  string::size_type pos ( base.string().size() );
89  return src.string().substr (
90  pos + ( pos < src.string().size() ? 1 : 0 ) );
91 }
92 
93 string impute_library ( const path& full_dir_path );
94 
95 }
96 }
97 
98 #endif // BOOST_INSPECTOR_HPP
string impute_library(const path &full_dir_path)
Definition: inspect.cpp:559
void register_signature(const string &signature)
Definition: inspect.cpp:479
const string_set & signatures() const
Definition: inspector.hpp:51
virtual void close()
Definition: inspector.hpp:46
virtual void inspect(const string &library_name, const path &full_path, const string &contents)
Definition: inspector.hpp:40
std::set< string > string_set
Definition: inspector.hpp:24
virtual void inspect(const string &library_name, const path &full_path)
Definition: inspector.hpp:35
string relative_to(const path &src_arg, const path &base_arg)
Definition: inspector.hpp:82
virtual const char * name() const =0
virtual const char * desc() const =0
void error(const string &library_name, const path &full_path, const string &msg)
Definition: inspect.cpp:487