Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Cyclomatic Complexity Viewer

, 30 Jun 2005
A Cyclomatic complexity viewer application.
ccmetricviewer_dll.zip
Program Files
CCMetricViewer
1033
Resource.dll
CCMetricViewer.dll
ccmetricviewer_src.zip
C++ Programs
CCMetricViewer
AddIn.def
AddIn.rgs
ccmlogo.bmp
logo.bmp
mlogo.bmp
Resource
ccmlogo.bmp
mlogo.bmp
vc6_dll.zip
Microsoft Visual Studio
COMMON
MSDev98
AddIns
CycloComplexViewer.dll
vc6_source.zip
CycloComplexViewer
CycloComplexViewer.clw
CycloComplexViewer.def
CycloComplexViewer.dsp
CycloComplexViewer.dsw
CycloComplexViewer.odl
res
logo.ico
TBarLrge.bmp
TBarMedm.bmp
/*  ====================================================================
*  Copyright (c) 2005 Franz Klein, franzaklein@yahoo.co.uk
*  All rights reserved.
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*  1. Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer.
*
*  2. Redistributions in binary form must reproduce the above copyright
*     notice, this list of conditions and the following disclaimer in the
*     documentation and/or other materials provided with the distribution.
*
*  3. The name of the author may not be used to endorse or promote products
*     derived from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
*  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
*  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
*  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
*  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*  ====================================================================
*/

// Parser.h: Schnittstelle f�r die Klasse CParser.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PARSER_H__3FDC5480_1A11_11D8_998A_AEF5ED3EB60D__INCLUDED_)
#define AFX_PARSER_H__3FDC5480_1A11_11D8_998A_AEF5ED3EB60D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>
#include <vector>
#include <sstream>
#include <assert.h>
#include "wordsearcher.h"
#include "data.h"

using namespace std;

typedef vector<string>::iterator location;

class CParser  
{
public:
	CParser();
	~CParser();

	void Parse(string buffer, int size);

private:
	bool GetLinesofCode(int size);
	void RemoveWhiteSpace(string& textline);
	void RemoveComments(string& textline);
	void RemoveTabs(string& textline);
	void RemoveSpaces(string& textline);
	void RemoveEndline(string& textline);
	void RemoveCStyleComment(string& textline);
	void RemoveMacros(string& textline);
	bool IsStartCStyleComment(string& textline, string::size_type& pos);
	bool IsEndCStyleComment(string& textline, string::size_type& pos);
	bool IsCPPComment(string& textline, string::size_type& pos);
	bool IsCompoundStatement(location& start);
	bool IsEmptyCompoundStatement(location start, location end);
	bool IsIfElseStatement(location input);
	bool HasWord(location currentline);
	void AddParseData(string codeline, string& word);
	bool RemoveCase(string& codeline);
	void RemoveCBrace(string& codeline);
	void RemoveOBrace(string& codeline);
	void RemoveDo(string& codeline);
	void RemoveElse(string& codeline);

	location ConditionalSwitcher(location input);
	location IfElseParser(location input);
	location IfParser(location input);
	location ElseParser(location input);
	location DoParser(location input);
	location WhileParser(location input);
	location SwitchParser(location input);
	location ConditionalParser(location input);
	location CaseParser(location input);
	location FindEndCompoundStatement(location input);
	location ParseCompoundStatement(location first_statement);

	vector<string> codelines;
	stringstream codebuffer;
	int m_nlevel;
	int m_ncaselevel;
	CWordSearcher m_dictionary;
	bool m_binsidecomment;
	int m_inif;
	bool m_bifelse;
	bool m_biselse;
	int m_inwhile;
	int m_indo;
	bool m_bcase;
	int m_ncase;
	int m_inelse;
	vector<string>::iterator ifpart;
	vector<Data>* parsedatalist;

	string empty_string;
	string empty_statement;
};

#endif // !defined(AFX_PARSER_H__3FDC5480_1A11_11D8_998A_AEF5ED3EB60D__INCLUDED_)

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

Share

About the Author

Franz Klein

United Kingdom United Kingdom
I am a qualified Veterinary Surgeon who prefers treating computers with viruses than animals with viruses. I have recently completed a MEng German Informatics degree at the University of Reading with a 2:1. I also have the ISEB Foundation Certificate in Software Testing.
 
Currently I am umemployed and desparately looking for a job in the IT industry.

| Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 1 Jul 2005
Article Copyright 2005 by Franz Klein
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid