CCArchive Class Reference

Archive class used to save and load the Camelot tree. More...

#include <archive.h>

List of all members.

Protected Member Functions

 CCArchive (const CCArchive &Src)
 Copy Constuctor. Since the coping of Archives is not permitted, this just fails with an ERROR3.
void operator= (const CCArchive &Src)
 Stops Archives from being copied as this is not permitted. Always fails with an Error3. DO NOT CALL THIS FUNCTION.

Protected Attributes

CCLexFilepFile
BOOL IsLoadArchive
BOOL IsArchiveOK

Private Types

enum  { Load = 1, Save = 2 }

Private Member Functions

 CC_DECLARE_MEMDUMP (CCArchive)
 CCArchive (CCLexFile *pNewFile, UINT32 Mode)
 Constructs a new CCArchive object. The Archive class assumes the following things about the size of objects.
 ~CCArchive ()
 Destructor.
void Close ()
 Flushes and closes the CCArchive. After this has been done, you can not write any more data to it.
CCArchiveoperator>> (INT32 &)
CCArchiveoperator>> (BYTE &)
 Loads a primitive item out of the archive into the variable. This function will throw an ArchiveExeption if there is an error.
CCArchiveoperator>> (WORD &)
CCArchiveoperator>> (INT32 &)
CCArchiveoperator>> (DWORD &)
CCArchiveoperator>> (float &)
CCArchiveoperator>> (double &)
CCArchiveoperator<< (INT32)
CCArchiveoperator<< (BYTE)
 saves a primitive item out of the archive from the variable. This function will throw an ArchiveExeption if there is an error
CCArchiveoperator<< (WORD)
CCArchiveoperator<< (INT32)
CCArchiveoperator<< (DWORD)
CCArchiveoperator<< (float)
CCArchiveoperator<< (double)
BOOL IsReady ()
 Tests to see if the Archive is ready to save or load data items. This tests that all the files are OK and everything is set up as it should be. You should call this function before starting to use the Loading and Saving operators of this class, though it does only need to be called once at the begining. Individual objects should NOT need to call this function before saving/loading their components as it should have been done before all the Serialise functions are called.
BOOL IsLoading () const
 Determines if this Archive is a loading or saving archive and responds appropriatly.
BOOL IsSaving () const
 Determines if this Archive is a loading or saving archive and responds appropriatly.


Detailed Description

Archive class used to save and load the Camelot tree.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94

Definition at line 116 of file archive.h.


Member Enumeration Documentation

anonymous enum [private]
 

Enumerator:
Load 
Save 

Definition at line 122 of file archive.h.

00122 { Load=1, Save=2 };


Constructor & Destructor Documentation

CCArchive::CCArchive CCLexFile pNewFile,
UINT32  Mode
[private]
 

Constructs a new CCArchive object. The Archive class assumes the following things about the size of objects.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Parameters:
pNewFile - A CCDiskFile that is ready to be saved into or loaded out of [INPUTS] Mode - The mode of the Archive. Can be one of CCArchive::Load or CCArchive::Save.

Definition at line 131 of file archive.cpp.

00132   : pFile(pNewFile),
00133     IsLoadArchive(FALSE),
00134     IsArchiveOK(TRUE)
00135 {
00136     // Find out what sort of Archive we are going to be
00137     if (Mode & CCArchive::Load)
00138     {
00139         // We are loading
00140         IsLoadArchive = TRUE;
00141     }
00142     else if (Mode & CCArchive::Save)
00143     {
00144         // We are saving
00145         IsLoadArchive = FALSE;
00146     }
00147     else
00148     {
00149         // Something is wrong. Mode should be Save or Load
00150         IsArchiveOK = FALSE;
00151     }
00152 }

CCArchive::~CCArchive  )  [private]
 

Destructor.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94

Definition at line 165 of file archive.cpp.

00166 {
00167     // Empty.
00168 }

CCArchive::CCArchive const CCArchive Src  )  [protected]
 

Copy Constuctor. Since the coping of Archives is not permitted, this just fails with an ERROR3.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Parameters:
Src - Reference to an Archive [INPUTS]
Returns:
Errors: Always fails with an ERROR3. You should never call this function

Definition at line 504 of file archive.cpp.

00505 {
00506     ERROR3("CCArchive classes can not be copied\n");
00507 }


Member Function Documentation

CCArchive::CC_DECLARE_MEMDUMP CCArchive   )  [private]
 

void CCArchive::Close  )  [private]
 

Flushes and closes the CCArchive. After this has been done, you can not write any more data to it.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94

Definition at line 183 of file archive.cpp.

00184 {
00185     // Close the file associated with the Archive. This should flush the file as well...
00186     pFile->close();
00187 }

BOOL CCArchive::IsLoading  )  const [private]
 

Determines if this Archive is a loading or saving archive and responds appropriatly.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Returns:
TRUE if this archive is Loading data.

Definition at line 465 of file archive.cpp.

00466 {
00467     return IsLoadArchive;
00468 }

BOOL CCArchive::IsReady  )  [private]
 

Tests to see if the Archive is ready to save or load data items. This tests that all the files are OK and everything is set up as it should be. You should call this function before starting to use the Loading and Saving operators of this class, though it does only need to be called once at the begining. Individual objects should NOT need to call this function before saving/loading their components as it should have been done before all the Serialise functions are called.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Returns:
TRUE if the Archive is Ready, FALSE if not

Definition at line 437 of file archive.cpp.

00438 {
00439     // Make sure that we have a pointer to a file
00440     if (pFile==NULL)
00441         return FALSE;
00442 
00443     // make sure that it is open
00444     if (!pFile->isOpen())
00445         return FALSE;
00446 
00447     // all seemed to be ok.
00448     return TRUE;
00449 }

BOOL CCArchive::IsSaving  )  const [private]
 

Determines if this Archive is a loading or saving archive and responds appropriatly.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Returns:
TRUE if this archive is Saving data.

Definition at line 483 of file archive.cpp.

00484 {
00485     return !IsLoadArchive;
00486 }

CCArchive & CCArchive::operator<< double   )  [private]
 

Definition at line 404 of file archive.cpp.

00405 {
00406     ERROR3IF(sizeof(double)!=8, "double is no longer 8 bytes!\n");
00407 
00408     // Get the double into Intel form
00409     double SaveMe;
00410     DOUBLE_TO_INTEL(Var, SaveMe);
00411 
00412     // Save out the Fixed up word
00413     pFile->write(&SaveMe, sizeof(double));
00414     return *this;
00415 }

CCArchive & CCArchive::operator<< float   )  [private]
 

Definition at line 390 of file archive.cpp.

00391 {
00392     ERROR3IF(sizeof(float)!=4, "float is no longer 4 bytes!\n");
00393 
00394     // Get the float into Intel form
00395     float SaveMe;
00396     FLOAT_TO_INTEL(Var, SaveMe);
00397 
00398     // Save out the Fixed up word
00399     pFile->write(&SaveMe, sizeof(float));
00400     return *this;
00401 }

CCArchive & CCArchive::operator<< DWORD   )  [private]
 

Definition at line 376 of file archive.cpp.

00377 {
00378     ERROR3IF(sizeof(DWORD)!=4, "DWORD is no longer 4 bytes!\n");
00379 
00380     // Get the DWORD into Intel form
00381     DWORD SaveMe;
00382     DWORD_TO_INTEL(Var, SaveMe);
00383 
00384     // Save out the Fixed up word
00385     pFile->write(&SaveMe, sizeof(DWORD));
00386     return *this;
00387 }

CCArchive& CCArchive::operator<< INT32   )  [private]
 

CCArchive & CCArchive::operator<< WORD   )  [private]
 

Definition at line 347 of file archive.cpp.

00348 {
00349     ERROR3IF(sizeof(WORD)!=2, "WORD is no longer 2 bytes!\n");
00350 
00351     // Get the Word into Intel form
00352     WORD SaveMe;
00353     WORD_TO_INTEL(Var, SaveMe);
00354 
00355     // Save out the Fixed up word
00356     pFile->write(&SaveMe, sizeof(WORD));
00357     return *this;
00358 }

CCArchive & CCArchive::operator<< BYTE  Var  )  [private]
 

saves a primitive item out of the archive from the variable. This function will throw an ArchiveExeption if there is an error

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Parameters:
Various - The item to be Saved to the archive [INPUTS]
Returns:
A reference to a CCArchive to allow chaining of saving commands
See also:
CCArchive::operator>>

Definition at line 324 of file archive.cpp.

00325 {
00326     pFile->write(&Var, sizeof(BYTE));
00327     return *this;
00328 }

CCArchive & CCArchive::operator<< INT32   )  [private]
 

Definition at line 332 of file archive.cpp.

00333 {
00334     ERROR3IF(sizeof(INT32)!=4, "INT32 is no longer 4 bytes!\n");
00335 
00336     // Get the Word into Intel form
00337     INT32 SaveMe;
00338     INT_TO_INTEL(Var, SaveMe);
00339 
00340     // Save out the Fixed up word
00341     pFile->write(&SaveMe, sizeof(INT32));
00342     return *this;
00343 }

void CCArchive::operator= const CCArchive Src  )  [protected]
 

Stops Archives from being copied as this is not permitted. Always fails with an Error3. DO NOT CALL THIS FUNCTION.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Parameters:
Src - An Archive [INPUTS]
Returns:
Errors: Always fails with an ERROR3. You are not allowed to copy Archives

Definition at line 524 of file archive.cpp.

00525 {
00526     ERROR3("CCArchive classes can not be assigned to each other\n");
00527 }

CCArchive & CCArchive::operator>> double &   )  [private]
 

Definition at line 290 of file archive.cpp.

00291 {
00292     ERROR3IF(sizeof(double)!=8, "double is no longer 8 bytes!\n");
00293 
00294     // Get a float out the Archive
00295     double LoadMe;
00296     pFile->read(&LoadMe, sizeof(double));
00297 
00298     // Fix the float up from Intel format
00299     DOUBLE_FROM_INTEL(LoadMe, Var);
00300     return *this;
00301 }

CCArchive & CCArchive::operator>> float &   )  [private]
 

Definition at line 276 of file archive.cpp.

00277 {
00278     ERROR3IF(sizeof(float)!=4, "float is no longer 4 bytes!\n");
00279 
00280     // Get a float out the Archive
00281     float LoadMe;
00282     pFile->read(&LoadMe, sizeof(float));
00283 
00284     // Fix the float up from Intel format
00285     FLOAT_FROM_INTEL(LoadMe, Var);
00286     return *this;
00287 }

CCArchive & CCArchive::operator>> DWORD  )  [private]
 

Definition at line 262 of file archive.cpp.

00263 {
00264     ERROR3IF(sizeof(DWORD)!=4, "DWORD is no longer 4 bytes!\n");
00265 
00266     // Get a DWORD out the Archive
00267     DWORD LoadMe;
00268     pFile->read(&LoadMe, sizeof(DWORD));
00269 
00270     // Fix the DWORD up from Intel format
00271     DWORD_FROM_INTEL(LoadMe, Var);
00272     return *this;
00273 }

CCArchive& CCArchive::operator>> INT32 &   )  [private]
 

CCArchive & CCArchive::operator>> WORD  )  [private]
 

Definition at line 234 of file archive.cpp.

00235 {
00236     ERROR3IF(sizeof(WORD)!=2, "WORD is no longer 2 bytes!\n");
00237 
00238     // Get a Word out the Archive
00239     WORD LoadMe;
00240     pFile->read(&LoadMe, sizeof(WORD));
00241 
00242     // Fix the word up from Intel format
00243     WORD_FROM_INTEL(LoadMe, Var);
00244     return *this;
00245 }

CCArchive & CCArchive::operator>> BYTE &  Var  )  [private]
 

Loads a primitive item out of the archive into the variable. This function will throw an ArchiveExeption if there is an error.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/12/94
Parameters:
Various - The item to be loaded from the archive [INPUTS]
Various - The data from the file will be in the variable supplied [OUTPUTS]
Returns:
A reference to a CCArchive to allow chaining of loading commands
See also:
CCArchive::operator<<

Definition at line 212 of file archive.cpp.

00213 {
00214     // Read an INT32 out of the file
00215     pFile->read(&Var, sizeof(BYTE));
00216     return *this;
00217 }

CCArchive & CCArchive::operator>> INT32 &   )  [private]
 

Definition at line 220 of file archive.cpp.

00221 {
00222     ERROR3IF(sizeof(INT32)!=4, "INT32 is no longer 4 bytes!\n");
00223 
00224     // Get a Word out the Archive
00225     INT32 LoadMe;
00226     pFile->read(&LoadMe, sizeof(INT32));
00227 
00228     // Fix the word up from Intel format
00229     INT_FROM_INTEL(LoadMe, Var);
00230     return *this;
00231 }


Member Data Documentation

BOOL CCArchive::IsArchiveOK [protected]
 

Definition at line 163 of file archive.h.

BOOL CCArchive::IsLoadArchive [protected]
 

Definition at line 162 of file archive.h.

CCLexFile* CCArchive::pFile [protected]
 

Definition at line 159 of file archive.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:02 2007 for Camelot by  doxygen 1.4.4