#include <cxfile.h>
Inheritance diagram for CXaraFile:
Public Member Functions | |
CXaraFile () | |
Default constructor. | |
virtual | ~CXaraFile () |
virtual BOOL | OpenToWrite (CCLexFile *pCCFile) |
Opens the CXaraFile object ready for writing. It uses the given CCFile object as the file to write to. | |
virtual BOOL | OpenToRead (CCLexFile *pCCFile) |
Opens the CXaraFile object ready for reading. It uses the given CCFile object as the file to read from. | |
virtual BOOL | Close () |
This closes the CXaraFile object. You should call this func at the very end of reading from or writing to the file. | |
BOOL | SetCompression (BOOL NewState) |
Function to turn Compression on or off on the underlying CCFile. This is used during reading to change the state of the file compression. | |
virtual BOOL | StartCompression () |
Function to turn Compression on when we are writing to the file. It asks the underlying CCFile and CXaraFile to start the compression process up. Will only send the record out if the preference option is on. | |
virtual BOOL | StopCompression () |
Function to turn Compression off when we are writing to the file. It asks the underlying CCFile and CXaraFile to stop the compression process. Will only send the record out if the preference option is on. | |
virtual BOOL | IsCompressionOn () |
This returns the compression state of the associated CCFile object. | |
virtual CCLexFile * | GetCCFile (void) const |
Function to give public access to the underlying CCLexFile that is being used to save out the data. Note: only people who have a genuine reason need to access this - e.g. bitmap savers. | |
UINT32 | GetCurrentRecordSize () |
Function to get the current size of the record that has been read in by the CXaraFile and RecordHandlers and are currently processing. This can be used by streamed record handlers, such as bitmaps, which need to know the size of the recordso that they can update the progress bar size by a proportion of this amount on loading. (Not require on saving as the streamed record handlers can supply what value they like to the progress system and hence update with whatever value they require. | |
virtual INT32 | StartRecord (UINT32 Tag, INT32 Size) |
Prepares a record ready for writing to the file. | |
virtual BOOL | EndRecord (void) |
Ends the current record. | |
virtual INT32 | StartStreamedRecord (UINT32 Tag, INT32 Size) |
virtual BOOL | EndStreamedRecord (UINT32 *RecordSize) |
Ends the current streamed record. | |
UINT32 | GetRecordTag () |
Gets the tag value. | |
INT32 | GetRecordNum () |
Gets the current record's record number. | |
virtual BOOL | Write (BYTE b) |
Writes out the given value to the file. | |
BOOL | Write (UINT32 n) |
Writes out the given value to the file. | |
BOOL | Write (INT32 n) |
BOOL | Write (const DocCoord &Coord) |
Writes out the coord. | |
BOOL | Write (BYTE *pBuf, UINT32 Size) |
Writes out the given buffer of bytes to the file. | |
BOOL | Write (FLOAT f) |
BOOL | Write (double d) |
BOOL | WriteWCHAR (WCHAR w) |
BOOL | WriteCCPanose (const CCPanose &Panose) |
BOOL | WriteBitmapSource (const BitmapSource &Source, UINT32 Height, BaseCamelotFilter *pThisFilter) |
Writes out the given BitmapSource to this file. | |
BOOL | Write (TCHAR *pStr) |
Writes out the string as a Unicode string (UTF16). | |
BOOL | WriteASCII (TCHAR *pStr) |
Writes out the string as an ASCII string. | |
BOOL | WriteUnicode (TCHAR *pStr) |
virtual UINT32 | Write (CXaraFileRecord *pRecord) |
Writes out the record to the file. | |
virtual UINT32 | WriteDefinitionRecord (CXaraFileRecord *pRecord) |
Writes out the record to the file Override this if your filter needs to keep track of definition records. | |
BOOL | Read (UINT32 *pUINT32) |
Reads in the give value type from the file. | |
BOOL | Read (BYTE *pBuf, UINT32 Size) |
Reads in the give value type from the file. | |
BOOL | Read (BYTE *pBYTE) |
Reads in the give value type from the file. | |
BOOL | Read (FLOAT *pf) |
BOOL | Read (double *pd) |
BOOL | ReadWCHAR (WCHAR *pw) |
BOOL | ReadCCPanose (CCPanose *pPanose) |
BOOL | Read (TCHAR *pStr, UINT32 MaxChars) |
Reads in the given string from the file. | |
BOOL | ReadUnicode (TCHAR *pStr, UINT32 MaxChars) |
Reads in the given string from the file. | |
BOOL | ReadNextRecord () |
Reads in the next record from the file. | |
BOOL | ReadNextRecordHeader () |
Reads in the header (i.e. tag & size fields) of the next record in the file. | |
virtual UINT32 | GetNumBytesWritten () |
virtual UINT32 | GetNumBytesRead () |
virtual UINT32 | GetTotalNumBytesToRead () |
virtual void | SetTotalNumBytesToRead (UINT32 n) |
virtual FilePos | GetFilePos () |
Gets the current file pos of the associated CCFile object. | |
virtual BOOL | SetUpHandlers (BaseCamelotFilter *pThisFilter) |
Sets up some record handlers that are needed for reading the file successfully. | |
virtual void | SetDefaultRecordHandler (CXaraFileRecordHandler *pHandler) |
virtual CXaraFileRecordHandler * | GetDefaultRecordHandler () |
virtual void | SetStripSubTreeRecordHandler (StripSubTreeRecordHandler *pHandler) |
virtual StripSubTreeRecordHandler * | GetStripSubTreeRecordHandler () |
void | StripNextSubTree () |
void | GotError (UINT32 errorID) |
Sets an error using the given resource string All it does is call the mirror function in the attached CCFile. | |
void | GotError (UINT32 errorID, const TCHAR *errorString) |
Sets an error using the given resource string All it does is call the mirror function in the attached CCFile. | |
BOOL | RegisterRecordHandlers (List *pListOfHandlers) |
Finds the record handler that's been registered to handle a record with the given tag value. | |
UINT32 | GetLastReadTag () |
void | SetFilter (BaseCamelotFilter *pThisFilter) |
BaseCamelotFilter * | GetFilter () |
Protected Member Functions | |
virtual CXaraFileRecordHandler * | FindHandler (UINT32 Tag) |
Finds the record handler that's been registered to handle a record with the given tag value. | |
virtual CXaraFileRecordHandler * | SearchForHandler (UINT32 Tag) |
Searches through the list of registered record handlers for a handler for the given tag value. | |
virtual CXaraFileRecordHandler * | LookUpHandler (UINT32 Tag) |
This looks up the tag in the tag-to-handler map. | |
virtual void | SetUpHandlerMap () |
Sets up the tag to handler map so that LookUpHandler() can function. | |
virtual void | ResetHandlers () |
Resets the handlers set up via SetUpHandlers(). | |
UINT32 | WriteRecordHeader (UINT32 Tag, INT32 Size) |
Writes out a record header directly to the file. It expects the caller to handle other aspects of the record writing. This should only be used by people who know what they are doing e.g. compression. | |
virtual BOOL | FixStreamedRecordHeader (UINT32 *RecordSize) |
Fixes up the previously saved record header for a streamed record. The RecordSize is the size of the data section of the record and so does not include the 8 bytes in the header. | |
virtual void | IncNumBytesWritten (UINT32 n) |
virtual void | IncNumBytesRead (UINT32 n) |
Protected Attributes | |
CXaraFileRecord * | pRecord |
BOOL | WriteToRecord |
CCLexFile * | pCCFile |
INT32 | RecordNumber |
UINT32 | NumBytesWritten |
UINT32 | NumBytesRead |
UINT32 | TotalNumBytesToRead |
UINT32 | ProgressID |
UINT32 | ReadTag |
UINT32 | ReadSize |
List * | pRecordHandlerList |
CXaraFileRecordHandler * | pDefaultRecordHandler |
CamelotRecordHandler * | pStandardDefaultRecordHandler |
StripSubTreeRecordHandler * | pStripSubTreeRecordHandler |
StripSubTreeRecordHandler * | pStandardStripSubTreeRecordHandler |
FilePos | StartOfStreamedRecord |
BOOL | WritingStreamedRecord |
BOOL | CompOffDueToStreamedRecord |
BaseCamelotFilter * | pFilter |
CXaraFileMapTagToHandler * | pMap |
Private Member Functions | |
CC_DECLARE_DYNAMIC (CXaraFile) |
Definition at line 149 of file cxfile.h.
|
Default constructor.
Definition at line 167 of file cxfile.cpp. 00168 { 00169 pCCFile = NULL; 00170 pRecord = NULL; 00171 WriteToRecord = FALSE; 00172 00173 RecordNumber = 0; 00174 00175 NumBytesWritten = 0; 00176 NumBytesRead = 0; 00177 TotalNumBytesToRead = 0; 00178 00179 // the record handler list 00180 pRecordHandlerList = NULL; 00181 00182 // The standard set of record handlers 00183 pDefaultRecordHandler = NULL; 00184 pStandardDefaultRecordHandler = NULL; 00185 pStripSubTreeRecordHandler = NULL; 00186 pStandardStripSubTreeRecordHandler = NULL; 00187 00188 StartOfStreamedRecord = 0; 00189 WritingStreamedRecord = FALSE; 00190 CompOffDueToStreamedRecord = FALSE; 00191 00192 pFilter = NULL; 00193 pMap = NULL; 00194 00195 #if defined(EXCLUDE_FROM_XARLIB) 00196 pAtomicTagList = NULL; 00197 pEssentialTagList = NULL; 00198 00199 EndOfFile = FALSE; 00200 #endif 00201 }
|
|
Definition at line 156 of file cxfile.h.
|
|
|
|
This closes the CXaraFile object. You should call this func at the very end of reading from or writing to the file.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 565 of file cxfile.cpp. 00566 { 00567 // Sanity Check 00568 ERROR3IF(pCCFile == NULL,"pCCFile is NULL"); 00569 00570 // Reset all handlers that we set up via SetUpHandlers() 00571 ResetHandlers(); 00572 00573 return TRUE; 00574 }
|
|
Ends the current record.
Reimplemented in CXaraTemplateFile. Definition at line 1486 of file cxfile.cpp. 01487 { 01488 ERROR3IF(WriteToRecord && pRecord == NULL,"Writing to a NULL record!"); 01489 01490 BOOL ok = TRUE; 01491 01492 if (WritingStreamedRecord) 01493 { 01494 // Not interested in the result, but we will pass through a variable anyway 01495 // Complete the process of writing out the streamed record 01496 UINT32 RecordSize = 0L; 01497 return EndStreamedRecord(&RecordSize); 01498 } 01499 01500 if (WriteToRecord && pRecord != NULL) 01501 { 01502 WriteToRecord = FALSE; 01503 01504 #if !defined(EXCLUDE_FROM_XARLIB) 01505 ERROR3IF(!pRecord->IsDataSectionFull(),"Data section of the record has not been filled"); 01506 #endif 01507 01508 if (ok) ok = Write(pRecord->GetTag()); 01509 if (ok) ok = Write(pRecord->GetSize()); 01510 if (ok) ok = Write(pRecord->GetBuffer(),pRecord->GetSize()); 01511 01512 delete pRecord; 01513 pRecord = NULL; 01514 } 01515 01516 return (ok); 01517 }
|
|
Ends the current streamed record.
Reimplemented in CXaraTemplateFile. Definition at line 1542 of file cxfile.cpp. 01543 { 01544 ERROR3IF(!WritingStreamedRecord,"Trying to end a non-streamed record!"); 01545 if (!WritingStreamedRecord) 01546 return FALSE; 01547 01548 BOOL ok = TRUE; 01549 // We must reset WritingStreamedRecord to FALSE immediately, to prevent stack overflow 01550 // due to recursion via the StartCompression() call below 01551 WritingStreamedRecord = FALSE; 01552 01553 // Use our vitrual function to fix the header up with the correct info 01554 // Null filter overides this to do nothing 01555 UINT32 SizeOfRecord = 0L; 01556 ok = FixStreamedRecordHeader(&SizeOfRecord); 01557 // If we are passed a pointer then return the size to the caller 01558 if (RecordSize) 01559 *RecordSize = SizeOfRecord; 01560 // Add this number to the number of bytes written 01561 TRACEUSER( "Neville", _T("EndStreamedRecord update size by %d\n"),SizeOfRecord); 01562 IncNumBytesWritten(SizeOfRecord); 01563 01564 // If compression was turned off due to the streamed record, make sure we turn it back on again 01565 if (ok && CompOffDueToStreamedRecord) 01566 ok = StartCompression(); 01567 01568 // Reset the streamed record vars 01569 StartOfStreamedRecord = 0; 01570 CompOffDueToStreamedRecord = FALSE; 01571 01572 return ok; 01573 }
|
|
Finds the record handler that's been registered to handle a record with the given tag value.
Definition at line 1967 of file cxfile.cpp. 01968 { 01969 ERROR3IF(pRecordHandlerList == NULL && GetDefaultRecordHandler()==NULL,"pRecordHandlerList is NULL & there's no default handler"); 01970 01971 CXaraFileRecordHandler* pHandler = NULL; 01972 01973 // Does the sub tree stripper want to process the tag? 01974 pHandler = GetStripSubTreeRecordHandler(); 01975 if (pHandler != NULL) 01976 { 01977 if (pHandler->IsTagInList(Tag)) 01978 return pHandler; 01979 } 01980 01981 // See if handler is in the map (i.e. do the quick method first) 01982 pHandler = LookUpHandler(Tag); 01983 if (pHandler != NULL) 01984 return pHandler; 01985 01986 // Search the handler list for a suitable handler 01987 pHandler = SearchForHandler(Tag); 01988 if (pHandler != NULL) 01989 return pHandler; 01990 01991 // If all else fails, fall through to the default record handler. 01992 return GetDefaultRecordHandler(); 01993 }
|
|
Fixes up the previously saved record header for a streamed record. The RecordSize is the size of the data section of the record and so does not include the 8 bytes in the header.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 1592 of file cxfile.cpp. 01593 { 01594 ERROR2IF(pCCFile == NULL,FALSE,"CXaraFile::FixStreamedRecordHeader NULL pCCFile"); 01595 ERROR2IF(StartOfStreamedRecord == 0,FALSE,"CXaraFile::FixStreamedRecordHeader StartOfStreamedRecord == 0"); 01596 01597 // Note the current position in the file 01598 FilePos Pos = GetFilePos(); 01599 // Work out the record size from it and the previosuly stored start of record position 01600 UINT32 Size = Pos-StartOfStreamedRecord-8; 01601 UINT32 tSize = NativetoLE(Size); 01602 01603 // Seek back to the size field in the record header 01604 pCCFile->seek(StartOfStreamedRecord+4); 01605 01606 // Fix the size to be correct 01607 if (pCCFile->write(&tSize, 4).fail()) 01608 return FALSE; 01609 01610 // Now get back to where we were in the file 01611 pCCFile->seek(Pos); 01612 01613 // If we are passed a pointer then return the size to the caller 01614 if (RecordSize) 01615 *RecordSize = Size; 01616 01617 return TRUE; 01618 }
|
|
Function to give public access to the underlying CCLexFile that is being used to save out the data. Note: only people who have a genuine reason need to access this - e.g. bitmap savers.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 836 of file cxfile.cpp. 00837 { 00838 ERROR2IF(pCCFile == NULL,FALSE,"CXaraFile::GetCCFile pCCFile is NULL"); 00839 return pCCFile; 00840 }
|
|
Function to get the current size of the record that has been read in by the CXaraFile and RecordHandlers and are currently processing. This can be used by streamed record handlers, such as bitmaps, which need to know the size of the recordso that they can update the progress bar size by a proportion of this amount on loading. (Not require on saving as the streamed record handlers can supply what value they like to the progress system and hence update with whatever value they require.
Definition at line 862 of file cxfile.cpp. 00863 { 00864 return ReadSize; 00865 }
|
|
Definition at line 588 of file cxfile.cpp. 00589 { 00590 return pDefaultRecordHandler; 00591 }
|
|
Gets the current file pos of the associated CCFile object.
Reimplemented in NULLXaraFile. Definition at line 1733 of file cxfile.cpp.
|
|
Definition at line 272 of file cxfile.h. 00272 { return pFilter; }
|
|
Definition at line 268 of file cxfile.h. 00268 { return ReadTag; }
|
|
Definition at line 235 of file cxfile.h. 00235 { return NumBytesRead; }
|
|
Definition at line 234 of file cxfile.h. 00234 { return NumBytesWritten; }
|
|
Gets the current record's record number.
The record number defines the position of the record in the file. Record number 1 means the first record in the file, 2 the second, etc.
Definition at line 1787 of file cxfile.cpp. 01788 { 01789 ERROR3IF(!WriteToRecord,"Can't get record num - no current record"); 01790 01791 if (!WriteToRecord) 01792 return 0; 01793 01794 return RecordNumber; 01795 }
|
|
Gets the tag value.
Definition at line 1756 of file cxfile.cpp. 01757 { 01758 ERROR3IF(!WriteToRecord,"Can't get tag - no current record"); 01759 ERROR3IF(WriteToRecord && pRecord == NULL,"current record is NULL"); 01760 01761 if (!WriteToRecord || (pRecord == NULL)) 01762 return UINT32(-1); 01763 01764 return pRecord->GetTag(); 01765 }
|
|
Definition at line 622 of file cxfile.cpp. 00623 { 00624 return pStripSubTreeRecordHandler; 00625 }
|
|
Definition at line 236 of file cxfile.h. 00236 { return TotalNumBytesToRead; }
|
|
Sets an error using the given resource string All it does is call the mirror function in the attached CCFile.
Definition at line 1834 of file cxfile.cpp.
|
|
Sets an error using the given resource string All it does is call the mirror function in the attached CCFile.
Definition at line 1812 of file cxfile.cpp.
|
|
Definition at line 301 of file cxfile.h. 00301 { NumBytesRead += n; }
|
|
Definition at line 300 of file cxfile.h. 00300 { NumBytesWritten += n; }
|
|
This returns the compression state of the associated CCFile object.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 764 of file cxfile.cpp. 00765 { 00766 ERROR2IF(pCCFile == NULL,FALSE,"pCCFile is NULL"); 00767 00768 return pCCFile->IsCompressionSet(); 00769 }
|
|
This looks up the tag in the tag-to-handler map.
Definition at line 1906 of file cxfile.cpp. 01907 { 01908 CXaraFileRecordHandler* pHandler = NULL; 01909 01910 if (pMap != NULL) 01911 pHandler = pMap->LookUp(Tag); 01912 01913 return pHandler; 01914 }
|
|
Opens the CXaraFile object ready for reading. It uses the given CCFile object as the file to read from.
This also function sets the default record handler to the standard one, unless you have previously set the default handler with a call to SetDefaultRecordHandler(). You can also set a default handler with SetDefaultRecordHandler() after this call. It's up to you, before or after, which
Reimplemented in CXaraTemplateFile. Definition at line 517 of file cxfile.cpp. 00518 { 00519 // Check entry params 00520 ERROR2IF(pThisCCFile == NULL,FALSE,"pThisCCFile is NULL"); 00521 00522 // pCCFile should be NULL at this point 00523 ERROR3IF(pCCFile != NULL,"pThisCCFile is NULL"); 00524 00525 // Set our ptr the the CCFile to the one provided 00526 pCCFile = pThisCCFile; 00527 00528 // Reset the read vars 00529 RecordNumber = 0; 00530 NumBytesRead = 0; 00531 TotalNumBytesToRead = 0; 00532 00533 BOOL ok = TRUE; 00534 UINT32 n = 0; 00535 00536 // The first 8 bytes should be our unique ID sequence 00537 if (ok) ok = Read(&n); 00538 if (ok) ok = (n == CXF_IDWORD1); 00539 if (ok) ok = Read(&n); 00540 if (ok) ok = (n == CXF_IDWORD2); 00541 00542 return ok; 00543 }
|
|
Opens the CXaraFile object ready for writing. It uses the given CCFile object as the file to write to.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 223 of file cxfile.cpp. 00224 { 00225 // Check entry params 00226 ERROR2IF(pThisCCFile == NULL,FALSE,"pThisCCFile is NULL"); 00227 00228 // pCCFile should be NULL at this point 00229 ERROR3IF(pCCFile != NULL,"pThisCCFile is NULL"); 00230 00231 // Set our ptr the the CCFile to the one provided 00232 pCCFile = pThisCCFile; 00233 00234 // Reset the write vars 00235 RecordNumber = 0; 00236 NumBytesWritten = 0; 00237 00238 BOOL ok = TRUE; 00239 00240 // The first 8 bytes should be our unique ID sequence 00241 if (ok) ok = Write((UINT32)CXF_IDWORD1); 00242 if (ok) ok = Write((UINT32)CXF_IDWORD2); 00243 00244 return ok; 00245 }
|
|
Reads in the given string from the file.
Definition at line 994 of file cxfile.cpp. 00995 { 00996 return ReadUnicode(pStr,MaxChars); 00997 }
|
|
Definition at line 898 of file cxfile.cpp. 00899 { 00900 DoubleUnion f; 00901 BOOL ok = (Read((BYTE*)&(f.u_INT64),sizeof(f.u_INT64))); 00902 *pd = LEtoNative(f); 00903 return ok; 00904 }
|
|
Definition at line 890 of file cxfile.cpp. 00891 { 00892 FloatUnion f; 00893 BOOL ok = (Read((BYTE*)&(f.u_INT32),sizeof(f.u_INT32))); 00894 *pf = LEtoNative(f); 00895 return ok; 00896 }
|
|
Reads in the give value type from the file.
Definition at line 964 of file cxfile.cpp. 00965 { 00966 ERROR3IF(pBYTE == NULL,"pBYTE is NULL"); 00967 ERROR2IF(pCCFile == NULL,FALSE,"Can't write a BYTE with no pCCFile"); 00968 00969 if (pBYTE == NULL) 00970 return FALSE; 00971 00972 pCCFile->read((void*)pBYTE); 00973 IncNumBytesRead(1); 00974 00975 return (!pCCFile->bad() && !pCCFile->fail() && !pCCFile->eof()); 00976 }
|
|
Reads in the give value type from the file.
Definition at line 930 of file cxfile.cpp. 00931 { 00932 ERROR3IF(pBuf == NULL,"pBuf is NULL"); 00933 00934 BOOL ok = (pBuf != NULL); 00935 00936 // for (UINT32 i=0;ok && i< Size;i++) 00937 // ok = Read(pBuf+i); 00938 00939 pCCFile->read((void*)pBuf,Size); 00940 IncNumBytesRead(Size); 00941 00942 // AMB commented out eof() line - it seems wrong as reading the last bytes in a file 00943 // will otherwise fail 00944 ok = (!pCCFile->bad() && !pCCFile->fail() /*&& !pCCFile->eof()*/); 00945 00946 return ok; 00947 }
|
|
Reads in the give value type from the file.
Definition at line 883 of file cxfile.cpp. 00884 { 00885 BOOL ok = Read((BYTE*)pUINT32,sizeof(UINT32)); 00886 *pUINT32 = LEtoNative(*pUINT32); 00887 return ok; 00888 }
|
|
|
|
Reads in the next record from the file.
Definition at line 2009 of file cxfile.cpp. 02010 { 02011 ERROR2IF(pCCFile == NULL,FALSE,"NULL pCCFile ptr"); 02012 02013 BOOL ok = FALSE; 02014 02015 if (ReadNextRecordHeader()) 02016 { 02017 // TRACEUSER("Gerry", _T("HandleRecord %d - %d [%d]"), RecordNumber, ReadTag, ReadSize); 02018 02019 CXaraFileRecordHandler* pCXaraFileRecordHandler = FindHandler(ReadTag); 02020 if (pCXaraFileRecordHandler != NULL) 02021 { 02022 // Only if it is not a streamed record do we want to reda in the data into a buffer 02023 if (pCXaraFileRecordHandler->IsStreamed(ReadTag)) 02024 { 02025 // Its a streamed record so just ask the handler to read it. 02026 ok = pCXaraFileRecordHandler->HandleStreamedRecord(this,ReadTag,ReadSize,RecordNumber); 02027 } 02028 else 02029 { 02030 // It is not a streamed record so read it in and ask the handler to 02031 // deal with it 02032 CXaraFileRecord* pCXaraFileRecord = new CamelotFileRecord(pFilter,ReadTag,ReadSize); 02033 02034 if (pCXaraFileRecord != NULL) 02035 { 02036 ok = pCXaraFileRecord->Init(); 02037 pCXaraFileRecord->SetRecordNumber(RecordNumber); 02038 02039 // Read data section, if there is one 02040 if (ok && ReadSize > 0) 02041 { 02042 BYTE* pBuf = pCXaraFileRecord->GetBuffer(); 02043 ok = (pBuf != NULL); 02044 if (ok) ok = Read(pBuf,ReadSize); 02045 } 02046 02047 if (ok) ok = pCXaraFileRecordHandler->HandleRecord(pCXaraFileRecord); 02048 #if !defined(EXCLUDE_FROM_XARLIB) 02049 if (ok) pCXaraFileRecordHandler->IncProgressBarCount(pCXaraFileRecord->GetSize()+8); 02050 #endif 02051 delete pCXaraFileRecord; 02052 } 02053 } 02054 02055 #if !defined(EXCLUDE_FROM_XARLIB) 02056 if (ok && pFilter != NULL) ok = pFilter->SetLastRecordHandler(pCXaraFileRecordHandler,ReadTag); 02057 #endif 02058 } 02059 else 02060 { 02061 // No handler for this tag 02062 //TRACEUSER( "Markn", _T("Unhandled tag value : %d\n"),ReadTag); 02063 02064 // Read the rest of this record, and send the data to oblivion 02065 ok = TRUE; 02066 BYTE b; 02067 for (UINT32 i=0;ok && i<ReadSize;i++) 02068 ok = Read(&b); 02069 } 02070 } 02071 02072 //TRACE(_T("ReadNextTag %d %d\n"), ReadTag, ok); 02073 02074 02075 return ok; 02076 }
|
|
Reads in the header (i.e. tag & size fields) of the next record in the file.
Definition at line 1855 of file cxfile.cpp. 01856 { 01857 BOOL ok = TRUE; 01858 01859 if (ok) ok = Read(&ReadTag); 01860 if (ok) ok = Read(&ReadSize); 01861 if (ok) RecordNumber++; 01862 01863 return ok; 01864 }
|
|
Reads in the given string from the file.
Definition at line 1015 of file cxfile.cpp. 01016 { 01017 ERROR3IF(pStr == NULL,"pStr is NULL"); 01018 ERROR2IF(pCCFile == NULL,FALSE,"Can't read a Unicode String with no pCCFile"); 01019 01020 if (pStr == NULL) 01021 return FALSE; 01022 01023 BOOL ok = TRUE; 01024 01025 #ifdef UNICODE 01026 if (MaxChars==0) 01027 return FALSE; 01028 01029 WCHAR* pBuf = pStr; 01030 WCHAR* pBufEnd = pBuf+MaxChars; // Pointer arithmetic! 01031 WCHAR c = 0; 01032 01033 do 01034 { 01035 ok = ReadWCHAR(&c); // Read two bytes into the WCHAR buffer 01036 if (!ok) c = 0; // If the read failed then write a terminator 01037 *pBuf++ = c; // Add the character to the string 01038 } 01039 while (c!=0 && pBuf<pBufEnd);// Until end of string or out of room in buffer 01040 01041 #else 01042 BYTE* pBuf = (BYTE*)pStr; 01043 BYTE* pBufEnd = pBuf+MaxChars; 01044 BYTE b1 = 1; 01045 BYTE b2 = 1; 01046 01047 while (ok && !(b1 == 0 && b2 == 0)) 01048 { 01049 ok = Read(&b1) && Read(&b2); 01050 01051 if (ok) ok = (pBuf < pBufEnd); 01052 if (ok) *pBuf++ = b1; 01053 } 01054 #endif 01055 01056 return ok; 01057 }
|
|
Definition at line 906 of file cxfile.cpp. 00907 { 00908 BOOL ok = Read((BYTE*)pw, SIZEOF_XAR_UTF16); // sizeof(WCHAR)); 00909 *pw = LEtoNative(*pw); 00910 *pw = UTF16ToNative(*pw); 00911 return ok; 00912 }
|
|
Finds the record handler that's been registered to handle a record with the given tag value.
Definition at line 1880 of file cxfile.cpp. 01881 { 01882 ERROR2IF(pListOfHandlers == NULL, FALSE,"pListOfHandlers is NULL"); 01883 pRecordHandlerList = pListOfHandlers; 01884 return TRUE; 01885 }
|
|
Resets the handlers set up via SetUpHandlers().
Definition at line 425 of file cxfile.cpp. 00426 { 00427 // Delete the StandardDefaultRecordHandler 00428 if (pStandardDefaultRecordHandler != NULL) 00429 { 00430 delete pStandardDefaultRecordHandler; 00431 pStandardDefaultRecordHandler = NULL; 00432 } 00433 00434 // Delete the StandardStripSubTreeRecordHandler 00435 if (pStandardStripSubTreeRecordHandler != NULL) 00436 { 00437 delete pStandardStripSubTreeRecordHandler; 00438 pStandardStripSubTreeRecordHandler = NULL; 00439 } 00440 00441 // delete the tag-to-handler map 00442 if (pMap != NULL) 00443 { 00444 delete pMap; 00445 pMap = NULL; 00446 } 00447 }
|
|
Searches through the list of registered record handlers for a handler for the given tag value.
If one can't be found, a ptr to the default record handler is returned (if there is one).
Definition at line 1936 of file cxfile.cpp. 01937 { 01938 if (pRecordHandlerList != NULL) 01939 { 01940 CXaraFileRecordHandler* pHandler = (CXaraFileRecordHandler*) pRecordHandlerList->GetHead(); 01941 while (pHandler != NULL) 01942 { 01943 if (pHandler->IsTagInList(Tag)) 01944 return pHandler; 01945 01946 pHandler = (CXaraFileRecordHandler*) pRecordHandlerList->GetNext(pHandler); 01947 } 01948 } 01949 01950 return NULL; 01951 }
|
|
Function to turn Compression on or off on the underlying CCFile. This is used during reading to change the state of the file compression.
Definition at line 650 of file cxfile.cpp. 00651 { 00652 ERROR2IF(pCCFile == NULL,FALSE,"CXaraFile::SetCompression pCCFile is NULL"); 00653 00654 // This is used when reading to change the file compression state 00655 // It is called by the compression record handler when it is given the compression on/off 00656 // tags to handle. 00657 // The CCFile ZLib combination will read in the values 00658 BOOL ok = TRUE; 00659 if (NewState) 00660 { 00661 // If turning on then read the version number and check it 00662 UINT32 Version = 0L; 00663 Read(&Version); 00664 00665 UINT32 MajorVersion = Version / 100; 00666 UINT32 MinorVersion = Version - MajorVersion * 100; 00667 TRACEUSER( "Neville", _T("CXaraFile::SetCompression compression version %d.%d\n"),MajorVersion,MinorVersion); 00668 00669 // Now tell CCFile to turn compression on 00670 ok = pCCFile->SetCompression(TRUE); 00671 } 00672 else 00673 { 00674 TRACEUSER( "Neville", _T("CXaraFile::SetCompression off\n")); 00675 // Now tell CCFile to turn compression off 00676 // The Zlib/CCFile combination will automatically read in the CRC and uncompressed size 00677 // and check these. 00678 ok = pCCFile->SetCompression(FALSE); 00679 00680 pCCFile->SetGoodState(); 00681 FilePos Pos = pCCFile->tellIn(); 00682 TRACEUSER( "Neville", _T("CXaraFile::SetCompression pos = %d\n"),Pos); 00683 } 00684 00685 return ok; 00686 }
|
|
Definition at line 577 of file cxfile.cpp. 00578 { 00579 if (pHandler != NULL) 00580 pDefaultRecordHandler = pHandler; 00581 else 00582 pDefaultRecordHandler = pStandardDefaultRecordHandler; 00583 00584 ERROR3IF(pDefaultRecordHandler == NULL,"NULL handler ptr"); 00585 }
|
|
Definition at line 271 of file cxfile.h. 00271 { pFilter = pThisFilter; }
|
|
Definition at line 611 of file cxfile.cpp. 00612 { 00613 if (pHandler != NULL) 00614 pStripSubTreeRecordHandler = pHandler; 00615 else 00616 pStripSubTreeRecordHandler = pStandardStripSubTreeRecordHandler; 00617 00618 ERROR3IF(pStripSubTreeRecordHandler == NULL,"NULL handler ptr"); 00619 }
|
|
Definition at line 237 of file cxfile.h. 00237 { TotalNumBytesToRead = n; }
|
|
Sets up the tag to handler map so that LookUpHandler() can function.
Definition at line 464 of file cxfile.cpp. 00465 { 00466 if (pMap != NULL) 00467 delete pMap; 00468 00469 pMap = new CXaraFileMapTagToHandler; 00470 00471 if (pMap != NULL && pRecordHandlerList != NULL) 00472 { 00473 CXaraFileRecordHandler* pHandler = (CXaraFileRecordHandler*) pRecordHandlerList->GetHead(); 00474 while (pHandler != NULL) 00475 { 00476 UINT32* pTagList = pHandler->GetTagList(); 00477 00478 if (pTagList != NULL) 00479 { 00480 while (*pTagList != CXFRH_TAG_LIST_END) 00481 { 00482 pMap->Add(*pTagList,pHandler); 00483 pTagList++; 00484 } 00485 } 00486 00487 pHandler = (CXaraFileRecordHandler*) pRecordHandlerList->GetNext(pHandler); 00488 } 00489 } 00490 }
|
|
Sets up some record handlers that are needed for reading the file successfully.
Definition at line 264 of file cxfile.cpp. 00265 { 00266 SetUpHandlerMap(); 00267 00268 BOOL ok = TRUE; 00269 00270 // Set up the default handler, but only if there hasn't been one set up yet 00271 if (pDefaultRecordHandler == NULL) 00272 { 00273 if (pStandardDefaultRecordHandler == NULL) 00274 pStandardDefaultRecordHandler = new StandardDefaultRecordHandler; 00275 00276 if (pStandardDefaultRecordHandler == NULL) 00277 { 00278 ERROR3("Unable to create StandardDefaultRecordHandler"); 00279 return FALSE; 00280 } 00281 00282 SetDefaultRecordHandler(pStandardDefaultRecordHandler); 00283 } 00284 00285 // Init the default handler, and inform it we're about to start importing 00286 if (pDefaultRecordHandler != NULL) 00287 { 00288 if (ok) ok = pDefaultRecordHandler->Init(pFilter); 00289 if (ok) ok = pDefaultRecordHandler->BeginImport(); 00290 } 00291 00292 // Set up the sub tree stripper handler, but only if one has not been set yet 00293 if (pStripSubTreeRecordHandler == NULL) 00294 { 00295 if (pStandardStripSubTreeRecordHandler == NULL) 00296 pStandardStripSubTreeRecordHandler = new StripSubTreeRecordHandler; 00297 00298 if (pStandardStripSubTreeRecordHandler == NULL) 00299 { 00300 ERROR3("Unable to create standard sub tree stripper"); 00301 return FALSE; 00302 } 00303 00304 SetStripSubTreeRecordHandler(pStandardStripSubTreeRecordHandler); 00305 } 00306 00307 // Init the sub tree stripper handler, and inform it we're about to start importing 00308 if (pStripSubTreeRecordHandler != NULL) 00309 { 00310 if (ok) ok = pStripSubTreeRecordHandler->Init(pFilter); 00311 if (ok) ok = pStripSubTreeRecordHandler->BeginImport(); 00312 } 00313 00314 return ok; 00315 }
|
|
Function to turn Compression on when we are writing to the file. It asks the underlying CCFile and CXaraFile to start the compression process up. Will only send the record out if the preference option is on.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 705 of file cxfile.cpp. 00706 { 00707 ERROR2IF(pCCFile == NULL,FALSE,"CXaraFile::StartCompression pCCFile is NULL"); 00708 00709 // First check whether we are meant to be doing this or not 00710 // by looking at the filter preference 00711 #if !defined(EXCLUDE_FROM_XARLIB) 00712 if (!BaseCamelotFilter::GetNativeCompression()) 00713 return TRUE; 00714 #endif 00715 00716 if (pCCFile->IsCompressionSet()) 00717 { 00718 // Just continue as if nothing has happened. 00719 //ERROR3("Trying to compress an already compressed stream!"); 00720 return TRUE; 00721 } 00722 00723 // Send out a start compression record 00724 CXaraFileRecord Rec(TAG_STARTCOMPRESSION, TAG_STARTCOMPRESSION_SIZE); 00725 00726 BOOL ok = Rec.Init(); 00727 00728 // Save the version and type of compression all in one word or UINT32. 00729 // Top byte is the type of compression which is zero by default = zlib compression 00730 UINT32 Version = ZLIB_MAJOR_VERSIONNO * 100 + ZLIB_MINOR_VERSIONNO; 00731 Rec.WriteUINT32(Version); 00732 00733 if (ok) ok = (Write(&Rec) != 0); 00734 00735 // Now ask the CCFile to turn compression on as everything after this needs to be 00736 // compressed. 00737 // First, see if we have enough memory to start up the compression system 00738 if (ok) ok = pCCFile->InitCompression(); 00739 00740 // If this fails then don't try anything 00741 if (ok) ok = pCCFile->SetCompression(TRUE); 00742 00743 return ok; 00744 }
|
|
Prepares a record ready for writing to the file.
After this call all Write() functions write to the data section of the record. The complete record (inc. the tag & size fields) is written out when EndRecord() is called. If you know the exact size in bytes of the record you are writing, supply this value via the Size parameter. This allows the write functions to provide additional error checking for you (e.g. if you try and write extra bytes) If you are not sure of the exact number of bytes that will be written to the data section, set the Size param to CXF_UNKNOWN_SIZE. EndRecord() will ensure that the written record will have its size field set to the number of bytes that were written.
Reimplemented in CXaraTemplateFile. Definition at line 1415 of file cxfile.cpp. 01416 { 01417 if (EndRecord()) 01418 { 01419 // Inc the record number 01420 RecordNumber++; 01421 01422 // Create a new record, & initialise it 01423 pRecord = new CXaraFileRecord(Tag,Size); 01424 01425 WriteToRecord = (pRecord != NULL && pRecord->Init()); 01426 01427 if (WriteToRecord) 01428 { 01429 pRecord->SetRecordNumber(RecordNumber); 01430 return RecordNumber; 01431 } 01432 } 01433 01434 return 0; 01435 }
|
|
Reimplemented in CXaraTemplateFile. Definition at line 1437 of file cxfile.cpp. 01438 { 01439 ERROR2IF(WritingStreamedRecord,0,"Already writing a streamed record. Forgot to call EndRecord()?"); 01440 01441 WritingStreamedRecord = TRUE; 01442 WriteToRecord = FALSE; 01443 01444 // Make sure compression off before starting the streamed record. 01445 // If it was turned on, than make sure we know that the writing of the streamed record 01446 // caused it to be turned off. 01447 CompOffDueToStreamedRecord = IsCompressionOn(); 01448 BOOL ok = StopCompression(); 01449 01450 // Must do this after turning compression off as otherwise CCFile will complain 01451 // as FilePos in the compressed stream is an unknown entity 01452 StartOfStreamedRecord = GetFilePos(); 01453 01454 if (ok) ok = Write(Tag); 01455 if (ok) ok = Write(Size); 01456 01457 if (ok) 01458 { 01459 RecordNumber++; 01460 return RecordNumber; 01461 } 01462 01463 return 0; 01464 }
|
|
Function to turn Compression off when we are writing to the file. It asks the underlying CCFile and CXaraFile to stop the compression process. Will only send the record out if the preference option is on.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 789 of file cxfile.cpp. 00790 { 00791 ERROR2IF(pCCFile == NULL,FALSE,"CXaraFile::StopCompression pCCFile is NULL"); 00792 00793 // First check whether we are meant to be doing this or not 00794 // by looking at the filter preference 00795 #if !defined(EXCLUDE_FROM_XARLIB) 00796 if (!BaseCamelotFilter::GetNativeCompression()) 00797 return TRUE; 00798 #endif 00799 00800 if (!pCCFile->IsCompressionSet()) 00801 { 00802 // Just continue as if nothing has happened 00803 //ERROR3("Trying to stop compression on an uncompressed stream!"); 00804 return TRUE; 00805 } 00806 00807 // Now send out the end compression record 00808 UINT32 RecordNumber = WriteRecordHeader(TAG_ENDCOMPRESSION, TAG_ENDCOMPRESSION_SIZE); 00809 if (RecordNumber < 0) 00810 return FALSE; 00811 00812 // If we are turning compression off then just ask the CCFile to do this for us 00813 // This should write out the CRC and file size to the file, so we cannot use the 00814 // legal way of writing records, we have to use the special WriteHeader function above. 00815 BOOL ok = pCCFile->SetCompression(FALSE); 00816 00817 return ok; 00818 }
|
|
Definition at line 628 of file cxfile.cpp. 00629 { 00630 if (pStripSubTreeRecordHandler != NULL) 00631 pStripSubTreeRecordHandler->StripSubTreeOn(); 00632 }
|
|
Writes out the record to the file.
Reimplemented in CXaraTemplateFile. Definition at line 1636 of file cxfile.cpp. 01637 { 01638 ERROR2IF(pRecord == NULL,FALSE,"pRecord param is NULL"); 01639 01640 BOOL ok = EndRecord(); 01641 01642 #if !defined(EXCLUDE_FROM_XARLIB) 01643 ERROR3IF(!pRecord->IsDataSectionFull(),"Data section of the record has not been filled"); 01644 #endif 01645 01646 if (ok) ok = Write(pRecord->GetTag()); 01647 if (ok) ok = Write(pRecord->GetSize()); 01648 if (ok) ok = Write(pRecord->GetBuffer(),pRecord->GetSize()); 01649 01650 // Inc the record number 01651 RecordNumber++; 01652 01653 if (ok) 01654 return RecordNumber; 01655 else 01656 return 0; 01657 }
|
|
Writes out the string as a Unicode string (UTF16).
Definition at line 1144 of file cxfile.cpp. 01145 { 01146 return WriteUnicode(pStr); 01147 }
|
|
Definition at line 1097 of file cxfile.cpp. 01098 { 01099 DoubleUnion u=NativetoLEU(d); 01100 return (Write((BYTE*)&(u.u_INT64),sizeof(u.u_INT64))); 01101 }
|
|
Definition at line 1091 of file cxfile.cpp. 01092 { 01093 FloatUnion u=NativetoLEU(f); 01094 return (Write((BYTE*)&(u.u_INT32),sizeof(u.u_INT32))); 01095 }
|
|
Writes out the given buffer of bytes to the file.
Definition at line 1340 of file cxfile.cpp. 01341 { 01342 ERROR3IF(pBuf == NULL && Size > 0,"NULL pBuf param yet Size > 0"); 01343 01344 BOOL ok = !(pBuf == NULL && Size > 0); 01345 01346 for (UINT32 i=0;i<Size && ok;i++) 01347 ok = Write(pBuf[i]); 01348 01349 return ok; 01350 }
|
|
Writes out the coord.
Definition at line 1244 of file cxfile.cpp.
|
|
Definition at line 1085 of file cxfile.cpp. 01086 { 01087 INT32 t = NativetoLE(n); 01088 return (Write((BYTE*)&t,sizeof(INT32))); 01089 }
|
|
Writes out the given value to the file.
Definition at line 1079 of file cxfile.cpp. 01080 { 01081 UINT32 t = NativetoLE(n); 01082 return (Write((BYTE*)&t,sizeof(UINT32))); 01083 }
|
|
Writes out the given value to the file.
Reimplemented in NULLXaraFile, and CXaraTemplateFile. Definition at line 1367 of file cxfile.cpp. 01368 { 01369 ERROR2IF(pCCFile == NULL,FALSE,"Can't write a BYTE with no pCCFile"); 01370 01371 BOOL ok = TRUE; 01372 01373 if (WriteToRecord && pRecord != NULL) 01374 ok = pRecord->WriteBYTE(b); 01375 else 01376 { 01377 pCCFile->write((void const*)&b); 01378 IncNumBytesWritten(1); 01379 } 01380 01381 return ok; 01382 }
|
|
Writes out the string as an ASCII string.
Definition at line 1205 of file cxfile.cpp. 01206 { 01207 ERROR3IF(pStr == NULL,"NULL pStr"); 01208 if (pStr == NULL) 01209 return FALSE; 01210 01211 UINT32 len = camStrlen(pStr); 01212 01213 #ifdef UNICODE 01214 // Writing a Unicode string at pStr as an ASCII string 01215 // Just write out the first byte of each unicode char. 01216 01217 BOOL ok= TRUE; 01218 for (UINT32 i=0;ok && i<=len;i++) 01219 ok = Write(BYTE(pStr[i*2])); 01220 01221 return ok; 01222 #else 01223 // pStr points at an ASCII string, so write it out 01224 return (Write((BYTE*)pStr,len+1)); 01225 #endif 01226 }
|
|
Writes out the given BitmapSource to this file.
Definition at line 1269 of file cxfile.cpp. 01271 { 01272 ERROR2IF(pThisFilter == NULL, FALSE, "pThisFilter == NULL"); 01273 ERROR2IF(Height == 0, FALSE, "Height == 0"); 01274 01275 CCBufferFile* pBufferFile = new CCBufferFile(GetCCFile()); 01276 // Now create a file that can fill it 01277 if (pBufferFile == NULL || !pBufferFile->IsInited()) 01278 { 01279 return FALSE; 01280 } 01281 // and provide the filter with something to work with 01282 Source.AttachToBufferFile(pBufferFile); 01283 01284 // Work out how much to increment the progress bar by on each loop 01285 OFFSET Size = Source.GetSize(); 01286 UINT32 Increment = (Height * CCBufferFile::DEFAULT_BUFSIZ) / Size; 01287 if (Increment > Height) 01288 { 01289 Increment = Height; 01290 } 01291 else if (Increment < 1) 01292 { 01293 Increment = 1; 01294 } 01295 UINT32 UpdateEvery = Size / (Height * CCBufferFile::DEFAULT_BUFSIZ); 01296 01297 // Write out the BitmapSource DEFAULT_BUFSIZ bytes at a time 01298 UINT32 WritesSinceUpdate = 0; 01299 while (!pBufferFile->IsAllWritten()) 01300 { 01301 pBufferFile->write(NULL, CCBufferFile::DEFAULT_BUFSIZ); 01302 if (pBufferFile->bad() || pBufferFile->fail()) 01303 { 01304 delete pBufferFile; 01305 return FALSE; 01306 } 01307 01308 // We've made some progress so provide some user feedback 01309 ++WritesSinceUpdate; 01310 if (WritesSinceUpdate >= UpdateEvery) 01311 { 01312 pThisFilter->IncProgressBarCount(Increment); 01313 WritesSinceUpdate = 0; 01314 } 01315 }; 01316 01317 // Destroy our file handle 01318 delete pBufferFile; 01319 01320 return TRUE; 01321 }
|
|
Definition at line 1110 of file cxfile.cpp. 01111 { 01112 BOOL ok = TRUE; 01113 01114 if (ok) ok = Write(MyCCPanose.GetFamilyType()); 01115 if (ok) ok = Write(MyCCPanose.GetSerifStyle()); 01116 if (ok) ok = Write(MyCCPanose.GetWeight()); 01117 if (ok) ok = Write(MyCCPanose.GetProportion()); 01118 if (ok) ok = Write(MyCCPanose.GetContrast()); 01119 if (ok) ok = Write(MyCCPanose.GetStrokeVariation()); 01120 if (ok) ok = Write(MyCCPanose.GetArmStyle()); 01121 if (ok) ok = Write(MyCCPanose.GetLetterform()); 01122 if (ok) ok = Write(MyCCPanose.GetMidline()); 01123 if (ok) ok = Write(MyCCPanose.GetXHeight()); 01124 01125 return ok; 01126 }
|
|
Writes out the record to the file Override this if your filter needs to keep track of definition records.
Reimplemented in CXaraTemplateFile. Definition at line 1673 of file cxfile.cpp. 01674 { 01675 // This base class just calls the standard Write function 01676 return(Write(pRecord)); 01677 }
|
|
Writes out a record header directly to the file. It expects the caller to handle other aspects of the record writing. This should only be used by people who know what they are doing e.g. compression.
Reimplemented in CXaraTemplateFile. Definition at line 1699 of file cxfile.cpp. 01700 { 01701 BOOL ok = TRUE; 01702 01703 // Make sure we write directly to file 01704 WriteToRecord = FALSE; 01705 01706 ok = Write(Tag); 01707 if (ok) ok = Write(Size); 01708 01709 // Inc the record number 01710 RecordNumber++; 01711 01712 if (ok) 01713 return RecordNumber; 01714 else 01715 return 0; 01716 }
|
|
Definition at line 1149 of file cxfile.cpp. 01150 { 01151 ERROR3IF(pStr == NULL,"NULL pStr"); 01152 if (pStr == NULL) 01153 return FALSE; 01154 01155 #ifdef UNICODE 01156 // pStr points to a Unicode string, so just write it out 01157 // 01158 // We must cope with byte-order differences between native storage and XAR file storage: 01159 // Native may be big-endian or little-endian, XAR is always little-endian 01160 // Native WCHAR may be 16 or 32 bits, XAR is always 16 bits 01161 // These differences are handled in WriteWCHAR 01162 BOOL ok = TRUE; 01163 WCHAR c = 0; 01164 INT32 i = 0; 01165 01166 do 01167 { 01168 c = pStr[i++]; 01169 ok = WriteWCHAR(c); // Read two bytes into the WCHAR buffer 01170 if (!ok) c = 0; // If the read failed then write a terminator 01171 } 01172 while (c!=0);// Until end of string or no longer OK to write 01173 01174 return ok; // If we terminated due to Read failure tell the caller 01175 01176 #else 01177 // pStr points to an ASCII string, and we want it written as a Unicode string 01178 // Write out each char, followed by a 0 byte 01179 01180 size_t len = camStrlen(pStr); 01181 01182 BOOL ok= TRUE; 01183 for (unsigned i=0;ok && i<=len;i++) 01184 ok = Write(BYTE(pStr[i])) && Write(BYTE(0)); 01185 01186 return ok; 01187 #endif 01188 }
|
|
Definition at line 1103 of file cxfile.cpp. 01104 { 01105 WCHAR t = NativeToUTF16(w); 01106 t = NativetoLE(t); 01107 return (Write((BYTE*)&t, SIZEOF_XAR_UTF16)); //sizeof(WCHAR))); 01108 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|