- Timestamp:
- Jan 8, 2008, 3:40:37 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/AddStats.cc
r545 r552 56 56 void AddStats::do_parse(const std::string& path) 57 57 { 58 Parser parser(path);58 LineTypeParser parser(path); 59 59 SVNlog log(path); 60 60 typedef std::set<svn_revnum_t> RevSet; -
trunk/lib/BlameStats.cc
r537 r552 78 78 void BlameStats::do_parse(const std::string& path) 79 79 { 80 Parser parser(path);80 LineTypeParser parser(path); 81 81 SVNlog log(path); 82 82 typedef std::set<svn_revnum_t> RevSet; … … 100 100 ++rev_iter; 101 101 else { 102 fill_in(code_,rev); 103 fill_in(comments_,rev); 104 fill_in(other_,rev); 102 fill_in(code_stats(),rev); 103 fill_in(comment_stats(),rev); 104 fill_in(other_stats(),rev); 105 fill_in(copyright_stats(),rev); 105 106 } 106 107 } -
trunk/lib/ClassicStats.cc
r537 r552 64 64 void ClassicStats::do_parse(const std::string& path) 65 65 { 66 Parser parser(path);66 LineTypeParser parser(path); 67 67 SVNblame svn_blame(path); 68 68 while (svn_blame.valid()) { -
trunk/lib/File.cc
r546 r552 63 63 map<int, set<Alias> > year_authors; 64 64 SVNlog log(path()); 65 66 assert(log.author().size()==log.date().size()); 67 vector<string>::const_iterator author=log.author().begin(); 68 for (vector<string>::const_iterator date=log.date().begin(); 69 date!=log.date().end(); ++date, ++author) { 70 time_t sec = str2time(*date); 71 tm* timeinfo = gmtime(&sec); 72 73 // find username in map of aliases 74 std::map<string,Alias>::iterator name(alias.lower_bound(*author)); 75 76 // if alias exist insert alias 77 if (name != alias.end() && name->first==*author) 78 year_authors[timeinfo->tm_year].insert(name->second); 79 else { 80 // else insert user name 81 Alias a(*author,alias.size()); 82 year_authors[timeinfo->tm_year].insert(a); 83 std::cerr << "svndigest: warning: no copyright alias found for `" 84 << *author << "'\n"; 85 // insert alias to avoid multiple warnings. 86 alias.insert(name, std::make_pair(*author, a)); 65 const Stats& stats = stats_["add"]; 66 67 68 for (LogIterator i=log.begin(); i<log.end(); ++i){ 69 if (i->revision() && 70 (stats(LineTypeParser::code, i->author(), i->revision()) > 71 stats(LineTypeParser::code, i->author(), i->revision()-1) || 72 stats(LineTypeParser::comment, i->author(), i->revision()) > 73 stats(LineTypeParser::comment, i->author(), i->revision()-1)) 74 ) { 75 76 time_t sec = str2time(i->date()); 77 tm* timeinfo = gmtime(&sec); 78 79 // find username in map of aliases 80 std::map<string,Alias>::iterator name(alias.lower_bound(i->author())); 81 82 // if alias exist insert alias 83 if (name != alias.end() && name->first==i->author()) 84 year_authors[timeinfo->tm_year].insert(name->second); 85 else { 86 // else insert user name 87 Alias a(i->author(),alias.size()); 88 year_authors[timeinfo->tm_year].insert(a); 89 std::cerr << "svndigest: warning: no copyright alias found for `" 90 << i->author() << "'\n"; 91 // insert alias to avoid multiple warnings. 92 alias.insert(name, std::make_pair(i->author(), a)); 93 } 87 94 } 88 95 } … … 129 136 { 130 137 using namespace std; 131 ifstream is(path().c_str()); 132 assert(is.good()); 133 string line; 134 bool found_copyright = false; 135 bool after_copyright = false; 136 size_t line_no=0; 137 while(getline(is, line) && !after_copyright){ 138 ++line_no; 139 if (found_copyright){ 140 // check if line is end of copyright statement, i.e. contains 141 // no alphanumerical character (except in prefix). 142 after_copyright = true; 143 for (size_t i=0; i<line.size()&&after_copyright; ++i) 144 if (isalnum(line[i]) && !(i<prefix.size() && prefix[i]==line[i])) { 145 after_copyright = false; 146 block += line + "\n"; 147 } 148 if (after_copyright) 149 end_at_line=line_no; 150 } 151 else { 152 // check whether copyright starts on this line 153 string::iterator i = search(line.begin(), line.end(), "Copyright (C)"); 154 if (i!=line.end()) { 155 start_at_line=line_no; 156 prefix = line.substr(0, distance(line.begin(), i)); 157 found_copyright = true; 158 block = line + "\n"; 159 } 160 } 161 } 162 is.close(); 163 return found_copyright; 138 LineTypeParser parser(path()); 139 if (!parser.copyright_found()) 140 return false; 141 block = parser.block(); 142 start_at_line = parser.start_line(); 143 end_at_line = parser.end_line(); 144 prefix = parser.prefix(); 145 return true; 164 146 } 165 147 … … 229 211 HtmlStream hs(os); 230 212 SVNblame blame(path_); 231 Parser parser(path_);213 LineTypeParser parser(path_); 232 214 while (blame.valid()) { 233 215 parser.parse(blame.line()); … … 236 218 blame.reset(); 237 219 238 std::vector< Parser::line_type>::const_iterator220 std::vector<LineTypeParser::line_type>::const_iterator 239 221 line_type(parser.type().begin()); 240 222 int last=0; … … 271 253 os << "</td>\n<td class=\""; 272 254 assert(line_type!=parser.type().end()); 273 if (*line_type== Parser::other)255 if (*line_type==LineTypeParser::other) 274 256 os << "line-other"; 275 else if (*line_type== Parser::comment)257 else if (*line_type==LineTypeParser::comment) 276 258 os << "line-comment"; 277 259 else -
trunk/lib/LineTypeParser.cc
r550 r552 22 22 */ 23 23 24 #include " Parser.h"24 #include "LineTypeParser.h" 25 25 #include "Configuration.h" 26 26 #include "utility.h" … … 39 39 40 40 41 Parser::Parser(std::string path)42 : mode_(0) 41 LineTypeParser::LineTypeParser(std::string path) 42 : mode_(0), post_copyright_(false), copyright_found_(false) 43 43 { 44 44 codon_ = Configuration::instance().codon(path); … … 46 46 47 47 48 Parser::line_type Parser::parse(const std::string&line)48 LineTypeParser::line_type LineTypeParser::parse(std::string line) 49 49 { 50 if (codon_) 50 if (!post_copyright_) { 51 if (copyright_found_) { 52 // check if line is end of copyright statement, i.e. contains 53 // no alphanumerical character (except in copyright_prefix). 54 for (size_t i=0; i<line.size()&&post_copyright_; ++i) 55 if (isalnum(line[i]) && 56 !(i<copyright_prefix_.size() && copyright_prefix_[i]==line[i])){ 57 post_copyright_ = false; 58 block_ += line + "\n"; 59 } 60 if (post_copyright_) 61 end_line_ = type_.size()+1; 62 } 63 else { 64 // check whether copyright starts on this line 65 std::string::iterator i=search(line.begin(),line.end(),"Copyright (C)"); 66 if (i!=line.end()) { 67 start_line_ = type_.size()+1; 68 copyright_prefix_ = line.substr(0, distance(line.begin(), i)); 69 copyright_found_ = true; 70 block_ = line+"\n"; 71 } 72 } 73 } 74 // we are in copyright block 75 if (copyright_found_ && !post_copyright_) 76 type_.push_back(LineTypeParser::copyright); 77 78 else if (codon_) 51 79 type_.push_back(code_mode(line)); 52 80 else … … 57 85 58 86 59 Parser::line_typeParser::code_mode(const std::string& str)87 LineTypeParser::line_type LineTypeParser::code_mode(const std::string& str) 60 88 { 61 89 // mode zero means we are currently not in a comment … … 99 127 100 128 101 Parser::line_typeParser::text_mode(const std::string& str)129 LineTypeParser::line_type LineTypeParser::text_mode(const std::string& str) 102 130 { 103 131 for (std::string::const_iterator iter=str.begin(); iter!=str.end(); ++iter) -
trunk/lib/LineTypeParser.h
r550 r552 1 #ifndef _theplu_svndigest_ parser_2 #define _theplu_svndigest_ parser_1 #ifndef _theplu_svndigest_line_type_parser_ 2 #define _theplu_svndigest_line_type_parser_ 3 3 4 4 // $Id$ … … 34 34 35 35 /** 36 \brief Class parsing files36 \brief differentiate code, comments, and blank lines 37 37 38 38 Class gets parsing rules from Configuration. Which rules depends … … 41 41 which can be accessed through function type(void). 42 42 */ 43 class Parser43 class LineTypeParser 44 44 { 45 45 public: … … 47 47 /// see 'doc/readmea.txt' for info on what is code, comment, and other. 48 48 /// 49 // do not change these without checking in Stats class 49 50 enum line_type { 50 copyright, 51 other, 52 comment, 53 code 51 copyright = 0, 52 other = 1, 53 comment = 2, 54 code = 3, 55 comment_or_copy = 4, 56 total = 5 // total should always be the largest 54 57 }; 55 58 … … 58 61 /// \param filename is used to decide which parsing rules to use 59 62 /// 60 explicit Parser(std::string filename); 63 explicit LineTypeParser(std::string filename); 64 65 const std::string& block(void) const { return block_; } 66 inline bool copyright_found(void) const { return copyright_found_; } 67 68 inline size_t end_line(void) const { return end_line_; } 61 69 62 70 /** … … 67 75 The line is parsed and added to internal vector. 68 76 */ 69 line_type parse(const std::string& line); 77 line_type parse(std::string line); 78 79 const std::string& prefix(void) const { return copyright_prefix_; } 80 81 inline size_t start_line(void) const { return start_line_; } 70 82 71 83 /// … … 76 88 private: 77 89 // no copy allowed 78 Parser(constParser& other);79 Parser& operator=(constParser&);90 LineTypeParser(const LineTypeParser& other); 91 LineTypeParser& operator=(const LineTypeParser&); 80 92 81 93 line_type code_mode(const std::string& line); … … 83 95 84 96 size_t mode_; 97 bool post_copyright_; 98 bool copyright_found_; 99 std::string copyright_prefix_; 100 std::string block_; 101 size_t start_line_; 102 size_t end_line_; 85 103 86 104 std::vector<line_type> type_; -
trunk/lib/LogIterator.cc
r519 r552 74 74 75 75 76 bool LogIterator::operator==(const LogIterator& other) const 77 { 78 assert(&log_==&other.log_); 79 return index_==other.index_; 80 } 81 82 83 bool LogIterator::operator!=(const LogIterator& other) const 84 { 85 assert(&log_==&other.log_); 86 return index_!=other.index_; 87 } 88 89 76 90 const Commitment& LogIterator::operator*() const 77 91 { -
trunk/lib/LogIterator.h
r519 r552 49 49 50 50 bool operator<(const LogIterator&) const; 51 bool operator==(const LogIterator&) const; 52 bool operator!=(const LogIterator&) const; 51 53 const Commitment* operator->() const; 52 54 const Commitment& operator*() const; -
trunk/lib/Makefile.am
r549 r552 29 29 Commitment.h Configuration.h css.h\ 30 30 Date.h Directory.h File.h first_page.h Functor.h Gnuplot.h GnuplotFE.h \ 31 HtmlStream.h html_utility.h LogIterator.h Node.h Parser.h rmdirhier.h \ 31 HtmlStream.h html_utility.h LineTypeParser.h \ 32 LogIterator.h Node.h rmdirhier.h \ 32 33 Stats.h StatsCollection.h SVN.h SVNblame.h \ 33 34 SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h … … 38 39 css.cc Date.cc Directory.cc File.cc first_page.cc\ 39 40 Functor.cc Gnuplot.cc GnuplotFE.cc HtmlStream.cc \ 40 html_utility.cc L ogIterator.cc Node.cc Parser.cc \41 html_utility.cc LineTypeParser.cc LogIterator.cc Node.cc \ 41 42 rmdirhier.cc Stats.cc StatsCollection.cc SVN.cc \ 42 43 SVNblame.cc SVNinfo.cc SVNlog.cc SVNproperty.cc Trac.cc utility.cc -
trunk/lib/Stats.cc
r537 r552 51 51 52 52 Stats::Stats(const std::string& path) 53 : stats_(std::vector<Author2Vector>(LineTypeParser::total+1)) 53 54 { 54 55 // Make sure latest revision is set properly … … 81 82 for (std::set<std::string>::const_iterator iter(authors().begin()); 82 83 iter!=authors().end(); ++iter) { 83 std::vector<u_int>& code = code_ [*iter];84 std::vector<u_int>& code = code_stats()[*iter]; 84 85 accumulate(code); 85 std::vector<u_int>& comments = comment s_[*iter];86 std::vector<u_int>& comments = comment_stats()[*iter]; 86 87 accumulate(comments); 87 std::vector<u_int>& other = other_ [*iter];88 std::vector<u_int>& other = other_stats()[*iter]; 88 89 accumulate(other); 89 90 } … … 92 93 93 94 void Stats::add(const std::string& user, const u_int& rev, 94 const Parser::line_type& lt, u_int n)95 const LineTypeParser::line_type& lt, u_int n) 95 96 { 96 97 assert(user.size()); 97 98 add_author(user); 98 99 99 std::vector<u_int>& code = code_[user]; 100 // Peter remove repeat 101 std::vector<u_int>& code = code_stats()[user]; 100 102 if (code.size() < rev+1){ 101 103 code.reserve(rev+1); 102 104 code.resize(rev); 103 if (lt == Parser::code)105 if (lt == LineTypeParser::code) 104 106 code.push_back(n); 105 107 else 106 108 code.push_back(0); 107 109 } 108 else if (lt == Parser::code)110 else if (lt == LineTypeParser::code) 109 111 code[rev]+=n; 110 112 111 std::vector<u_int>& comments = comment s_[user];113 std::vector<u_int>& comments = comment_stats()[user]; 112 114 if (comments.size() < rev+1){ 113 115 comments.reserve(revision() + 1); 114 116 comments.insert(comments.end(), rev - comments.size(), 0); 115 if (lt == Parser::comment)117 if (lt == LineTypeParser::comment) 116 118 comments.push_back(n); 117 119 else 118 120 comments.push_back(0); 119 121 } 120 else if (lt == Parser::comment)122 else if (lt == LineTypeParser::comment) 121 123 comments[rev]+=n; 122 124 123 std::vector<u_int>& other = other_ [user];125 std::vector<u_int>& other = other_stats()[user]; 124 126 if (other.size() < rev+1){ 125 127 other.reserve(revision() + 1); 126 128 other.insert(other.end(), rev - other.size(), 0); 127 if (lt == Parser::other)129 if (lt == LineTypeParser::other) 128 130 other.push_back(n); 129 131 else 130 132 other.push_back(0); 131 133 } 132 else if (lt == Parser::other)134 else if (lt == LineTypeParser::other) 133 135 other[rev]+=n; 134 136 } … … 157 159 { 158 160 std::vector<u_int> init(revision()+1); 159 code_["all"]=std::accumulate(code_.begin(), code_.end(), init, 160 PairValuePlus<std::string,u_int>()); 161 comments_["all"]=std::accumulate(comments_.begin(), comments_.end(), init, 162 PairValuePlus<std::string,u_int>()); 163 other_["all"]=std::accumulate(other_.begin(), other_.end(), init, 164 PairValuePlus<std::string,u_int>()); 161 code_stats()["all"]=std::accumulate(code_stats().begin(), 162 code_stats().end(), init, 163 PairValuePlus<std::string,u_int>()); 164 comment_stats()["all"]=std::accumulate(comment_stats().begin(), 165 comment_stats().end(), init, 166 PairValuePlus<std::string,u_int>()); 167 other_stats()["all"]=std::accumulate(other_stats().begin(), 168 other_stats().end(), init, 169 PairValuePlus<std::string,u_int>()); 170 copyright_stats()["all"]=std::accumulate(copyright_stats().begin(), 171 copyright_stats().end(), init, 172 PairValuePlus<std::string,u_int>()); 165 173 VectorPlus<u_int> vp; 166 total_["all"] = vp(vp(code_["all"], comments_["all"]), other_["all"]); 174 comment_or_copy_stats()["all"] = 175 vp(comment_stats()["all"], copyright_stats()["all"]); 176 177 total_stats()["all"] = 178 vp(vp(code_stats()["all"], comment_or_copy_stats()["all"]), 179 other_stats()["all"]); 167 180 } 168 181 … … 172 185 for (std::set<std::string>::const_iterator iter(authors().begin()); 173 186 iter!=authors().end(); ++iter) { 174 std::vector<u_int>& code = code_[*iter]; 175 std::vector<u_int>& comments = comments_[*iter]; 176 std::vector<u_int>& other = other_[*iter]; 187 std::vector<u_int>& code = code_stats()[*iter]; 188 std::vector<u_int>& comments = comment_stats()[*iter]; 189 std::vector<u_int>& other = other_stats()[*iter]; 190 std::vector<u_int>& copy = copyright_stats()[*iter]; 177 191 178 192 VectorPlus<u_int> vp; 179 total_[*iter] = vp(vp(code, comments),other); 193 total_stats()[*iter] = vp(vp(vp(code, comments),other),copy); 194 } 195 196 } 197 198 199 void Stats::calc_comment_or_copy(void) 200 { 201 for (std::set<std::string>::const_iterator iter(authors().begin()); 202 iter!=authors().end(); ++iter) { 203 std::vector<u_int>& comments = comment_stats()[*iter]; 204 std::vector<u_int>& copy = copyright_stats()[*iter]; 205 206 VectorPlus<u_int> vp; 207 comment_or_copy_stats()[*iter] = vp(comments, copy); 180 208 } 181 209 … … 185 213 u_int Stats::code(const std::string& user) const 186 214 { 187 return get_back(code_ , user);215 return get_back(code_stats(), user); 188 216 } 189 217 … … 191 219 u_int Stats::comments(const std::string& user) const 192 220 { 193 return get_back(comment s_, user);221 return get_back(comment_or_copy_stats(), user); 194 222 } 195 223 … … 197 225 u_int Stats::empty(const std::string& user) const 198 226 { 199 return get_back(other_ , user);227 return get_back(other_stats(), user); 200 228 } 201 229 … … 228 256 u_int Stats::lines(const std::string& user) const 229 257 { 230 return get_back(total_ , user);258 return get_back(total_stats(), user); 231 259 } 232 260 … … 255 283 bool Stats::load_cache(std::istream& is) 256 284 { 285 std::string str; 286 getline(is, str); 287 if (str!=cache_check_str()) 288 return false; 257 289 svn_revnum_t rev; 258 290 is >> rev; … … 263 295 size_t a_size=0; 264 296 is >> a_size; 265 std::string str;266 297 while (authors().size()<a_size && is.good()){ 267 298 getline(is, str); … … 270 301 } 271 302 getline(is, str); 272 if (str!=c ode_cache()){303 if (str!=cache_check_str()) 273 304 return false; 274 } 275 load(is, code_); 276 getline(is, str); 277 getline(is, str); 278 if (str!=comments_cache()){ 279 return false; 280 } 281 load(is, comments_); 282 getline(is, str); 283 getline(is, str); 284 if (str!=other_cache()){ 285 return false; 286 } 287 load(is, other_); 288 getline(is, str); 289 getline(is, str); 290 if (str!=total_cache()){ 291 return false; 292 } 293 load(is, total_); 294 getline(is,str); 295 getline(is,str); 296 if (total_.size()>static_cast<size_t>(rev+1)) 297 return false; 298 accumulate_stats(); 299 return false; 300 return str==end_of_cache(); 305 for (size_t i=0; i<stats_.size(); ++i){ 306 load(is, stats_[i]); 307 getline(is, str); 308 if (str!=cache_check_str()) 309 return false; 310 } 311 return true; 301 312 } 302 313 … … 331 342 { 332 343 do_parse(path); 344 calc_comment_or_copy(); 333 345 calc_total(); 334 346 calc_all(); … … 342 354 const Author2Vector* stat=NULL; 343 355 if (linetype=="total") 344 stat = &total_ ;356 stat = &total_stats(); 345 357 else if (linetype=="code") 346 stat = &code_ ;358 stat = &code_stats(); 347 359 else if (linetype=="comments") 348 stat = &comment s_;360 stat = &comment_or_copy_stats(); 349 361 else if (linetype=="empty") 350 stat = &other_ ;362 stat = &other_stats(); 351 363 assert(stat); 352 364 assert(stat->size()); 365 assert(stat->find("all")!=stat->end()); 353 366 std::vector<u_int> total=get_vector(*stat, "all"); 354 367 double yrange_max=1.03*total.back()+1; … … 360 373 for (std::set<std::string>::const_iterator i=authors_.begin(); 361 374 i != authors_.end(); ++i) { 362 if (lines(*i)) 375 if (lines(*i)) { 376 assert(stat->find(*i)!=stat->end()); 363 377 author_cont.push_back(std::make_pair(*i,get_vector(*stat,*i))); 378 } 364 379 } 365 380 … … 416 431 plot_init(filename); 417 432 GnuplotFE* gp=GnuplotFE::instance(); 418 std::vector<u_int> total = get_vector(total_ , "all");433 std::vector<u_int> total = get_vector(total_stats(), "all"); 419 434 double yrange_max=1.03*total.back()+1; 420 435 gp->yrange(yrange_max); … … 422 437 423 438 ss.str(""); 424 std::vector<u_int> x(get_vector(code_ , "all"));439 std::vector<u_int> x(get_vector(code_stats(), "all")); 425 440 ss << x.back() << " code"; 426 441 gp->command("set key height 2"); … … 430 445 431 446 ss.str(""); 432 x = get_vector(comment s_, "all");447 x = get_vector(comment_or_copy_stats(), "all"); 433 448 ss << x.back() << " comment"; 434 449 gp->command("set key height 4"); … … 438 453 439 454 ss.str(""); 440 x = get_vector(other_ , "all");455 x = get_vector(other_stats(), "all"); 441 456 ss << x.back() << " other"; 442 457 gp->command("set key height 6"); … … 459 474 void Stats::print(std::ostream& os) const 460 475 { 476 os << cache_check_str() << "\n"; 461 477 os << last_changed_rev() << " "; 462 478 os << authors().size() << " "; … … 464 480 std::copy(authors().begin(), authors().end(), 465 481 std::ostream_iterator<std::string>(os, "\n")); 466 os << code_cache() << "\n"; 467 print(os, code_); 468 os << "\n" << comments_cache() << "\n"; 469 print(os, comments_); 470 os << "\n" << other_cache() << "\n"; 471 print(os, other_); 472 os << "\n" << total_cache() << "\n"; 473 print(os, total_); 474 os << "\n" << end_of_cache() << "\n"; 482 os << cache_check_str() << "\n"; 483 for (size_t i=0; i<stats_.size(); ++i){ 484 print(os, stats_[i]); 485 os << cache_check_str() << "\n"; 486 } 475 487 } 476 488 … … 490 502 void Stats::reset(void) 491 503 { 492 total_.clear(); 493 code_.clear(); 494 comments_.clear(); 495 other_.clear(); 504 for (size_t i=0; i<stats_.size(); ++i){ 505 stats_[i].clear(); 506 std::vector<u_int> vec; 507 stats_[i]["all"] = vec; 508 } 496 509 authors_.clear(); 497 std::vector<u_int> vec;498 code_["all"] = vec;499 comments_["all"] = vec;500 other_["all"] = vec;501 total_["all"] = vec;502 510 } 503 511 … … 508 516 last_changed_rev_ = std::max(last_changed_rev_, rhs.last_changed_rev_); 509 517 add_authors(rhs.authors().begin(), rhs.authors().end()); 510 map_add(rhs.code_.begin(), rhs.code_.end(), code_); 511 map_add(rhs.comments_.begin(), rhs.comments_.end(), comments_); 512 map_add(rhs.other_.begin(), rhs.other_.end(), other_); 513 map_add(rhs.total_.begin(), rhs.total_.end(), total_); 514 assert(rhs.other_.size()); 515 assert(other_.size()); 518 assert(stats_.size()==rhs.stats_.size()); 519 for (size_t i=0; i<stats_.size(); ++i) 520 map_add(rhs.stats_[i].begin(), rhs.stats_[i].end(), stats_[i]); 516 521 517 522 return *this; 518 523 } 519 524 525 526 size_t Stats::operator()(int linetype, std::string author, size_t rev) const 527 { 528 assert(linetype<=LineTypeParser::total); 529 A2VConstIter i = stats_[linetype].find(author); 530 if (i==stats_[linetype].end()) 531 throw std::runtime_error(author + " does not exist"); 532 return i->second[rev]; 533 } 520 534 521 535 }} // end of namespace svndigest and namespace theplu -
trunk/lib/Stats.h
r537 r552 27 27 */ 28 28 29 #include " Parser.h"29 #include "LineTypeParser.h" 30 30 31 31 #include <subversion-1/svn_types.h> … … 60 60 /// 61 61 void add(const std::string& user, const u_int& revision, 62 const Parser::line_type&, u_int n=1);62 const LineTypeParser::line_type&, u_int n=1); 63 63 64 64 /// … … 136 136 Stats& operator+=(const Stats&); 137 137 138 138 /** 139 \return number of lines for \a author and \a linetype from 140 revision \a rev. 141 142 \throw if \a author does not exist 143 */ 144 size_t operator()(int linetype, std::string author, size_t rev) const; 139 145 140 146 protected: … … 148 154 std::set<std::string>::const_iterator); 149 155 156 // references to data 157 inline Author2Vector& code_stats(void) 158 { return stats_[LineTypeParser::code]; } 159 inline Author2Vector& comment_stats(void) 160 { return stats_[LineTypeParser::comment]; } 161 inline Author2Vector& copyright_stats(void) 162 { return stats_[LineTypeParser::copyright]; } 163 inline Author2Vector& other_stats(void) 164 { return stats_[LineTypeParser::other]; } 165 inline Author2Vector& comment_or_copy_stats(void) 166 { return stats_[LineTypeParser::comment_or_copy]; } 167 inline Author2Vector& total_stats(void) 168 { return stats_[LineTypeParser::total]; } 169 170 // const references to data 171 inline const Author2Vector& code_stats(void) const 172 { return stats_[LineTypeParser::code]; } 173 inline const Author2Vector& comment_stats(void) const 174 { return stats_[LineTypeParser::comment]; } 175 inline const Author2Vector& copyright_stats(void) const 176 { return stats_[LineTypeParser::copyright]; } 177 inline const Author2Vector& other_stats(void) const 178 { return stats_[LineTypeParser::other]; } 179 inline const Author2Vector& comment_or_copy_stats(void) const 180 { return stats_[LineTypeParser::comment_or_copy]; } 181 inline const Author2Vector& total_stats(void) const 182 { return stats_[LineTypeParser::total]; } 183 150 184 /** 151 185 add range [\a first, \a last) to \a map … … 160 194 void plot_init(const std::string& output) const; 161 195 162 Author2Vector total_;163 Author2Vector code_;164 Author2Vector comments_;165 Author2Vector other_;166 196 std::set<std::string> authors_; 167 197 … … 174 204 // Change this string if cache format is changed in such a way 175 205 // that all old cache files are obsolete. 176 inline std::string end_of_cache(void) const 177 {return "END OF OK CACHE FILE VERSION 4";} 178 inline std::string code_cache(void) const {return "CACHE CODE";} 179 inline std::string comments_cache(void) const {return "CACHE COMMENTS";} 180 inline std::string other_cache(void) const {return "CACHE EMPTY";} 181 inline std::string total_cache(void) const {return "CACHE TOTAL";} 182 183 206 inline std::string cache_check_str(void) const 207 {return "CACHE FILE VERSION 5";} 184 208 185 209 void calc_all(void); 210 void calc_comment_or_copy(void); 186 211 void calc_total(void); 187 212 u_int get_back(const Author2Vector&, std::string user) const; … … 192 217 svn_revnum_t last_changed_rev_; // Should be the latest revision for file 193 218 219 std::vector<Author2Vector> stats_; // from linetype to a2v 194 220 195 221 // using compiler generated copy constructor -
trunk/test/parser.cc
r528 r552 23 23 */ 24 24 25 #include " Parser.h"25 #include "LineTypeParser.h" 26 26 27 27 #include <iostream> … … 44 44 using namespace theplu::svndigest; 45 45 os << "Testing: " << file << std::endl; 46 Parser parser(file);46 LineTypeParser parser(file); 47 47 std::ifstream is(file.c_str()); 48 48 for (size_t i=0; i<parser.type().size(); ++i){ 49 if (parser.type()[i]== Parser::other)49 if (parser.type()[i]==LineTypeParser::other) 50 50 os << "other: "; 51 else if (parser.type()[i]== Parser::comment)51 else if (parser.type()[i]==LineTypeParser::comment) 52 52 os << "comment: "; 53 53 else
Note: See TracChangeset
for help on using the changeset viewer.