Changeset 72


Ignore:
Timestamp:
Mar 2, 2006, 11:16:24 PM (16 years ago)
Author:
Peter Johansson
Message:

prefer stl algorithms...

Location:
trunk/lib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r71 r72  
    77#include <algorithm>
    88#include <fstream>
     9#include <functional>
    910#include <iostream>
    1011#include <iterator>
     
    6566    stats_.reset();
    6667
    67     // empty directory treated as one-liner file
    68     if (daughters_.empty())
    69       stats_.parse(path_,true);
    70 
    7168    for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); i++)
    7269      stats_ += (*i)->parse(verbose);
     
    8683    os << std::endl;
    8784
    88     // Peter, use for_each
    89     for (NodeConstIter_ i=daughters_.begin();i!=daughters_.end();i++){
    90       (*i)->print_link(os);
    91       os << "<br/>" << std::endl;
    92     }
     85    // print html links to daughter nodes
     86    transform(daughters_.begin(), daughters_.end(),
     87              std::ostream_iterator<std::string>(os,"\n"),
     88              std::mem_fun(&Node::html_link));
    9389
    9490    print_footer(os);
    9591    os.close();
    9692
    97     // Peter, use for_each
    98     for (NodeConstIter_ i=daughters_.begin();i!=daughters_.end();i++)
    99       (*i)->print(verbose);
     93    // print daughter nodes, i.e, this function is recursive
     94    for_each(daughters_.begin(), daughters_.end(),
     95             std::bind1st(std::mem_fun(&Node::print), verbose));
     96
    10097  }
    10198
  • trunk/lib/File.cc

    r63 r72  
    2626    ss >> revision_;
    2727
    28     binary_ = stats_.parse(path_, binary_);
     28    binary_ = stats_.parse(path_);
    2929    return stats_;
    3030  }
  • trunk/lib/File.h

    r60 r72  
    1818    ///
    1919    File(const std::string& path, const std::string& output="")
    20       : Node(path,output), binary_(false) {}
     20      : Node(path,output), binary_(false), ignore_(false) {}
    2121
    2222    ///
     
    4747    std::string author_;
    4848    bool binary_;
     49    bool ignore_;
    4950    u_int revision_;
    5051 
  • trunk/lib/Node.cc

    r71 r72  
    5151
    5252
     53  std::string Node::html_link(void) const
     54  {
     55    return "<a href=\"" + output_name() + ".html\">" + name() + "</a><br/>";
     56  }
     57 
    5358  bool Node::subversion_controlled(void) const
    5459  {
  • trunk/lib/Node.h

    r60 r72  
    88#include <ostream>
    99#include <string>
     10#include <sstream>
    1011
    1112namespace theplu{
     
    2829    virtual inline ~Node(void) {};
    2930
    30     const std::string& output_name(void) const { return output_name_; }
     31    inline const std::string& output_name(void) const { return output_name_; }
    3132
    3233    ///
     
    4142
    4243    ///
    43     /// Prints a html link.
     44    /// @return html link.
    4445    ///
    45     inline void print_link(std::ostream& os) const
    46     { os << "<a href=\"" << output_name() << ".html\">" << name() << "</a>"; }
     46    std::string html_link(void) const;
    4747 
    4848    ///
  • trunk/lib/Stats.cc

    r65 r72  
    6666
    6767
    68   bool Stats::parse(const std::string& path, const bool binary)
     68  bool Stats::parse(const std::string& path)
    6969  {
    70     if (binary){
    71       std::map<std::string,std::string> svn_info = info(path);
    72       std::stringstream ss(svn_info["Last Changed Rev"]);
    73       u_int revision;
    74       ss >> revision;
    75       add(svn_info["Last Changed Author"],revision);
    76       return true;
    77     }
    78 
    7970    // Calling svn blame
    8071    if (blame(path))
     
    8980      if (line==std::string("binary")){
    9081        is.close();
    91         return parse(path,true);
     82        return true;
    9283      }
    9384    }
  • trunk/lib/Stats.h

    r71 r72  
    2929    /// @return true if file is binary
    3030    ///
    31     bool parse(const std::string&, const bool);
     31    bool parse(const std::string&);
    3232
    3333    ///
Note: See TracChangeset for help on using the changeset viewer.