Files Classes Functions Hierarchy
#include <compilationfile.h>
Public Types | |
| enum | filetype { unknown = 0, header, source, obj } |
Public Member Functions | |
| stringc | filenamefull () const |
| e.g. | |
| boolc | isheader () const |
| Is this file a header? | |
| boolc | issource () const |
| Is this file a cpp file? | |
| boolc | isobj () const |
| Is this file an object file? | |
| compilationfile (stringc &fullfilename) | |
| Interpret the string extracting path and type. | |
| compilationfile (stringc &path_, stringc &filename_) | |
| Interpret the string extracting type. | |
| compilationfile (stringc &path_, stringc &filename_, filetype ft_) | |
| Not all headers have .h, this lets construction explicitly pass that information in. | |
| stringc | extension () const |
| Filename extension. | |
| stringc | component () const |
| Filename without the extension. | |
| void | determinefiletype () |
| Set ft based on extension. | |
| void | print () const |
| Print to standard output info. | |
| void | clear () |
| Clears all data fields. | |
| boolc | includesvalid () const |
| Verify unique list of elements. | |
| boolc | includesadd (compilationfile *cf) |
| Add the file if it is not already contained in includes. | |
Public Attributes | |
| string | filename |
| Primary id e.g. | |
| string | path |
| Relative to a directory inside proj. | |
| filetype | ft |
| compilationfile * | linkheader |
| Link to header file if it exists. | |
| compilationfile * | linksource |
| Link to cpp/source file if it exists. | |
| compilationfile * | linkobj |
| Link to obj file if this is a header, cpp pair. | |
| vector< compilationfile * > | includes |
| For source file - a list of files from include directive. | |
Static Public Attributes | |
| static uint | filenamelengthmax = 40 |
| Restriction so hash algorithm has a maximum length. | |
Definition at line 15 of file compilationfile.h.
| compilationfile::compilationfile | ( | stringc & | fullfilename | ) |
Interpret the string extracting path and type.
Definition at line 43 of file compilationfile.cpp.
References clear(), determinefiletype(), filename, filenamelengthmax, and path.
00044 { 00045 clear(); 00046 00047 assert( fullfilename.length()>0 ); 00048 00049 string::size_type pos2 = fullfilename.rfind("/"); 00050 filename = fullfilename.substr(pos2+1); 00051 00052 path = fullfilename.substr(0,pos2+1); 00053 00054 determinefiletype(); 00055 00056 // Maximum number of characters for hash. 00057 assert(filename.length() <= filenamelengthmax); 00058 }
Interpret the string extracting type.
Definition at line 61 of file compilationfile.cpp.
00065 { 00066 clear(); 00067 00068 filename=filename_; 00069 path=path_; 00070 00071 determinefiletype(); 00072 00073 // Maximum number of characters for hash. 00074 assert(filename.length() <= filenamelengthmax); 00075 }
Not all headers have .h, this lets construction explicitly pass that information in.
Definition at line 78 of file compilationfile.cpp.
00083 { 00084 clear(); 00085 00086 filename=filename_; 00087 path=path_; 00088 ft=ft_; 00089 00090 // Maximum number of characters for hash. 00091 assert(filename.length() <= filenamelengthmax); 00092 }
| void compilationfile::clear | ( | ) |
Clears all data fields.
Definition at line 32 of file compilationfile.cpp.
References filename, ft, linkheader, linkobj, linksource, path, and unknown.
Referenced by compilationfile().
00033 { 00034 filename=""; 00035 path=""; 00036 ft=unknown; 00037 00038 linkheader=0; 00039 linksource=0; 00040 linkobj=0; 00041 }
| stringc compilationfile::component | ( | ) | const |
Filename without the extension.
Definition at line 104 of file compilationfile.cpp.
References filename.
Referenced by makestate< CFC >::eval(), and print().
00105 { 00106 assert( filename.length()>0 ); 00107 00108 string::size_type pos3 = filename.rfind("."); 00109 string s1 = filename.substr(0,pos3); 00110 00111 return s1; 00112 }
| void compilationfile::determinefiletype | ( | ) |
Set ft based on extension.
Definition at line 114 of file compilationfile.cpp.
References extension(), ft, header, obj, and source.
Referenced by compilationfile().
00115 { 00116 string ext=extension(); 00117 00118 if (ext==".h") 00119 ft=header; 00120 if (ext==".cpp") 00121 ft=source; 00122 if (ext==".o") 00123 ft=obj; 00124 }
| stringc compilationfile::extension | ( | ) | const |
Filename extension.
Definition at line 94 of file compilationfile.cpp.
References filename.
Referenced by determinefiletype(), and print().
00095 { 00096 assert( filename.length()>0 ); 00097 00098 string::size_type pos = filename.rfind("."); 00099 string s1 = filename.substr(pos); 00100 00101 return s1; 00102 }
| stringc compilationfile::filenamefull | ( | ) | const [inline] |
| boolc compilationfile::includesadd | ( | compilationfile * | cf | ) |
Add the file if it is not already contained in includes.
Definition at line 182 of file compilationfile.cpp.
References assertreturnfalse, filename, includes, and includesvalid().
Referenced by makestate< CFC >::eval(), makestate< CFC >::objsdependenciesPass2(), and makestate< CFC >::objseval().
00183 { 00184 assertreturnfalse(cf); 00185 //assert(cf); 00186 00187 // if (cf==this) 00188 // return false; 00189 00190 uint imax=includes.size(); 00191 for ( uint i=0; i<imax; ++i) 00192 { 00193 if (includes[i]==cf) 00194 return false; 00195 if (includes[i]->filename==cf->filename) 00196 return false; 00197 } 00198 00199 includes.push_back(cf); 00200 includesvalid(); 00201 return true; 00202 }
| boolc compilationfile::includesvalid | ( | ) | const |
Verify unique list of elements.
Definition at line 141 of file compilationfile.cpp.
References filename, includes, print(), SHOW, and SHOW3.
Referenced by includesadd(), and makestate< CFC >::objseval().
00142 { 00143 00144 //cout << SHOW(this) << " " << filename << endl; 00145 00146 /* 00147 { 00148 for (uint i=0; i<includes.size(); ++i) 00149 //cout << i << ":" << includes[i] << " " << includes[i]->filename << endl; 00150 cout << i << ":" << includes[i] << " "; 00151 cout << endl; 00152 } 00153 */ 00154 00155 00156 uint imax=includes.size(); 00157 for (uint i=0; i<imax; ++i) 00158 { 00159 if (includes[i]==0) 00160 return false; 00161 00162 for (uint k=i+1; k<imax; ++k) 00163 { 00164 if (includes[i]==includes[k]) 00165 { 00166 cout << SHOW(this) << " " << filename << endl; 00167 cout << i << "," << k << ":" << SHOW3(includes[i]); 00168 cout << endl; 00169 this->print(); 00170 00171 //cout << " " << includes[i]->filename << endl; 00172 //for (uint i=0; i<includes.size(); ++i) 00173 // { cout << includes[i]->print(); } 00174 return false; 00175 } 00176 } 00177 } 00178 00179 return true; 00180 }
| boolc compilationfile::isheader | ( | ) | const |
| boolc compilationfile::isobj | ( | ) | const |
| boolc compilationfile::issource | ( | ) | const |
| void compilationfile::print | ( | ) | const |
Print to standard output info.
Definition at line 9 of file compilationfile.cpp.
References component(), extension(), filename, ft, includes, isheader(), isobj(), issource(), path, and SHOW.
Referenced by includesvalid(), compilationfiletest::test01(), compilationfiletest::test03(), and makestatetest::test05().
00010 { 00011 cout << SHOW(filename) << endl; 00012 cout << SHOW(path) << endl; 00013 cout << SHOW(ft) << endl; 00014 cout << SHOW(component()) << endl; 00015 cout << SHOW(extension()) << endl; 00016 00017 cout << SHOW(isheader()) << endl; 00018 cout << SHOW(issource()) << endl; 00019 cout << SHOW(isobj()) << endl; 00020 00021 cout << "includes: "; 00022 for (uint i=0; i<includes.size(); ++i) 00023 { 00024 if (includes[i]==0) 00025 continue; 00026 00027 cout << " " << includes[i]->filename; 00028 } 00029 cout << endl; 00030 }
| string compilationfile::filename |
Primary id e.g.
myfile.h.
Definition at line 23 of file compilationfile.h.
Referenced by cfcontainervec::add(), cfcontainerhash::add(), clear(), compilationfile(), component(), makestate< CFC >::eval(), extension(), filenamefull(), includesadd(), includesvalid(), makestate< CFC >::objseval(), projfiles< CFC >::print(), makestate< CFC >::print(), and print().
uint compilationfile::filenamelengthmax = 40 [static] |
Restriction so hash algorithm has a maximum length.
Definition at line 20 of file compilationfile.h.
Referenced by compilationfile().
Definition at line 32 of file compilationfile.h.
Referenced by clear(), determinefiletype(), makestate< CFC >::eval(), isheader(), isobj(), issource(), makestate< CFC >::objsdependenciesPass2(), makestate< CFC >::objseval(), and print().
| vector<compilationfile*> compilationfile::includes |
For source file - a list of files from include directive.
For an obj file - a list of dependencies for the Makefile.
Definition at line 69 of file compilationfile.h.
Referenced by makestate< CFC >::eval(), includesadd(), includesvalid(), makestate< CFC >::objsdependenciesPass2(), makestate< CFC >::objseval(), createmakefile< CFC >::pathsbuild(), makestate< CFC >::print(), and print().
Link to header file if it exists.
Definition at line 61 of file compilationfile.h.
Referenced by clear(), makestate< CFC >::eval(), and makestate< CFC >::objseval().
Link to obj file if this is a header, cpp pair.
Definition at line 65 of file compilationfile.h.
Referenced by clear(), makestate< CFC >::eval(), and makestate< CFC >::objseval().
Link to cpp/source file if it exists.
Definition at line 63 of file compilationfile.h.
Referenced by clear(), makestate< CFC >::eval(), and makestate< CFC >::objseval().
| string compilationfile::path |
Relative to a directory inside proj.
Definition at line 25 of file compilationfile.h.
Referenced by clear(), compilationfile(), makestate< CFC >::eval(), filenamefull(), projfiles< CFC >::print(), and print().
1.5.8