Changeset 102:24058c6c98bf in rrlib_util


Ignore:
Timestamp:
03.12.2013 17:54:15 (6 years ago)
Author:
Jens Wettach <wettach@…>
Branch:
default
Phase:
public
Message:

added convenience function

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sFileIOUtils.cpp

    r101 r102  
    223223 
    224224  return true; 
    225 } 
     225} // FileExists() 
     226 
     227 
     228//---------------------------------------------------------------------- 
     229// class sFileIOUtils::CountLineNumbers() 
     230//---------------------------------------------------------------------- 
     231size_t sFileIOUtils::CountLineNumbers(const std::string &filename) 
     232{ 
     233  std::ifstream file(filename); 
     234  return std::count(std::istreambuf_iterator<char>(file), 
     235                    std::istreambuf_iterator<char>(), '\n'); 
     236} // CountLineNumbers() 
     237 
    226238 
    227239 
  • sFileIOUtils.h

    r101 r102  
    130130   */ 
    131131  static bool FileExists(const std::string &filename); 
     132 
     133  /*! 
     134   * \brief Counts # lines in given file 
     135   * 
     136   * \returns # lines 
     137   */ 
     138  static size_t CountLineNumbers(const std::string &filename); 
    132139 
    133140 
Note: See TracChangeset for help on using the changeset viewer.