Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C++

Project Line Counter Add-In v2.10 for VS.NET and VC6

Rate me:
Please Sign up or sign in to vote.
4.92/5 (38 votes)
29 Jun 2003 447.9K   5.3K   142  
Get statistics about your source code with a click of a button
/***************************************************************************/
/* NOTE:                                                                   */
/* This document is copyright (c) by Oz Solomonovich, and is bound by the  */
/* MIT open source license (www.opensource.org/licenses/mit-license.html). */
/* See License.txt for more information.                                   */
/***************************************************************************/

#ifndef __FILEPARSER_H
#define __FILEPARSER_H

class CFileInfo
{
public:
    CFileInfo() : 
        m_iLinesWithComments(0), 
        m_iLinesWithCode(0), 
        m_iBlankLines(0), 
        m_iTotalLines(0),
        m_iContext(-1),
        m_stat(unknown) {}

    enum stat 
    { 
        unknown,        // file not processed yet
        file_error,     // error reading the file
        filtered,       // the file was not read due to filtering
        full            // stats have been fully read
    };
    stat m_stat;

    int m_iContext;  // used by list control population code to track duplicates

    CString m_sFullFileName;

    CString m_sFilePath;
    CString m_sFileName;
    CString m_sFileExt;

    int m_iTotalLines;
    int m_iLinesWithCode;
    int m_iLinesWithComments;
    int m_iBlankLines;

    CString GetTotalLinesStr       (bool bDecorated = true) const;
    CString GetLinesWithCodeStr    (bool bDecorated = true) const;
    CString GetLinesWithCommentsStr(bool bDecorated = true) const;
    CString GetMixedLinesStr       (bool bDecorated = true) const;
    CString GetBlankLinesStr       (bool bDecorated = true) const;

    int CalculateMixedLines() const
    {
        return m_iLinesWithCode + m_iLinesWithComments - 
            (m_iTotalLines - m_iBlankLines);
    }

    void SetFileName(LPCTSTR pszFullFileName);

protected:

    CString DecoratedNumber(int iNum, bool bDecorated, bool bNA) const;
};

class IFileParser
{
public:
    IFileParser() {};
    virtual ~IFileParser() {};

    virtual void ParseFile(ifstream& ifs, CFileInfo& info) = 0;

    virtual LPCTSTR GetDefaultExtensions() const = 0;
    virtual LPCTSTR GetParserCfgCode() const = 0;
    virtual int GetParserNameResourceID() const = 0;
};

#endif // __FILEPARSER_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Experion
Canada Canada
You may know Oz from his WndTabs days. Oz has long since left client side development to work on web technologies and to consult in the R&D management field.

Comments and Discussions