Click here to Skip to main content
15,886,137 members
Articles / Desktop Programming / MFC

FiveLoaves v1.0

Rate me:
Please Sign up or sign in to vote.
3.84/5 (10 votes)
2 Jul 20028 min read 84.7K   4.4K   49  
FiveLoaves is an Internet utility designed to meet the most common needs of internet users - primarily secure connectivity
// --------------------------------------------------------------------------
//					www.UnitedBusinessTechnologies.com
//			  Copyright (c) 1998 - 2002  All Rights Reserved.
//
// Source in this file is released to the public under the following license:
// --------------------------------------------------------------------------
// This toolkit may be used free of charge for any purpose including corporate
// and academic use.  For profit, and Non-Profit uses are permitted.
//
// This source code and any work derived from this source code must retain 
// this copyright at the top of each source file.
// 
// UBT welcomes any suggestions, improvements or new platform ports.
// email to: XMLFoundation@UnitedBusinessTechnologies.com
// --------------------------------------------------------------------------
#ifndef XML_LIST_ABSTRACTION
#define XML_LIST_ABSTRACTION

typedef void * xmlObjectIterator;
typedef void * xmlObjectList;
typedef void * userStringList;
typedef void * userStringListIterator;
typedef void * userArray;
typedef void * userHashIterator;
typedef void * KeyedDataStructure;

#include "GString.h"

class XMLObject;
class ListAbstraction	// abstract object container interface
{
public:
	// remove the last object issued by getFirst() or getNext()
	virtual void removeObject(xmlObjectList pList, xmlObjectIterator Iterator) = 0;
	virtual int itemCount(xmlObjectList pList) = 0;
	virtual void append(xmlObjectList pList, XMLObject *pObject) = 0;
	virtual XMLObject *getLast(xmlObjectList pList) = 0;
	virtual XMLObject *getFirst(xmlObjectList pList, xmlObjectIterator *pIterator) = 0;
	virtual XMLObject *getNext(xmlObjectList pList, xmlObjectIterator Iterator) = 0;
	virtual void releaseIterator(xmlObjectIterator Iterator) = 0;
};

///////////////////////////////////////////////////////////////////////////////////////////
// hashes, binary-trees, etc...
///////////////////////////////////////////////////////////////////////////////////////////
// Unlike all the other *Abstraction* base classes, this one contains state (members).
// Therefore it becomes necessary to create one instance of this deravitive for each
// KeyedDataStructure that is used.  You cannot use a global instance for all handlers
// as is typical for all other *Abstraction* base classes.
///////////////////////////////////////////////////////////////////////////////////////////
// For example, 
// class foo
// {
//	GHashAbstraction m_htblUsersAbs;
//	hashTbl m_htblUsers;
//	GHashAbstraction m_htblOtherAbs;
//	hashTbl m_htblOther;
//	....
//
//	virtual void MapXMLTagsToMembers()
//	{
//		MapMember(&m_htblUsers,	&m_htblUsersAbs,
//				  CUser::GetStaticTag(), 
//				  "User");
//		MapMember(&m_htblOther,	&m_htblOtherAbs,
//				  COther::GetStaticTag(), 
//				  "Other");
//
///////////////////////////////////////////////////////////////////////////////////////////
class KeyedDataStructureAbstraction
{
//	GString m_strKeyName;
//	int m_bKeyIsMember;
//	KeyedDataStructure m_kds;
public:
	// 1 = attribute, 0 = element
//	void SetKeySource(int n){m_bKeyIsMember = n;}
//	void SetKeyName(const char *p){m_strKeyName = p;};
	virtual void AddObjectToStructure(KeyedDataStructure kds, XMLObject *pObj, const char *pzKey) = 0;
	virtual XMLObject *getFirst(KeyedDataStructure kds, userHashIterator *pIterator) = 0;
	virtual XMLObject *getNext(KeyedDataStructure kds, userHashIterator Iterator) = 0;
	virtual int itemCount(KeyedDataStructure kds) = 0;
	virtual void releaseIterator(xmlObjectIterator Iterator) = 0;
public:

	// called by the object factory when the object is first created.
	void InsertObject(KeyedDataStructure kds, XMLObject *p);
	// called by the object when the factory is done populating it.
//	virtual void InitCallback(XMLObject *);
};



class StringCollectionAbstraction	// abstract string container interface
{
public:
	// append a new string to your string collection implementation
	virtual void append(userStringList pList, const char *pString) = 0;
	virtual const char *getFirst(userStringList pList, userStringListIterator *pIterator) = 0;
	virtual const char *getNext(userStringList pList, userStringListIterator Iterator) = 0;
	virtual int itemCount(userStringList pList) = 0;
};

class IntegerArrayAbstraction	// abstract dynamic allocation integer array interface
{
public:
	// append a new integer to your dynamic array implementation
	virtual void append(userArray pArray, int nValue) = 0;
	virtual unsigned int getAt(userArray pArray, unsigned int nIndex, int *bIsValidIndex) = 0;
	virtual unsigned int itemCount(userArray pList) = 0;
};


#endif //XML_LIST_ABSTRACTION

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
Founder United Business Technologies
United States United States
http://about.me/brian.aberle
https://www.linkedin.com/in/brianaberle
http://SyrianRue.org/Brian

Comments and Discussions