Click here to Skip to main content
15,892,674 members
Articles / Desktop Programming / MFC

Yaida

Rate me:
Please Sign up or sign in to vote.
2.74/5 (6 votes)
25 Aug 20043 min read 35.9K   173   9  
Yet another installer deployment application.

#include "stdafx.h"
#include "xml.h"
#include "globals.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

bool ParseVDStr( LPCTSTR&p, CString& t )
{
	t.Empty( );
	for( ; ; )
	{
		while( *p != '\"' && *p != '\\' && p != '\0' )
			t+= *p++;

		if( *p == '\"' )
		{
			++p;
			return true;
		}
		if( *p == '\\' )
		{
			t+= *++p;
			++p;
		}
		if( *p == '\0' )
			return false;
	}
}

HRESULT GetVDtoXML( CFile* file, CXML& xml )
{
	//visual deployment rules:
	//"name" of node.
	// followed by '=' makes it a simple node like <test>data</test>
	// followed by '{' makes it a parent node with element children.
	// "DeployProject" will become the root node.

	int depth= 0;
	LPVOID buf;
	const TCHAR* p;
	CString name, data;
	HRESULT result;

	if( ( result= GetFileBuf( file, &buf ) ) != ERROR_SUCCESS )
		return result;

	p= (LPCTSTR)buf;
	xml.CreateEmptyDoc( _T("VisualDevelopmentXML" ) );

	for( ; ; )
	{
//
	while( _istspace( *p ) )
		++p;

	if( *p == '}' )
	{
		--depth;
		xml.UpNode( );
		++p;
		if( depth == 0 )
			break; //for(..)
		else
			continue;
	}

	ASSERT( *p == '\"' );

	if( !ParseVDStr( ++p, name ) )
		return ERROR_BAD_FORMAT;

	while( _istspace( *p ) )
		++p;

	switch( *p )
	{
//
	case '{': //will have children.
	{
		++depth;
		xml.AddNewNode( name );
		++p;
		break; //case
	}

	case '=': //lone child node
	{
		++p;
		while( _istspace( *p ) )
			++p;

		ASSERT( *p == '\"' );
		++p;

		ParseVDStr( p, data );
		xml.AddNewElement( name, data );
		break; //case
	}
//
	}//case(..)
//
	}//for(..)
	free( buf );
	return ERROR_SUCCESS;
}

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
Systems Engineer
United States United States
In 2001 my wife and I started on a new business venture. Reserve Analyst Software

http://www.ReserveAnalyst.com

I have been messing with computers since the 6502 was announced. A good deal on the hardware side.


http://www.Lakeweb.net


Thanks, Dan.


Comments and Discussions