Changeset 454


Ignore:
Timestamp:
Aug 18, 2007, 2:01:45 AM (14 years ago)
Author:
Peter Johansson
Message:

adding print function in Stats class - refs #78

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r439 r454  
    3333#include <cassert>
    3434#include <cstdlib>
     35#include <fstream>
    3536#include <iostream>
     37#include <iterator>
    3638#include <map>
    3739#include <numeric>
     
    277279
    278280
     281  void Stats::print(std::ostream& os) const
     282  {
     283    os << last_changed_rev_ << "\n";
     284    os << authors_.size() << "\n";
     285    std::copy(authors_.begin(), authors_.end(),
     286              std::ostream_iterator<std::string>(os, "\n"));
     287    print(os, code_);
     288    print(os, comments_);
     289    print(os, empty_);
     290    print(os, total_);
     291  }
     292
     293
     294  void Stats::print(std::ostream& os, const Map_& m) const
     295  {
     296    for (MapConstIter_ i(m.begin()); i!=m.end(); ++i){
     297      os << i->first << "\n";
     298      os << i->second.size() << "\n";
     299      std::copy(i->second.begin(), i->second.end(),
     300                std::ostream_iterator<u_int>(os, "\n"));
     301    }
     302  }
     303
     304
    279305  Stats& Stats::operator+=(const Stats& other)
    280306  {
  • trunk/lib/Stats.h

    r439 r454  
    121121    void plot_summary(const std::string& output) const;
    122122
     123    /**
     124     */
     125    void print(std::ostream&) const;
     126
    123127    ///
    124128    /// @brief Clear all statistics
     
    175179
    176180
     181    void print(std::ostream& os, const Map_& map) const;
     182
    177183    svn_revnum_t revision_; // Should be the latest revision for whole project
    178184    svn_revnum_t last_changed_rev_; // Should be the latest revision for file
Note: See TracChangeset for help on using the changeset viewer.