00001 // idep_aliasdep.h 00002 #ifndef INCLUDED_IDEP_ALIASDEP 00003 #define INCLUDED_IDEP_ALIASDEP 00004 00005 // This component defines 1 fully insulated wrapper class: 00006 // idep_AliasDep: environment for creating/verifying filename aliases 00007 00008 #include <iosfwd> 00009 00010 class idep_AliasDep_i; 00011 class idep_AliasDep { 00012 idep_AliasDep_i *d_this; 00013 00014 private: 00015 idep_AliasDep(const idep_AliasDep&); // not implemented 00016 idep_AliasDep& operator=(const idep_AliasDep&); // not implemented 00017 00018 public: 00019 // CREATORS 00020 idep_AliasDep(); 00021 ~idep_AliasDep(); 00022 00023 // MANIPULATORS 00024 void addIgnoreName(const char *name); 00025 // Add a name to ignored during processing. A command-line argument 00026 // or -f<filelist> entry matching the specified name will not be 00027 // considered during any subsequent analysis. 00028 00029 int readIgnoreNames(const char *file); 00030 // Add a list of names to ignore during processing. This function 00031 // assumes that each contiguous sequence of non-whitespace characters 00032 // represents a name to be ignored. This function returns 0 unless 00033 // the specified file is unreadable or contains non-ascii characters. 00034 00035 const char *addAlias(const char *aliasName, const char *componentName); 00036 // Add an alias/component name pair to the set of aliases. This 00037 // function returns 0 on success or a character string containing 00038 // a previously corresponding component name for this alias that is 00039 // not identical to the one specified here. 00040 00041 int readAliases(std::ostream& err, const char *file); 00042 // Read a list of component aliases from the specified file. Each 00043 // contiguous sequence of non-whitespace characters represents a name. 00044 // Names are also arranged into sequences. The first name in a name 00045 // sequence represents the actual component name. Names that follow 00046 // on the same line (horizontal sequence) or subsequent lines 00047 // (vertical sequence) are interpreted as aliases for that component 00048 // name. A horizontal sequence is terminated by a newline ('\n') 00049 // unless preceded by a backslash ('\\'). A vertical sequence is 00050 // terminated by a blank line. This function quietly returns 0 on 00051 // success. If the specified file is not readable, this function 00052 // quietly returns -1. If an alias that is inconsistent with a 00053 // previously specified alias is encountered, the conflicting aliases 00054 // are identified to the err stream. After parsing is complete, the 00055 // number of offending aliases is returned as the value of this 00056 // function. 00057 00058 void addFileName(const char *fileName); 00059 // Add the name of a file to be analyzed. Errors in reading this file 00060 // will be detected only when a processing operation is invoked. 00061 00062 int readFileNames(const char *file); 00063 // Add a list of file names read from a specified file. This function 00064 // assumes that each contiguous sequence of non-whitespace characters 00065 // represents a file name to be added. The effect is the same as if 00066 // each file name had been added individually. This function returns 00067 // 0 unless the specified file is unreadable or contains non-ascii 00068 // characters. Errors in reading individual files named there in 00069 // will be detected only when a processing operation is invoked. 00070 00071 void inputFileNames(); 00072 // Similar to readFileNames except that input is presumed to come 00073 // from <stdin>, which is reset on eof. No check is done for 00074 // non-ascii characters. 00075 00076 // ACCESSORS 00077 int unpaired(std::ostream& out,std::ostream& err,int suffixFlag=1) const; 00078 // Format a list of unpaired files to the specified output 00079 // stream (out). If more than two files have the same root, 00080 // produce a warning on the error stream (err). By default 00081 // suffixes will be included when identifying unpaired files 00082 // setting this flag to 0 causes only the root names to be 00083 // printed and these names to be sorted in a more convenient 00084 // order for creating an alias file via editor cut-and-paste. 00085 // This function returns the number of unpaired files. 00086 00087 int verify(std::ostream& err) const; 00088 // Verify that all specified (.c) file dependencies are properly 00089 // paired after any aliases are applied. If a specified file fails 00090 // to include its corresponding header file as the first include 00091 // directive, an error will be reported to the specified error 00092 // stream (err). If any file cannot be opened, the value returned 00093 // by this function is negative. Otherwise, this function returns 00094 // the number of files containing missing or misplaced include 00095 // directives. 00096 00097 int extract(std::ostream& out, std::ostream& err) const; 00098 // Extract any necessary aliases from the specified set of (.c) files 00099 // and format them to the specified output stream (out) assuming that 00100 // the corresponding header file is the first include directive in the 00101 // specified (.c) file. If a specified (.c) file contains no include 00102 // directives, an error will be reported to the specified error 00103 // stream (err). If the same header is deduced as belonging to more 00104 // than a single (.c ) file, a warning message is printed to (err). 00105 // If any file cannot be opened, the value returned by this function 00106 // is negative. Otherwise, this function returns the number of files 00107 // containing no include directives. 00108 }; 00109 00110 #endif 00111 00112