Changeset 508
- Timestamp:
- Dec 8, 2007, 8:08:33 AM (15 years ago)
- Location:
- trunk/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Configuration.cc
r465 r508 45 45 46 46 47 void Configuration::add_codon(std::string key, std::string start, 48 std::string end) 49 { 50 std::pair<std::string, std::string> p(start,end); 51 String2Codons::iterator iter = string2codons_.end(); 52 for (String2Codons::iterator i=string2codons_.begin(); 53 i!=string2codons_.end(); ++i) 54 if (i->first == key) 55 iter = i; 56 57 if (iter==string2codons_.end()) 58 string2codons_.push_back(std::make_pair(key, codons(1,p))); 59 else 60 iter->second.push_back(p); 61 } 62 63 47 64 const std::map<std::string,Alias>& Configuration::copyright_alias(void) const 48 65 { … … 76 93 set_default(); 77 94 95 //bool parsing_found=false; 78 96 std::string line; 79 97 std::string section; … … 135 153 } 136 154 } 155 add_codon("*", "", ""); 137 156 } 138 157 … … 152 171 153 172 173 const std::vector<std::pair<std::string, std::string> >& 174 Configuration::parse_codon(std::string file_name) const 175 { 176 for (String2Codons::const_iterator i(string2codons_.begin()); 177 i!=string2codons_.end(); ++i) { 178 if (svndigest::equal(file_name.begin(), file_name.end(), 179 i->first.begin(), i->first.end()) ) { 180 return i->second; 181 } 182 } 183 return string2codons_.back().second; 184 } 185 186 187 std::string trans_end_code(std::string str) 188 { 189 if (str.size()>0 && str[str.size()-1]=='\n') 190 return str.substr(0, str.size()-1) + std::string("<NEWLINE>"); 191 return str; 192 } 193 194 195 std::string trans_beg_code(std::string str) 196 { 197 if (str.size()>0 && str[0]=='\n') 198 return std::string("<NEWLINE>") + str.substr(1); 199 return str; 200 } 201 202 154 203 void Configuration::set_default(void) 155 204 { … … 157 206 missing_copyright_warning_=false; 158 207 trac_root_ = ""; 208 209 add_codon("*.ac", "#", "\n"); 210 add_codon("*.ac", "dnl", "\n"); 211 add_codon("*.am", "#", "\n"); 212 add_codon("*.am", "dnl", "\n"); 213 add_codon("*.m4", "#", "\n"); 214 add_codon("*.m4", "dnl", "\n"); 215 add_codon("*.c", "//", "\n"); 216 add_codon("*.c", "/*", "*/"); 217 add_codon("*.cc", "//", "\n"); 218 add_codon("*.cc", "/*", "*/"); 219 add_codon("*.cpp", "//", "\n"); 220 add_codon("*.cpp", "/*", "*/"); 221 add_codon("*.cxx", "//", "\n"); 222 add_codon("*.cxx", "/*", "*/"); 223 add_codon("*.h", "//", "\n"); 224 add_codon("*.h", "/*", "*/"); 225 add_codon("*.hh", "//", "\n"); 226 add_codon("*.hh", "/*", "*/"); 227 add_codon("*.hpp", "//", "\n"); 228 add_codon("*.hpp", "/*", "*/"); 229 add_codon("*.java", "//", "\n"); 230 add_codon("*.java", "/*", "*/"); 231 add_codon("*.pl", "#", "\n"); 232 add_codon("*.pm", "#", "\n"); 233 add_codon("*.sh", "#", "\n"); 234 add_codon("*config", "#", "\n"); 235 add_codon("bootstrap", "#", "\n"); 236 add_codon("Makefile", "#", "\n"); 237 add_codon("*.tex", "%", "\n"); 238 add_codon("*.m", "%", "\n"); 239 add_codon("*.jsp", "<!--", "-->"); 240 add_codon("*.html", "<%--", "--%>"); 241 add_codon("*.xml", "<!--", "-->"); 242 add_codon("*.xsl", "<!--", "-->"); 243 add_codon("*.xsd", "<!--", "-->"); 244 add_codon("*.xhtml", "<!--", "-->"); 245 add_codon("*.shtml", "<!--", "-->"); 246 add_codon("*.xml", "<!--", "-->"); 247 add_codon("*.css", "<!--", "-->"); 248 add_codon("*.rss", "<!--", "-->"); 249 add_codon("*.sgml", "<!--", "-->"); 250 add_codon("*.bat", "\nREM", "\n"); 159 251 } 160 252 … … 212 304 os << "trac-root = " << conf.trac_root() << "\n"; 213 305 306 if (conf.string2codons_.size()>1) { 307 os << "\n" 308 << "### Section for setting parsing modes\n" 309 << "### The format of the entries is:\n" 310 << "### file-name-pattern = start-code : end-code\n" 311 << "### The file-name-pattern may contain wildcards (such as '*' " 312 << "and '?').\n" 313 << "### String \"<NEWLINE>\" can be used for codons containing newline" 314 << "\n### character: '\\n'\n" 315 << "[parsing]\n"; 316 for (size_t i=0; i<conf.string2codons_.size()-1; ++i) 317 for (size_t j=0; j<conf.string2codons_[i].second.size(); ++j) 318 os << conf.string2codons_[i].first << " = " 319 << trans_beg_code(conf.string2codons_[i].second[j].first) 320 << " : " 321 << trans_end_code(conf.string2codons_[i].second[j].second) 322 << "\n"; 323 } 324 214 325 return os; 215 326 } -
trunk/lib/Configuration.h
r446 r508 31 31 #include <string> 32 32 #include <utility> 33 #include <vector> 33 34 34 35 namespace theplu{ … … 66 67 bool missing_copyright_warning(void) const; 67 68 69 /** 70 \return vector of parse codons for the given \a file_name 71 */ 72 const std::vector<std::pair<std::string, std::string> >& 73 parse_codon(std::string file_name) const; 74 68 75 /// 69 76 /// @return root for the trac envrionment, e.g., … … 84 91 Configuration& operator=(const Configuration&); 85 92 93 friend std::ostream& operator<<(std::ostream&, const Configuration&); 94 95 void add_codon(std::string, std::string, std::string); 96 86 97 void clear(void); 87 98 88 99 bool equal_false(const std::string&) const; 89 100 bool equal_true(const std::string&) const; 90 101 std::string trans_end_code(std::string) const; 102 std::string trans_beg_code(std::string) const; 91 103 void set_default(void); 92 104 93 105 static Configuration* instance_; 94 106 … … 96 108 97 109 bool missing_copyright_warning_; 110 111 typedef std::vector<std::pair<std::string, std::string> > codons; 112 typedef std::vector<std::pair<std::string, codons> > String2Codons; 113 String2Codons string2codons_; 114 98 115 std::string trac_root_; 99 116 }; -
trunk/lib/utility.cc
r507 r508 97 97 return true; 98 98 if (first1!=end1 && first2!=end2 && 99 (*first1==*first2 || *first1=='*' || *first2=='*') && 99 (*first1==*first2 || *first1=='*' || *first2=='*' || 100 *first1=='?' || *first2=='?') && 100 101 equal(first1+1, end1, first2+1, end2) ) 101 102 return true;
Note: See TracChangeset
for help on using the changeset viewer.