Synopsis - Cross-Reference
File: /Synopsis/Parsers/Cxx/Filter.hh1// 2// Copyright (C) 2002 Stephen Davies 3// Copyright (C) 2002 Stefan Seefeld 4// All rights reserved. 5// Licensed to the public under the terms of the GNU LGPL (>= 2), 6// see the file COPYING for details. 7// 8 9#ifndef filter_hh_ 10#define filter_hh_ 11 12#include <Python.h> 13#include <string> 14#include <vector> 15#include "ASG.hh" 16 17class FileFilter 18{ 19public: 20 //. Constructor 21 FileFilter(PyObject *, const std::string &, const std::string &, bool); 22 23 //. Destructor 24 ~FileFilter(); 25 26 std::string get_main_file(); 27 28 //. Sets the prefix for syntax output filenames. 29 //. The syntax filename will be the source filename prepended with the 30 //. prefix, so you probably want the prefix to be a directory. 31 void set_sxr_prefix(const char* filename); 32 33 //. Returns the ASG::SourceFile for the given filename. If length is 34 //. given, then the filename is assumed to be that length. This is useful 35 //. since OCC returns filenames as a reference to the #line directive in 36 //. the preprocessor output and is not null-terminated. 37 ASG::SourceFile* get_sourcefile(const char* filename, size_t length = 0); 38 39 //. Returns whether a function implementation in the given file should 40 //. have it's Ptree walked. This will be true only if the given file is 41 //. one of the files to be stored. 42 bool should_visit_function_impl(ASG::SourceFile* file); 43 44 //. Returns true if links should be generated for the given sourcefile 45 bool should_xref(ASG::SourceFile* file); 46 47 //. Returns true if the given declaration should be stored in the final 48 //. ASG. Note that a Declaration is taken instead of a SourceFile because 49 //. Namespaces may be declared (and contain declarations) in multiple 50 //. files, and Classes may have nested classes defined in other files. 51 bool should_store(ASG::Declaration* decl); 52 53 //. Strips a filename of the basename if present 54 std::string strip_base_path(const std::string& filename); 55 56 //. Returns the filename to use for storing sxr info 57 std::string get_sxr_filename(ASG::SourceFile* file); 58 59 //. Returns a list of all the sourcefiles 60 void get_all_sourcefiles(ASG::SourceFile::vector&); 61 62 //. Returns a pointer to the Filter instance. Note that Filter is *not* a 63 //. regular singleton: instance() will return 0 if the Filter doesn't 64 //. exist, and the constructor/destructor control this. The reason for 65 //. this method is so the C function synopsis_include_hook can use the 66 //. Filter object without having a reference to it. 67 static FileFilter* instance(); 68 69private: 70 struct Private; 71 72 //. Compiler firewalled private data 73 Private* m; 74 75 //. Returns true if the given SourceFile is one of the main files 76 //. (including extra files) 77 bool is_main(std::string filename); 78}; 79 80#endif 81 82// vim: set ts=8 sts=4 sw=4 et: