Click here to Skip to main content
15,881,709 members
Articles / Desktop Programming / ATL

SppMk - a unit testing and GNU make support add-in for Visual Studio 6.0

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
11 Jul 200210 min read 155.1K   1.1K   51  
A DevStudio add-in described provides two interesting IDE integration features: adding a new tab to VC WorkspaceView window and running an arbitrary process under IDE with output sent to "Build" tab of VC Output window.
#include "StdAfx.h"
#include "SuppCmds.h"
#include "ParamStore.h"
#include "Config.h"

Config::Config(): m_sGeneralMakeOpts(""), 
    m_bEnableLog(false),
	m_LogLevel(Logger::cError),
	m_sLogPath(""),
    m_bInstallTab(false),
	m_pStore(&(ParamStore::GetInstance()))
{
    Load();
}

Config::~Config()
{
}

void Config::Load()
{
    m_sGeneralMakeOpts = LoadString("General", "GeneralMakeOpts");
	m_bEnableLog       = LoadBool("General", "EnableLog");
	m_LogLevel         = static_cast<Logger::Level>(LoadLong("General", "LogLevel"));
	m_sLogPath         = LoadString("General", "LogPath");

    for(SupportedCommands::cmditerator_t pCmd = SupportedCommands::GetInstance().begin();
    pCmd != SupportedCommands::GetInstance().end(); ++pCmd)
    {
        if(pCmd->second.bMake)
        {
			CmdOpts opts;
			opts.sMakeOpts        = LoadString(pCmd->second.sCmdName, "MakeOpts");
			opts.bShowInContextMenu = LoadBool(pCmd->second.sCmdName, "ShowInContextMenu");
			opts.bMasterToDswName = LoadBool(pCmd->second.sCmdName, "SetMasterToDswName");
			opts.bRemoveDoneFlags = LoadBool(pCmd->second.sCmdName, "RemoveDoneFlags");
			m_CommandOptions[pCmd->first] = opts;
        }
    }
    m_bInstallTab = LoadBool("General", "InstallTab");
}

void Config::Save()
{
    StoreString("General", "GeneralMakeOpts", m_sGeneralMakeOpts);
    StoreBool("General", "EnableLog", m_bEnableLog);
	StoreLong("General", "LogLevel", m_LogLevel);
	StoreString("General", "LogPath", m_sLogPath);
	StoreBool("General", "InstallTab", m_bInstallTab);
    for(cmdoptcont_t::iterator pCmdOpts = m_CommandOptions.begin();
    pCmdOpts != m_CommandOptions.end(); ++pCmdOpts)
    {
        CmdOpts opts = pCmdOpts->second;
		_bstr_t sSection = SupportedCommands::GetInstance().GetCmdInfo(pCmdOpts->first).sCmdName;
		StoreString(sSection, "MakeOpts", opts.sMakeOpts);
		StoreBool(sSection, "ShowInContextMenu", opts.bShowInContextMenu);
		StoreBool(sSection, "SetMasterToDswName", opts.bMasterToDswName);
		StoreBool(sSection, "RemoveDoneFlags", opts.bRemoveDoneFlags);
    }
}

Config::CmdOpts Config::GetCmdMakeOpts(SupportedCommands::CmdId id) const
{
    return const_cast<Config*>(this)->m_CommandOptions[id];
}

void Config::SetCmdMakeOpts(SupportedCommands::CmdId id, const CmdOpts &opts)
{
    m_CommandOptions[id] = opts;
}

bool Config::LoadBool(const _bstr_t &sSection, const _bstr_t &sKey)
{
	_bstr_t dummy;
	m_pStore->GetValue(sSection, sKey, dummy);
	return dummy.length() > 0;
}

void Config::StoreBool(const _bstr_t &sSection, const _bstr_t &sKey, bool bValue)
{
    m_pStore->PutValue(sSection, sKey, bValue ? "1" : "");
}

long Config::LoadLong(const _bstr_t &sSection, const _bstr_t &sKey)
{
	_bstr_t dummy;
	long ret = 0;
	if(m_pStore->GetValue(sSection, sKey, dummy))
    {
		swscanf(dummy, L"%d", &ret);
    }
	return ret;
}

void Config::StoreLong(const _bstr_t &sSection, const _bstr_t &sKey, long lValue)
{
    WCHAR buf[32] = {L'\0'};
	swprintf(buf, L"%d", lValue);
	m_pStore->PutValue(sSection, sKey, buf);
}

_bstr_t Config::LoadString(const _bstr_t &sSection, const _bstr_t &sKey)
{
	_bstr_t ret;
	m_pStore->GetValue(sSection, sKey, ret);
	return ret;
}

void Config::StoreString(const _bstr_t &sSection, const _bstr_t &sKey, const _bstr_t &sValue)
{
	m_pStore->PutValue(sSection, sKey, sValue);
}

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
Web Developer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions