Click here to Skip to main content
15,892,298 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.8K   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 __GSTRINGSTACK_H___
#define __GSTRINGSTACK_H___

#include "GList.h"
#include "GStack.h"
#include "GString.h"

class GStringStack
{
	GStack m_stk;
	GList  m_lst;

public:

	// Construct an empty stack
	GStringStack(unsigned long growBy) :
	  m_stk(growBy)
	{
	};
	
	// Destroy the stack
	~GStringStack() 
	{
		GListIterator it(&m_lst);
		while (it())
			delete (GString *)it++;
	};
	
	// Returns the number of entries in the stack
	inline int Size(void) const { return m_stk.Size(); } 
	
	// Returns TRUE if the stack is empty, otherwise FALSE
	inline bool isEmpty(void) const { return m_stk.isEmpty(); } 
	
	// Removes and returns the item at the top of the stack, or returns NULL if the stack is empty
	inline GString & Pop(void)
	{
		return *(GString *)m_stk.Pop();
	}
 
	inline void Push(const char *p)
	{
		GString *strNew = new GString(p);
		m_stk.Push(strNew);
		m_lst.AddLast(strNew);
	}

	inline void Push(GString &p)
	{
		Push((const char *)p);
	}

	// Adds an iten to the top of the stack
	inline void Push(GString *p)
	{
		Push(*p);
	} 
	
	// Returns the item at the top of the stack, or returns NULL if the stack is empty
	inline GString &Top(void)
	{ 
		return *(GString *)m_stk.Top();
	} 

	inline GString &Bottom(void)
	{
		return *(GString *)m_stk.Bottom();
	}
};

#endif // __GSTRINGSTACK_H___

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