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

STL WebServer

, 8 May 2000
A set of classes written in STL that implement a web server
#if !defined(TransferStatus_H)
#define TransferStatus_H



/////////////////////////////////////////////////////////////////////////////////////
// TransferStatus
//
// Purpose:	used to keep track of a transfer

class TransferStatus
{
	long			_blockSize;		// no to send at one time
	long			_noToSend;		// number of bytes left to send 
	long			_noSent;		// number of bytes sent in response

public:

	TransferStatus () :
		_blockSize(0),
		_noToSend(0),
		_noSent(0)
	{}

	// setup status
	void reset ()
	{
		_noToSend = 0;
		_noSent = 0;
	}

	void begin ( long noToSend )
	{
		_blockSize = noToSend;
		_noToSend = noToSend;
		_noSent = 0;
	}

	void setSizeToSend ( long noToSend )
	{
		begin(noToSend);
	}

	// get/set block size
	long getBlockSize ()
	{
		return _blockSize;
	}

	void setBlockSize ( long set )
	{
		_blockSize = set;
	}

	// status methods
	long size()
	{
		return _noToSend;
	}

	long getNoToSend ()
	{
		return _noToSend;
	}

	long getNoSent ()
	{
		return _noSent;
	}

	void incNoSent ( long inc )
	{
		// if not valid stop
		if ( inc <= 0 )
			return;

		// update no sent
		_noSent += inc;
		if ( _noSent > size() )
			_noSent = size();
	}

	void decNoToSend ( long dec )
	{
		// if not valid stop
		if ( dec <= 0 )
			return;

		// update no to send
		_noToSend -= dec;
		if ( _noToSend < 0 )
			_noToSend = 0;
	}

	bool finished ()
	{
		// if all sent show it
		if ( _noSent == _noToSend )
			return true;
		else
			return false;
	}




};

#endif

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

David Hubbard

United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 9 May 2000
Article Copyright 2000 by David Hubbard
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid