Click here to Skip to main content
11,583,859 members (46,562 online)
Click here to Skip to main content
Add your own
alternative version

STL WebServer

, 8 May 2000 73.6K 2.2K 47
A set of classes written in STL that implement a web server
#if !defined(TransactionFile_H)
#define TransactionFile_H



#include <string>
using namespace std;


#include "Lock.h"
#include "SysEvent.h"

////////////////////////////////////////////////////////////////////////////////
// TransactionFile
//
// Purpose: text file class

class TransactionFile :
	public Lock,
	public SysEvent
{
	long	m_readOffset;			// current read offset
	long	m_writeOffset;			// current write offset
	DWORD	m_readWait;				// time (ms) to wait after read
	DWORD	m_writeWait;			// time (ms) to wait after write
	DWORD	m_openFlags;			// flags used to open file
	string	m_name;					// name of file

public:
	HANDLE	m_hFile;


	TransactionFile ();
	~TransactionFile (); 

	// show error
	void	showLastError	();
	bool	invalidFile		();

	// open methods
	bool	create			( string & fileName );
	bool	open			( string & fileName );
	bool	openAlways		( string & fileName );
	bool	open			( string & fileName, DWORD openFlags );
	void	close			();

	// file info/position methods
	bool	setPosition		( DWORD position, bool read = true );
	long	size			();
	bool	offsetPosition	( DWORD offset, bool read = true  );

	// clear the file
	void	clear			();

	// read/write methods
	bool	write			( LPTSTR pBuffer, DWORD noToWrite, bool wait = true );
	bool	read			( LPTSTR pBuffer, DWORD noToRead, bool wait = true );

	void    operator <<		( string & buffer )
	{
		write( (LPTSTR) buffer.c_str(), buffer.size() );
	}

	operator HANDLE () 
	{ 
		return m_hFile; 
	}

	void setReadWait ( DWORD wait )
	{ m_readWait = wait; }

	void setWriteWait ( DWORD wait )
	{ m_writeWait = wait; }

};


void operator << ( stringstream & strm, TransactionFile & file );
void operator << ( TransactionFile & file, stringstream & strm );


#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

You may also be interested in...

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