simpleparsers.cpp
来自「一个统计文件大小和程序信息的插件程序(vc或vc.net下使用)」· C++ 代码 · 共 52 行
CPP
52 行
/***************************************************************************/
/* 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. */
/***************************************************************************/
#include "StdAfx.h"
#include "Resource.h"
#include "SimpleParsers.h"
#include "Config.h"
CSimpleCommentParser::CSimpleCommentParser(LPCTSTR pszCommentPrefix) :
m_sCommentPrefix(pszCommentPrefix)
{
}
void CSimpleCommentParser::ParseFile(ifstream& ifs, CFileInfo& info)
{
const int comment_length = m_sCommentPrefix.GetLength();
CString sLine;
while (!ifs.eof() && ifs.good())
{
ifs.getline(sLine.GetBuffer(10240), 10240);
sLine.ReleaseBuffer();
sLine.TrimLeft();
sLine.TrimRight();
if (sLine.IsEmpty() && cfg_bProcessBlanks)
{
++info.m_iBlankLines;
}
else
{
if (comment_length > 0 &&
sLine.GetLength() >= comment_length &&
sLine.Left(comment_length) == m_sCommentPrefix)
{
++info.m_iLinesWithComments;
}
else
{
++info.m_iLinesWithCode;
}
}
++info.m_iTotalLines;
}
info.m_stat = CFileInfo::full;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?