CCResTextFile Class Reference

Will be used to access Windows resource text files - such as those used in the for Camelot Menu Scripts. More...

#include <oilfiles.h>

Inheritance diagram for CCResTextFile:

CCResourceFile CCMemFile CCLexFile CCFile CCObject SimpleCCObject List of all members.

Public Member Functions

 CCResTextFile ()
 CCResTextFile (UINT32 ResourceId, UINT32 ResourceType, FileAccess fProt=CCMemRead)
 Constructs an instance of CCResTextFile and Opens it.
 ~CCResTextFile ()
 Default destructor.
BOOL open (UINT32 ResourceId, UINT32 ResourceType, FileAccess fProt=CCMemRead)
 Opens an instance of a CCResTextFile.
BOOL open (UINT32)
CCFileread (TCHAR &buf)
 Reads a single character from the Memory file.
CCFileread (StringBase *buf)
 Read in a string from the file. The read operation stops at the first newline, or when the string is full. The newline is removed from the input stream.
BOOL eof () const
 Determines whether an instance of CCResTextFile is open.
void close ()
 Closes an instance of a CCResTextFile.

Detailed Description

Will be used to access Windows resource text files - such as those used in the for Camelot Menu Scripts.

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

Definition at line 147 of file oilfiles.h.


Constructor & Destructor Documentation

CCResTextFile::CCResTextFile  )  [inline]
 

Definition at line 150 of file oilfiles.h.

00150 {}

CCResTextFile::CCResTextFile UINT32  ResourceId,
UINT32  ResourceType,
FileAccess  fProt = CCMemRead
 

Constructs an instance of CCResTextFile and Opens it.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Parameters:
UINT32 - Resource Identifier representing the Windows resource to be read in [INPUTS] UINT32 - Resource Type - String Id representing the type of Camelot resource fProt - defines the files protection - default = read only
Date:
9/9/93

Definition at line 389 of file oilfiles.cpp.

00390  : CCResourceFile(ResourceId, ResourceType, fProt)
00391 {
00392 }

CCResTextFile::~CCResTextFile  ) 
 

Default destructor.

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

Definition at line 404 of file oilfiles.cpp.

00405 {                   
00406 }


Member Function Documentation

void CCResTextFile::close  )  [virtual]
 

Closes an instance of a CCResTextFile.

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

Reimplemented from CCMemFile.

Definition at line 583 of file oilfiles.cpp.

00584 {   
00585     CCResourceFile::close();
00586 }

BOOL CCResTextFile::eof  )  const [virtual]
 

Determines whether an instance of CCResTextFile is open.

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

Reimplemented from CCMemFile.

Definition at line 560 of file oilfiles.cpp.

00561 {                                          
00562     char* tempResFile = (char*) MemFile;            // Cast MemFile to a char pointer
00563 
00564     // Changed the '==' to '>=' in the following check on CurrentPos (MarkN 9/5/94)
00565 
00566     if ((CurrentPos >= (FileSize - 1)) || (tempResFile[CurrentPos] == END_OF_FILE))
00567         return TRUE;
00568     else
00569         return FALSE;
00570 }

BOOL CCResTextFile::open UINT32   ) 
 

Reimplemented from CCResourceFile.

Definition at line 427 of file oilfiles.cpp.

00428 {
00429     return CCResourceFile::open( ResourceID );
00430 }

BOOL CCResTextFile::open UINT32  ResourceId,
UINT32  ResourceType,
FileAccess  fProt = CCMemRead
 

Opens an instance of a CCResTextFile.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/9/93
Parameters:
UINT32 - Resource Identifier representing the Windows resource to be read in [INPUTS] UINT32 - Resource Type - String Id representing the type of Camelot resource fProt - defines the files protection - default = read only
Returns:
TRUE if file is opened successfully or FALSE otherwize

Definition at line 422 of file oilfiles.cpp.

00423 {
00424     return CCResourceFile::open(ResourceId, ResourceType, fProt);
00425 }

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

Read in a string from the file. The read operation stops at the first newline, or when the string is full. The newline is removed from the input stream.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> & Mark Neves
Date:
6/9/93 (updated 26/4/94 by MarkN)
Parameters:
buf - the String object to place the characters in. [INPUTS]
buf - the characters read from the file. [OUTPUTS]
Returns:
Reference to the CCFile object.

Reimplemented from CCMemFile.

Definition at line 496 of file oilfiles.cpp.

00497 {
00498     // Make sure the file is open before it is read!
00499     if (!isOpen())
00500     {
00501         GotError(_R(IDE_NOTOPEN_ERROR));
00502         return (CCFile&) *this;
00503     }
00504 
00505     // if file is write protected then exit
00506     if (FileProt != CCMemRead)
00507     {
00508         GotError(_R(IDE_WRITE_ONLY));
00509         return (CCFile&) *this;
00510     }
00511 
00512     char* tempResFile   = (char*) MemFile;          // Cast MemFile to a TCHAR pointer
00513     TCHAR* pString      = *buf;                     // Cast input string to a TCHAR pointer
00514     UINT32 i = 0;
00515     
00516     UINT32 Len = buf->MaxLength();
00517 
00518     // Added check for '\n' on 26/4/94 by MarkN
00519 
00520     while ((i <= Len) && (!eof()) && (tempResFile[CurrentPos] != '\n') && (tempResFile[CurrentPos] != '\r'))
00521     {
00522 #if FALSE != wxUSE_UNICODE
00523         mbtowc( pString, tempResFile + CurrentPos, 1 );
00524         ++CurrentPos;
00525 #else
00526         *pString = tempResFile[CurrentPos++];
00527 #endif
00528         pString++;
00529         i++;
00530     }
00531 
00532     if ((tempResFile[CurrentPos] == '\n') || (tempResFile[CurrentPos] == '\r'))
00533     {
00534         CurrentPos++;
00535 
00536         // It is possible for the CR to be made up of a \r\n pair , so we have to look for this
00537         if ((!eof()) && ((tempResFile[CurrentPos] == '\n') || (tempResFile[CurrentPos] == '\r')))
00538         {
00539             CurrentPos++;
00540         }
00541     }
00542     
00543     *pString = 0;                           // Added 26/4/94 by MarkN
00544     
00545     return (CCFile&) *this;
00546 }

CCFile & CCResTextFile::read TCHAR buf  )  [virtual]
 

Reads a single character from the Memory file.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/9/93 Outputs; character read in Return: A reference to a memory file object

Reimplemented from CCMemFile.

Definition at line 444 of file oilfiles.cpp.

00445 {
00446     // Make sure the file is open before it is read!
00447     if (!isOpen())
00448     {
00449         GotError(_R(IDE_NOTOPEN_ERROR));
00450         return (CCFile&) *this;
00451     }
00452 
00453     // if file is write protected then exit
00454     if (FileProt != CCMemRead)
00455     {
00456         GotError(_R(IDE_WRITE_ONLY));
00457         return (CCFile&) *this;
00458     }
00459 
00460     char* tempResFile   = (char*)MemFile;           // Cast MemFile to a TCHAR pointer
00461 
00462     if (!eof())
00463     {
00464 #if FALSE != wxUSE_UNICODE
00465         mbtowc( &buf, tempResFile + CurrentPos, 1 );
00466 #else
00467         buf = tempResFile[CurrentPos];
00468 #endif
00469         ++CurrentPos;
00470     }
00471     else
00472     {
00473         GotError(_R(IDE_EOF_ERROR));
00474     }
00475 
00476     return (CCFile&) *this;
00477 }


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