Changeset 510
- Timestamp:
- Dec 9, 2007, 12:12:43 AM (15 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Configuration.cc
r509 r510 62 62 63 63 64 const std::vector<std::pair<std::string, std::string> >* 65 Configuration::codon(std::string file_name) const 66 { 67 for (String2Codons::const_iterator i(string2codons_.begin()); 68 i!=string2codons_.end(); ++i) { 69 if (svndigest::equal(file_name.begin(), file_name.end(), 70 i->first.begin(), i->first.end()) ) { 71 return &i->second; 72 } 73 } 74 return NULL; 75 } 76 77 64 78 const std::map<std::string,Alias>& Configuration::copyright_alias(void) const 65 79 { … … 93 107 set_default(); 94 108 95 //bool parsing_found=false;109 bool parsing_found=false; 96 110 std::string line; 97 111 std::string section; … … 140 154 } 141 155 } 142 else if (section == "copyright") 156 else if (section == "copyright") { 143 157 if (lhs=="missing-copyright-warning") 144 158 if (equal_false(rhs)) … … 152 166 throw std::runtime_error(mess.str()); 153 167 } 168 } 169 else if (section == "parsing-codons") { 170 if (!parsing_found) { 171 parsing_found=true; 172 string2codons_.clear(); 173 std::cout << "clear" << std::endl; 174 } 175 176 if (codon(lhs)) { 177 std::stringstream mess; 178 mess << "svndigest: invalid config file\n" 179 << "line: `" << line << "' is invalid.\n" 180 << "clashes with previous given file-name-pattern: "; 181 // find previous file-name-pattern 182 for (String2Codons::const_iterator i(string2codons_.begin()); 183 i!=string2codons_.end(); ++i) { 184 if (svndigest::equal(lhs.begin(), lhs.end(), 185 i->first.begin(), i->first.end()) ) { 186 mess << "`" << i->first << "'"; 187 break; 188 } 189 } 190 throw std::runtime_error(mess.str()); 191 } 192 std::cout << "lhs:" << lhs << " " << "rhs:" << rhs << std::endl; 193 std::stringstream ss(rhs); 194 std::string start; 195 while (getline(ss, start, ':')) { 196 trim(start); 197 std::string end; 198 getline(ss, end, ';'); 199 trim(end); 200 if (!start.empty() && !end.empty()) 201 add_codon(lhs, start, end); 202 else if (!start.empty() || !end.empty()) { 203 std::stringstream mess; 204 mess << "svndigest: invalid config file\n" 205 << "line: `" << line << "' is invalid.\n"; 206 throw std::runtime_error(mess.str()); 207 } 208 } 209 } 154 210 } 155 211 } … … 167 223 { 168 224 return missing_copyright_warning_; 169 }170 171 172 const std::vector<std::pair<std::string, std::string> >*173 Configuration::parse_codon(std::string file_name) const174 {175 for (String2Codons::const_iterator i(string2codons_.begin());176 i!=string2codons_.end(); ++i) {177 if (svndigest::equal(file_name.begin(), file_name.end(),178 i->first.begin(), i->first.end()) ) {179 return &i->second;180 }181 }182 return NULL;183 225 } 184 226 -
trunk/lib/Configuration.h
r509 r510 45 45 static Configuration& instance(void); 46 46 47 /** 48 \return vector of parse codons for the given \a file_name 49 */ 50 const std::vector<std::pair<std::string, std::string> >* 51 codon(std::string file_name) const; 52 47 53 /// 48 54 /// @brief Aliases for Copyright … … 66 72 /// 67 73 bool missing_copyright_warning(void) const; 68 69 /**70 \return vector of parse codons for the given \a file_name71 */72 const std::vector<std::pair<std::string, std::string> >*73 parse_codon(std::string file_name) const;74 74 75 75 ///
Note: See TracChangeset
for help on using the changeset viewer.