The Sims™ Technical Library

Include file far.h

#ifndef __SIMS_far_h
#define __SIMS_far_h

#include <iosfwd>

class simFAR
{
public:
	class Entry {
		friend class simFAR;
		simFAR *m_parent; // the FAR of which this is a member
		int m_length;	// length of entry
		int m_offset;	// offset within FAR
		int m_namLen;	// length of name string
		char *m_name;	// we null-terminate it
		// can only be created and destroyed by
		// our friends, such as they are...
		Entry(void); ~Entry(void);
	public:
		int length(void) const	{ return m_length; }
		int offset(void) const	{ return m_offset; }
		int nameLen(void) const	{ return m_namLen; }
		const char *name(void)const{ return m_name; }
		// seekable istream to contents, must delete when done
		std::istream *stream(void) const;
	};
	friend class Entry;
private:
	std::istream *m_stream;	// stream to access file
	int m_version;		// version must be one
	unsigned int m_entries;	// number of manifest entries
	Entry *m_list;		// manifest entries
	simFAR(const simFAR&); void operator=(const simFAR&);
	void init(void);
public:
	simFAR(const char *file); // access via named file
	// access via seekable input stream, deletes it when done
	simFAR(std::istream *stream) : m_stream(stream) { init(); }
	~simFAR(void);
	int err(void) const		{ return m_list == 0; }
	char *signature(void) const	{ return "FAR!byAZ"; }
	int version(void) const		{ return m_version; }
	int entries(void) const		{ return m_entries; }
	Entry &operator[](unsigned int ix) const { return m_list[ix]; }
};

#endif // __SIMS_far_h

Valid XHTML 1.1! Valid CSS!
Copyright © 2001-2008 Dave Baum and Greg Noel. All rights reserved.
The Sims™ is a trademark of Maxis and Electronic Arts.
This page was last modified Saturday, 27-Dec-2003 18:10:23 UTC.
Made on a Mac
SourceForge