[ create a new paste ] login | about

Project: chehob
Link: http://chehob.codepad.org/BpBTDZip    [ raw code | fork ]

chehob - C++, pasted on Aug 7:
#ifndef LUMP_H
#define LUMP_H

// Structure of each element in the lump info list.
// Holds information which can be used to retrieve the contents of a lump.
struct LumpInfo
{
  unsigned long Size;                     // Size of the lump, in bytes
  unsigned long Position;                 // Position in the file of the lump
  std::string Name;			  // Name of the lump
};

// Class representing single resource stored in a resource file.
// Stores lump information and lump contents
class Lump
{
protected:
  LumpInfo  mLumpInfo;    // Our lump information
  void*	    mData;        // Lump's contents

public:
  Lump() : mData() {}

  ~Lump()
  {
    if (mData != NULL) UnloadData();
  }

  bool LoadData (std::fstream&);    // Read data from file
  bool SaveData (std::fstream&);    // Write data to file
  void UnloadData();                // Clear data

  void LoadInfo (std::fstream&);    // Read information from file
  void SaveInfo (std::fstream&);    // Write information to file

  LumpInfo& GetInfo()		    { return mLumpInfo; }
  void*	    GetData()		    { return mData; }

  void SetInfo (const LumpInfo& li) { mLumpInfo = li; }
  void SetData (void* Data)	    { mData = Data; }
};

#endif	// LUMP_H


Create a new paste based on this one


Comments: