CCMemFile Class Reference

Represents a memory IO file - IO is in byte units. More...

#include <ccfile.h>

Inheritance diagram for CCMemFile:

CCLexFile CCFile CCObject SimpleCCObject CCClipBoardFile CCMemTextFile CCResourceFile CCResTextFile List of all members.

Public Member Functions

 CCMemFile (BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE)
 Given an instance of a CCDiskFile, you can ask for the actual file handle that describes the associated file. Required for the external filters. Constructs an instance of CCMemFile.
 CCMemFile (void *pFile, UINT32 size, FileAccess fProt=CCMemRead, BOOL ErrorReporting=TRUE, BOOL ExceptionThrowing=FALSE)
 Constructs an instance of CCMemFile and Opens it.
 ~CCMemFile ()
 Default destructor.
BOOL IsMemFileInited ()
 Allows errors to be returned from the constructor.
BOOL GetBuffer (BYTE **ppBuffer, UINT32 *pSize)
BOOL open (void *pFile, UINT32 size, FileAccess fProt=CCMemRead)
 Opens an instance of a CCmemFile.
virtual BOOL setMode (INT32 fileMode=0)
 None- cannot change the mode on a memory file - either it's binary in which case it's a CCMemFile, or it's text, in which case it's a CCMemTextFile.
virtual BOOL isOpen () const
 Determines whether an instance of CCMemFile is open.
virtual CCFileseekIn (FilePos)
 Alter position of the file input pointer. NB. input and output pointers are linked with CCMemFiles, so you will alter the output pointer too.
virtual CCFileseekIn (INT32 Offset, ios::seekdir Dir)
 Alter position of the file input pointer. NB. input and output pointers are linked with CCMemFiles, so you will alter the output pointer too.
virtual FilePos tellIn ()
 Return the position of the file input pointer.
virtual CCFileseek (FilePos pos)
 Sets the file pointer to the file position passed in. (Position zero is the beginning of the file).
virtual FilePos tell ()
 Gets the file pointer position of the file.
virtual CCFileread (void *buf, UINT32 length=1)
 Reads a single byte from the Memory file.
virtual CCFileread (StringBase *buf)
virtual CCFileread (char &buf)
virtual CCFilewrite (const void *buf, UINT32 length=1)
 Writes a stream of bytes to the Memory file.
virtual CCFilewrite (const StringBase &buf, UINT32 length=0)
virtual CCFilewrite (char &buf)
virtual size_t Size ()
 Find the size of the file.
virtual BOOL good () const
 Simple base implentation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
virtual BOOL bad () const
 Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
virtual BOOL fail () const
 Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).
virtual BOOL eof () const
 Determines whether an instance of CCMemFile is open.
virtual void SetBadState ()
 It allows the forceable setting of the test that functions like bad() use so the next check of the current file status to see if we should continue using the file or not will fail. This will be called by the GotError function so that any attempts to read/write after this should fail.
virtual void SetGoodState ()
 It allows the forceable setting of the test that functions like bad() use so the next check of the current file status to see if we should continue using the file or not will pass.
virtual iostream * GetIOFile ()
virtual BOOL GetName (StringBase *name) const
 Given a CCMemFile*, you can ask for some sort of name which is associated with that file. For filenames it might be a filename, or a pathname, for resource files it might be "Default Bitmap" etc. These names could then be used for making error messages have some extra useful information in.
virtual filedesc GetFileHandle () const
 Given an instance of a CCMemFile, you can ask for the actual file handle that describes the associated file. Required for the external filters.
virtual void close ()
 Closes an instance of a CCMemFile.
virtual BOOL InitCompression (BOOL Header=FALSE)
 To initialise the compression system ready for use. This is to make sure there is enough memory available for its buffers before writing out any compression tokens into the output file. MemFiles not supported at present so always returns FALSE. Graeme (15/11/99): Added the Header parameter.
virtual BOOL StartCompression ()
 To start up the compression system. MemFiles not supported at present so always returns FALSE.
virtual BOOL StopCompression ()
 To stop the compression system. MemFiles not supported at present so always returns FALSE.

Protected Member Functions

BOOL GrowMemFile ()
 Will increase the size of the memory file by allocating more space in blocks 1k. This function is called by all the write functions when the file size limit is reached. Scope: Private.

Protected Attributes

MHANDLE MemHandle
BYTE * MemFile
size_t FileSize
UINT32 CurrentPos
BOOL IsOpen
UINT32 FileProt
BOOL WasError
BOOL MemFileInitialised

Private Member Functions

 CC_DECLARE_DYNAMIC (CCMemFile)

Detailed Description

Represents a memory IO file - IO is in byte units.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/1993
Returns:
Errors: None.

Definition at line 838 of file ccfile.h.


Constructor & Destructor Documentation

CCMemFile::CCMemFile BOOL  ErrorReporting = TRUE,
BOOL  ExceptionThrowing = FALSE
 

Given an instance of a CCDiskFile, you can ask for the actual file handle that describes the associated file. Required for the external filters. Constructs an instance of CCMemFile.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Parameters:
ReportErrors flag [INPUTS] ThrowExceptions flag
Date:
1/9/94

Definition at line 4794 of file ccfile.cpp.

04795 {
04796     // Set our class variables from the passed in values
04797     ReportErrors = ErrorReporting;
04798     ThrowExceptions = ExceptionThrowing;
04799     WasError = FALSE;
04800     MemFileInitialised = TRUE;
04801 
04802     // Better set these up too or an unused object crashes on destuction
04803     MemHandle = BAD_MHANDLE;
04804     MemFile = NULL;
04805     FileSize = 0;
04806     CurrentPos = 0;
04807     IsOpen = FALSE;
04808     FileProt = CCMemRead;
04809 }

CCMemFile::CCMemFile void *  pFile,
UINT32  size,
FileAccess  fProt = CCMemRead,
BOOL  ErrorReporting = TRUE,
BOOL  ExceptionThrowing = FALSE
 

Constructs an instance of CCMemFile and Opens it.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Parameters:
pFile - a pointer to the file [INPUTS] UINT32 - the size of the file FileAccess - read or write access ReportErrors flag ThrowExceptions flag
Date:
6/9/93

Definition at line 4828 of file ccfile.cpp.

04830 {
04831     // First, set up our initialised flag to False
04832     MemFileInitialised = FALSE;
04833     WasError = FALSE;
04834 
04835     // Set our class variables from the passed in values
04836     ReportErrors = ErrorReporting;
04837     ThrowExceptions = ExceptionThrowing;
04838 
04839     FileProt = fProt;
04840 
04841     IsOpen = FALSE;
04842 
04843     // If file is opened for reading
04844     if (FileProt == CCMemRead) 
04845     {
04846         // Is file pointer NULL?
04847         if (pFile == NULL)
04848         {
04849             // Yes; report error.
04850             IsOpen = FALSE;
04851             GotError(_R(IDE_NULL_FILE));
04852             return;
04853         }             
04854         
04855         MemHandle   = BAD_MHANDLE;
04856         MemFile     = (BYTE*) pFile;            // Set Memory file pointer
04857         CurrentPos  = 0;                        // Set Current file position        
04858         
04859         // Check that file size is greater than zero
04860         if (size > 0)
04861         {
04862             FileSize    = size;
04863             // Flag that everything has gone ok
04864             MemFileInitialised = TRUE;
04865         }
04866         else
04867         {
04868             IsOpen  = FALSE;
04869             GotError(_R(IDE_FILE_SIZE_ZERO));
04870             return;
04871         }
04872  
04873         IsOpen = TRUE;
04874     }
04875 
04876     // if file is open for writing  
04877     else if (FileProt == CCMemWrite)
04878     {                             
04879         // check file size 
04880         if (size > 0)
04881             FileSize = size;                    // if not zero use size passed in
04882         else
04883             FileSize = CCFILE_DEFAULTSIZE;              // else used default size
04884             
04885         //Allocate Memory 
04886         MemHandle = ClaimBlock(FileSize);
04887         
04888         // Check allocation worked ok
04889         if (MemHandle != BAD_MHANDLE)
04890         {
04891             IsOpen      = TRUE;
04892             CurrentPos  = 0;
04893             // Flag that everything has gone ok
04894             MemFileInitialised = TRUE;
04895         }
04896         else
04897         {
04898             IsOpen  = FALSE;
04899             GotError(_R(IDE_MEM_BLOCK_FAILURE));
04900             return;
04901         } 
04902     }
04903 }

CCMemFile::~CCMemFile  ) 
 

Default destructor.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93

Definition at line 4915 of file ccfile.cpp.

04916 {                   
04917     if(isOpen())
04918     {
04919         // report error that file is not closed before destructor call
04920         GotError(_R(IDE_MEM_CLOSE_ERROR));
04921 
04922         // Release any memory block we might have
04923         if (MemHandle != BAD_MHANDLE)
04924         {
04925             ReleaseBlock(MemHandle);
04926             MemHandle = BAD_MHANDLE;
04927         }
04928     }
04929 }


Member Function Documentation

BOOL CCMemFile::bad  )  const [virtual]
 

Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
TRUE => An error has occured. FALSE => The file stream is ok.

Reimplemented from CCFile.

Definition at line 5477 of file ccfile.cpp.

05478 {
05479     return WasError;
05480 }

CCMemFile::CC_DECLARE_DYNAMIC CCMemFile   )  [private]
 

void CCMemFile::close  )  [virtual]
 

Closes an instance of a CCMemFile.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93

Implements CCFile.

Reimplemented in CCResTextFile, and CCClipBoardFile.

Definition at line 5580 of file ccfile.cpp.

05581 {
05582     IsOpen = FALSE;
05583 
05584     // Release any memory block we might have
05585     if (MemHandle != BAD_MHANDLE)
05586     {
05587         ReleaseBlock(MemHandle);
05588         MemHandle = BAD_MHANDLE;
05589     }
05590 }

BOOL CCMemFile::eof  )  const [virtual]
 

Determines whether an instance of CCMemFile is open.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (fixed by Andy)
Date:
6/9/93 Return: TRUE if end of file and FALSE otherwize

Implements CCFile.

Reimplemented in CCMemTextFile, CCResTextFile, and CCClipBoardFile.

Definition at line 5467 of file ccfile.cpp.

05468 {
05469     return (CurrentPos >= FileSize);
05470 }

BOOL CCMemFile::fail  )  const [virtual]
 

Simple base implementation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
TRUE => An error has occured. FALSE => The file stream is ok.

Reimplemented from CCFile.

Definition at line 5482 of file ccfile.cpp.

05483 {
05484     return WasError;
05485 }

BOOL CCMemFile::GetBuffer BYTE **  ppBuffer,
UINT32 pSize
 

Definition at line 4950 of file ccfile.cpp.

04951 {
04952     if (!MemFileInitialised)
04953         return(FALSE);
04954 
04955     BYTE* tempBuf = NULL;
04956     size_t tempSize = 0;
04957     
04958     // Get Pointer to the memory file
04959     if (!DescribeBlock(MemHandle, &tempBuf, &tempSize))
04960     {
04961         GotError(_R(IDE_MEM_BLOCK_FAILURE));
04962         return FALSE;
04963     } 
04964 
04965     *ppBuffer = tempBuf;
04966     *pSize = (UINT32)tempSize;
04967 
04968     return(TRUE);
04969 }

filedesc CCMemFile::GetFileHandle  )  const [virtual]
 

Given an instance of a CCMemFile, you can ask for the actual file handle that describes the associated file. Required for the external filters.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/09/94
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
The file handle (descriptor) for this file (really an INT32).

Errors: Not appropriate for memory files hence error at present

See also:
CCDiskFile::GetFileHandle(); CCFile::GetFileHandle()

Implements CCFile.

Definition at line 5564 of file ccfile.cpp.

05565 {
05566     ERROR3("CCMemFile::GetFileHandle() called");
05567     return -1;
05568 }

virtual iostream* CCMemFile::GetIOFile  )  [inline, virtual]
 

Implements CCFile.

Definition at line 913 of file ccfile.h.

00913 { return NULL; }

BOOL CCMemFile::GetName StringBase name  )  const [virtual]
 

Given a CCMemFile*, you can ask for some sort of name which is associated with that file. For filenames it might be a filename, or a pathname, for resource files it might be "Default Bitmap" etc. These names could then be used for making error messages have some extra useful information in.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/09/94
Parameters:
Pointer to a CCMemFile name [INPUTS]
None [OUTPUTS]
Returns:
True if a name has been set otherwise False. At present always returns False.

Errors: None

Reimplemented from CCFile.

Definition at line 5543 of file ccfile.cpp.

05544 {
05545     return FALSE;
05546 }

BOOL CCMemFile::good  )  const [virtual]
 

Simple base implentation of this function - just examines EOF status. It allows checking of the current file status to see if we should continue using the file or not. Override this function to provide more sophisticated error checking (the CCDiskFile class overrides this function).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
TRUE => file stream is ok. FALSE => an error has occured.

Reimplemented from CCFile.

Definition at line 5472 of file ccfile.cpp.

05473 {
05474     return !WasError;
05475 }

BOOL CCMemFile::GrowMemFile  )  [protected]
 

Will increase the size of the memory file by allocating more space in blocks 1k. This function is called by all the write functions when the file size limit is reached. Scope: Private.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/93 Return: TRUE if size can be increased otherwize FALSE

Definition at line 5068 of file ccfile.cpp.

05069 {
05070     if (IncreaseBlock(MemHandle, CCFILE_DEFAULTSIZE))   //SplitBlock(MemHandle, CCFILE_DEFAULTSIZE, (FileSize  - 1)))
05071     {
05072         FileSize += CCFILE_DEFAULTSIZE;
05073         return TRUE;
05074     }
05075     else
05076     {               
05077         IsOpen  = FALSE;
05078         GotError(_R(IDE_MEM_BLOCK_FAILURE));
05079         return FALSE;
05080     }
05081 }

BOOL CCMemFile::InitCompression BOOL  Header = FALSE  )  [virtual]
 

To initialise the compression system ready for use. This is to make sure there is enough memory available for its buffers before writing out any compression tokens into the output file. MemFiles not supported at present so always returns FALSE. Graeme (15/11/99): Added the Header parameter.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/6/95
See also:
StartCompression; StopCompression

Implements CCFile.

Definition at line 5609 of file ccfile.cpp.

05610 {
05611     ERROR3("CCMemFile::InitCompression Cannot compress memory files yet");
05612     return FALSE;   
05613 }

BOOL CCMemFile::IsMemFileInited  ) 
 

Allows errors to be returned from the constructor.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/9/94
Parameters:
None [INPUTS]
Returns:
TRUE if the contructor went without errors or FALSE otherwise.
See also:
CCMemFile

Definition at line 4944 of file ccfile.cpp.

04945 {
04946     return MemFileInitialised;
04947 }

BOOL CCMemFile::isOpen  )  const [virtual]
 

Determines whether an instance of CCMemFile is open.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93 Return: TRUE if file is open and FALSE otherwize

Implements CCFile.

Definition at line 5114 of file ccfile.cpp.

05115 {
05116     return IsOpen;
05117 }

BOOL CCMemFile::open void *  pFile,
UINT32  size,
FileAccess  fProt = CCMemRead
 

Opens an instance of a CCmemFile.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93
Parameters:
pFile - a pointer to the file [INPUTS] UINT32 - the size of the file fProt - defines the files protection - default = read only
Returns:
TRUE if file is opened successfully or FALSE otherwize

Definition at line 4986 of file ccfile.cpp.

04987 {
04988     // First check that the constructor went ok
04989     if (!MemFileInitialised)
04990     {
04991         // Did not construct ok, error should have been reported, so just fail
04992             IsOpen  = FALSE;
04993             return FALSE;
04994     }
04995 
04996     FileProt    = fProt;
04997 
04998     // If file is opened for reading
04999     if (FileProt == CCMemRead) 
05000     {
05001         // Is file pointer NULL
05002         if (!pFile)
05003         {
05004             IsOpen  = FALSE;
05005             GotError(_R(IDE_NULL_FILE));
05006             return FALSE;
05007         }             
05008         
05009         MemFile     = (BYTE*) pFile;            // Set Memory file pointer
05010         CurrentPos  = 0;                        // Set Current file position        
05011         
05012         // Check that file size is greater than zero
05013         if (size > 0)
05014             FileSize    = size;
05015         else
05016         {
05017             IsOpen  = FALSE;
05018             GotError(_R(IDE_FILE_SIZE_ZERO));
05019             return FALSE;
05020         }
05021     }
05022     // if file is open for writing  
05023     else if (FileProt == CCMemWrite)
05024     {                             
05025         // check file size 
05026         if (size > 0)
05027             FileSize = size;                    // if not zero use size passed in
05028         else
05029             FileSize = CCFILE_DEFAULTSIZE;              // else used default size
05030             
05031         // Allocate Memory 
05032         MemHandle = ClaimBlock(FileSize);
05033         
05034         // Check allocation worked ok
05035         if (MemHandle != BAD_MHANDLE)
05036         {
05037             IsOpen      = TRUE;
05038             CurrentPos  = 0;
05039         }
05040         else
05041         {
05042             IsOpen  = FALSE;
05043             GotError(_R(IDE_MEM_BLOCK_FAILURE));
05044             return FALSE;
05045         } 
05046     }
05047         
05048     return IsOpen;
05049 }

CCFile & CCMemFile::read char &  buf  )  [virtual]
 

Implements CCFile.

Reimplemented in CCMemTextFile, CCResTextFile, and CCClipBoardFile.

Definition at line 5170 of file ccfile.cpp.

05171 {
05172     // Make sure the file is open before it is read!
05173     if (!isOpen())
05174     {
05175         GotError(_R(IDE_NOTOPEN_ERROR));
05176         return *this;
05177     }
05178 
05179     // if file is write protected then exit
05180     if (FileProt != CCMemRead)
05181     {
05182         GotError(_R(IDE_WRITE_ONLY));
05183         return *this;
05184     }
05185     
05186     TCHAR* tempMemFile  = (TCHAR*) MemFile;         // Cast MemFile to a TCHAR pointer
05187 
05188     if (!eof())
05189     {
05190         buf = tempMemFile[CurrentPos++];
05191         CharsRead ++;
05192     }
05193     else
05194     {
05195         // Trying to read pasty EOF
05196         GotError(_R(IDE_EOF_ERROR));
05197     }
05198 
05199     return *this;
05200 }

CCFile & CCMemFile::read StringBase buf  )  [virtual]
 

Implements CCFile.

Reimplemented in CCMemTextFile, CCResTextFile, and CCClipBoardFile.

Definition at line 5164 of file ccfile.cpp.

05165 {
05166     ENSURE(FALSE, "Use a CCMemTextFile for ASCII memory files!");
05167     return (CCFile&) *this;
05168 }

CCFile & CCMemFile::read void *  buf,
UINT32  length = 1
[virtual]
 

Reads a single byte from the Memory file.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93
Parameters:
A pointer to a single byte [OUTPUTS]
Returns:
Reference to the CCFile object.

Implements CCFile.

Definition at line 5131 of file ccfile.cpp.

05132 {
05133     // Make sure the file is open before it is read!
05134     if (!isOpen())
05135     {
05136         GotError(_R(IDE_NOTOPEN_ERROR));
05137         return (CCFile&) *this;
05138     }
05139 
05140     // If not allowed to read, then exit.
05141     if (FileProt != CCMemRead)
05142     {
05143         GotError(_R(IDE_WRITE_ONLY));
05144         return (CCFile&) *this;
05145     }
05146     
05147     BYTE *TempBuf = (BYTE*) buf;
05148     
05149     while ((length > 0) && !eof())
05150     {
05151         *TempBuf++ = MemFile[CurrentPos++];
05152         length--;
05153     }
05154 
05155     if (length > 0)
05156     {
05157         // Could not read the required number of bytes.
05158         GotError(_R(IDE_EOF_ERROR));
05159     }
05160 
05161     return (CCFile&) *this;
05162 }

CCFile & CCMemFile::seek FilePos  pos  )  [virtual]
 

Sets the file pointer to the file position passed in. (Position zero is the beginning of the file).

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93
Returns:
Reference to the CCFile object.

Implements CCFile.

Definition at line 5292 of file ccfile.cpp.

05293 {
05294     if(!isOpen())
05295     {
05296         GotError(_R(IDE_NOTOPEN_ERROR));
05297         return (CCFile&) *this;
05298     }
05299     
05300     if (pos <= (FilePos)(FileSize))
05301     {
05302         CurrentPos = pos;
05303 
05304         // There were 1001 problems with memfile seeking / telling, the below sorts them out though
05305         if(IsLexerInitialised() && SeekingRequired)
05306         {
05307             Ch = 0;
05308             Ofs = 0;
05309             LastLinePos = pos;
05310             TokenBuf[0] = 0;
05311             Line = 0;
05312             CharsRead = 0;
05313             LastLinePos = pos;
05314             EOFFound = FALSE;
05315 
05316             // Fill up the buffers with the new chars           
05317             GetLine();
05318             //GetCh();
05319         }
05320     }
05321     else
05322     {
05323         GotError(_R(IDE_FILEPOS_ERROR));
05324         return (CCFile&) *this;
05325     }
05326 
05327     return (CCFile&) *this;
05328 }

CCFile & CCMemFile::seekIn INT32  Offset,
ios::seekdir  Dir
[virtual]
 

Alter position of the file input pointer. NB. input and output pointers are linked with CCMemFiles, so you will alter the output pointer too.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/05/95
Parameters:
Offset - the file offset required. [INPUTS] Dir - the offset mode to use.
- [OUTPUTS]
Returns:
Reference to the CCFile object.

Implements CCFile.

Definition at line 5383 of file ccfile.cpp.

05384 {
05385     switch(Dir)
05386     {
05387         case ios::beg:
05388             return(seek(Offset));
05389 
05390         case ios::cur:
05391             return(seek(tell() + Offset));
05392 
05393         case ios::end:
05394             {
05395                 FilePos NewPos = (FilePos)(FileSize - Offset);
05396                 if (NewPos < 0)
05397                 {
05398                     ERROR3("Attempt to seek before beginning of file using seekIn with ios::end");
05399                     NewPos = 0;
05400                 }
05401                 return(seek(NewPos));
05402             }
05403         default:
05404             break; // fall through
05405     }
05406 
05407     ERROR3("Illegal seekIn seek_dir value (CCMemFile::seekIn)");
05408     return (CCFile&) *this;
05409 }

CCFile & CCMemFile::seekIn FilePos  Pos  )  [virtual]
 

Alter position of the file input pointer. NB. input and output pointers are linked with CCMemFiles, so you will alter the output pointer too.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
Pos - the desired file position. [INPUTS]
Returns:
Reference to the CCFile object.

Implements CCFile.

Definition at line 5360 of file ccfile.cpp.

05361 {
05362     return seek(Pos);
05363 }

void CCMemFile::SetBadState  )  [virtual]
 

It allows the forceable setting of the test that functions like bad() use so the next check of the current file status to see if we should continue using the file or not will fail. This will be called by the GotError function so that any attempts to read/write after this should fail.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/08/94
Returns:
None.
See also:
CCFile::GotError

Implements CCFile.

Definition at line 5502 of file ccfile.cpp.

05503 {
05504     WasError = TRUE;
05505 }

void CCMemFile::SetGoodState  )  [virtual]
 

It allows the forceable setting of the test that functions like bad() use so the next check of the current file status to see if we should continue using the file or not will pass.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/12/94
Returns:
None.
See also:
CCFile::GotError

Implements CCFile.

Definition at line 5521 of file ccfile.cpp.

05522 {
05523     // Nuke any existing error states that might exist e.g. a lying eof() bit
05524     WasError = FALSE;
05525 }

BOOL CCMemFile::setMode INT32  fileMode = 0  )  [virtual]
 

None- cannot change the mode on a memory file - either it's binary in which case it's a CCMemFile, or it's text, in which case it's a CCMemTextFile.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
See also:
CCFile::setMode

Implements CCFile.

Definition at line 5096 of file ccfile.cpp.

05097 {
05098     ENSURE(FALSE, "Should use CCMemFile or CCMemTextFile to set the file mode!");
05099     return FALSE;
05100 }

size_t CCMemFile::Size  )  [virtual]
 

Find the size of the file.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
Size in bytes of the file.

Implements CCFile.

Definition at line 5450 of file ccfile.cpp.

05451 {
05452     return FileSize;
05453 }

BOOL CCMemFile::StartCompression  )  [virtual]
 

To start up the compression system. MemFiles not supported at present so always returns FALSE.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/5/95
See also:
StopCompression

Implements CCFile.

Definition at line 5628 of file ccfile.cpp.

05629 {
05630     ERROR3("CCMemFile::StartCompression Cannot compress memory files yet");
05631     return FALSE;   
05632 }   

BOOL CCMemFile::StopCompression  )  [virtual]
 

To stop the compression system. MemFiles not supported at present so always returns FALSE.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/5/95
See also:
StartCompression

Implements CCFile.

Definition at line 5647 of file ccfile.cpp.

05648 {
05649     ERROR3("CCMemFile::StartCompression Cannot compress memory files yet");
05650     return FALSE;
05651 }

FilePos CCMemFile::tell  )  [virtual]
 

Gets the file pointer position of the file.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93 Return: current file pointer position

Implements CCFile.

Definition at line 5341 of file ccfile.cpp.

05342 {
05343     return CurrentPos;
05344 }

FilePos CCMemFile::tellIn  )  [virtual]
 

Return the position of the file input pointer.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Returns:
File position.

Implements CCFile.

Definition at line 5424 of file ccfile.cpp.

05425 {
05426     if(IsLexerInitialised())
05427     {
05428         if(!SeekingRequired)
05429             ERROR3("CCMemFile::tellIn() will only work properly with seeking enabled");
05430 
05431         // -1 for the character lookahead in operation
05432         return (FilePos)(Ofs + (INT32) LastLinePos - 1);
05433     }
05434 
05435     return tell();
05436 }

CCFile & CCMemFile::write char &  buf  )  [virtual]
 

Implements CCFile.

Definition at line 5273 of file ccfile.cpp.

05274 {
05275     ENSURE(FALSE, "Use a CCMemTextFile for ASCII memory files!");
05276     return (CCFile&) *this;
05277 }

CCFile & CCMemFile::write const StringBase buf,
UINT32  length = 0
[virtual]
 

Implements CCFile.

Reimplemented in CCMemTextFile, and CCClipBoardFile.

Definition at line 5267 of file ccfile.cpp.

05268 {
05269     ENSURE(FALSE, "Use a CCMemTextFile for ASCII memory files!");
05270     return (CCFile&) *this;
05271 }

CCFile & CCMemFile::write const void *  buf,
UINT32  length = 1
[virtual]
 

Writes a stream of bytes to the Memory file.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/93
Parameters:
A pointer to a single byte [INPUTS] Length denotes number of bytes to written
Returns:
Reference to the CCFile object.

Implements CCFile.

Definition at line 5216 of file ccfile.cpp.

05217 {                                      
05218     // Make sure the file is open before it is written!
05219     if (!isOpen())
05220     {
05221         GotError(_R(IDE_NOTOPEN_ERROR));
05222         return (CCFile&) *this;
05223     }
05224 
05225     // if file is read only then exit
05226     if (FileProt != CCMemWrite)
05227     {
05228         GotError(_R(IDE_READ_ONLY));
05229         return (CCFile&) *this;
05230     }
05231     
05232     BYTE* tempBuf = (BYTE*) buf;
05233     
05234     // Get Pointer to the memory file
05235     if (!DescribeBlock(MemHandle, &MemFile, &FileSize))
05236     {
05237         GotError(_R(IDE_MEM_BLOCK_FAILURE));
05238         return (CCFile&) *this;
05239     } 
05240 
05241     while (length > 0)
05242     {
05243         if (eof())
05244         {
05245             if (GrowMemFile())
05246             {
05247                 // Get Pointer to the memory file
05248                 if (!DescribeBlock(MemHandle, &MemFile, &FileSize))
05249                 {
05250                     GotError(_R(IDE_MEM_BLOCK_FAILURE));
05251                     return (CCFile&) *this;
05252                 }
05253             }
05254             else
05255                 // Can't increase memfile - error
05256                 break;
05257         }
05258 
05259         // Write input byte
05260         MemFile[CurrentPos++] = *tempBuf++;
05261         length--;
05262     }
05263     
05264     return (CCFile&) *this;
05265 }


Member Data Documentation

UINT32 CCMemFile::CurrentPos [protected]
 

Definition at line 846 of file ccfile.h.

UINT32 CCMemFile::FileProt [protected]
 

Definition at line 848 of file ccfile.h.

size_t CCMemFile::FileSize [protected]
 

Definition at line 845 of file ccfile.h.

BOOL CCMemFile::IsOpen [protected]
 

Definition at line 847 of file ccfile.h.

BYTE* CCMemFile::MemFile [protected]
 

Definition at line 844 of file ccfile.h.

BOOL CCMemFile::MemFileInitialised [protected]
 

Definition at line 854 of file ccfile.h.

MHANDLE CCMemFile::MemHandle [protected]
 

Definition at line 843 of file ccfile.h.

BOOL CCMemFile::WasError [protected]
 

Definition at line 849 of file ccfile.h.


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