cgma
|
#include <CubitFileIOWrapper.hpp>
Public Member Functions | |
CIOWrapper (FILE *xpFile, UnsignedInt32 xeSourceEndian=CCubitFile::mintNativeEndian) | |
CIOWrapper (UnsignedInt32 swap_endian, FILE *xpFile) | |
CIOWrapper (FILE *xpFile, UnsignedInt32 xintAbsoluteOffset, UnsignedInt32 xintRelativeOffset) | |
virtual | ~CIOWrapper () |
virtual UnsignedInt32 | BeginWriteBlock (UnsignedInt32 xintAbsoluteOffset=0) |
virtual void | BeginRewriteBlock (UnsignedInt32 xintAbsoluteOffset, UnsignedInt32 xintRelativeOffset) |
virtual void | Write (const UnsignedInt32 *xpaintData, UnsignedInt32 xintCount) |
virtual void | Write (const char *xpachrData, UnsignedInt32 xintCount, UnsignedInt32 xint32bitPadded=0) |
virtual void | Write (const double *xpadblData, UnsignedInt32 xintCount) |
virtual void | Write (const char *xpachrData) |
virtual UnsignedInt32 | EndWriteBlock () |
virtual void | BeginReadBlock (UnsignedInt32 xintAbsoluteOffset, UnsignedInt32 xintRelativeOffset=0) |
virtual void | Read (UnsignedInt32 *xpaintData, UnsignedInt32 xintCount) |
virtual void | Read (char *xpachrData, UnsignedInt32 xintCount, UnsignedInt32 xint32bitPadded=0) |
virtual void | Read (double *xpadblData, UnsignedInt32 xintCount) |
virtual char * | Read () |
virtual void | EndReadBlock () |
virtual UnsignedInt32 | get_endian () |
virtual UnsignedInt32 | GetLocation () |
Private Attributes | |
FILE * | mpFile |
UnsignedInt32 | mintSwapEndian |
UnsignedInt32 | mintBlockStart |
UnsignedInt32 | mintBlockEnd |
Definition at line 40 of file CubitFileIOWrapper.hpp.
CIOWrapper::CIOWrapper | ( | FILE * | xpFile, |
UnsignedInt32 | xeSourceEndian = CCubitFile::mintNativeEndian |
||
) |
Definition at line 38 of file CubitFileIOWrapper.cpp.
{ if(!xpFile) throw CCubitFile::ePassedNullPointer; mpFile = xpFile; mintSwapEndian = (xintSourceEndian != CCubitFile::mintNativeEndian); mintBlockStart = mintBlockEnd = 0; }
CIOWrapper::CIOWrapper | ( | UnsignedInt32 | swap_endian, |
FILE * | xpFile | ||
) |
Definition at line 47 of file CubitFileIOWrapper.cpp.
{ if(!xpFile) throw CCubitFile::ePassedNullPointer; mpFile = xpFile; mintSwapEndian = swap_endian; mintBlockStart = mintBlockEnd = 0; }
CIOWrapper::CIOWrapper | ( | FILE * | xpFile, |
UnsignedInt32 | xintAbsoluteOffset, | ||
UnsignedInt32 | xintRelativeOffset | ||
) |
Definition at line 57 of file CubitFileIOWrapper.cpp.
{ if(!xpFile) throw CCubitFile::ePassedNullPointer; mpFile = xpFile; mintBlockStart = mintBlockEnd = 0; if(NCubitFile::SetLocation(mpFile, xintAbsoluteOffset + xintRelativeOffset, SEEK_SET)) throw CCubitFile::eFileSeekError; UnsignedInt32 lintSourceEndian; if(fread(&lintSourceEndian, sizeof(UnsignedInt32), 1, mpFile) != 1) throw CCubitFile::eFileReadError; mintSwapEndian = (lintSourceEndian != CCubitFile::mintNativeEndian); }
CIOWrapper::~CIOWrapper | ( | ) | [virtual] |
Definition at line 73 of file CubitFileIOWrapper.cpp.
{ }
void CIOWrapper::BeginReadBlock | ( | UnsignedInt32 | xintAbsoluteOffset, |
UnsignedInt32 | xintRelativeOffset = 0 |
||
) | [virtual] |
Definition at line 166 of file CubitFileIOWrapper.cpp.
{ if(NCubitFile::SetLocation(mpFile, xintAbsoluteOffset + xintRelativeOffset, SEEK_SET)) throw CCubitFile::eFileSeekError; }
void CIOWrapper::BeginRewriteBlock | ( | UnsignedInt32 | xintAbsoluteOffset, |
UnsignedInt32 | xintRelativeOffset | ||
) | [virtual] |
Definition at line 90 of file CubitFileIOWrapper.cpp.
{ mintBlockEnd = mintBlockStart = xintAbsoluteOffset + xintRelativeOffset; if(NCubitFile::SetLocation(mpFile, mintBlockStart, SEEK_SET)) throw CCubitFile::eFileSeekError; }
UnsignedInt32 CIOWrapper::BeginWriteBlock | ( | UnsignedInt32 | xintAbsoluteOffset = 0 | ) | [virtual] |
Definition at line 78 of file CubitFileIOWrapper.cpp.
{ if(NCubitFile::SetLocation(mpFile, 0, SEEK_END)) throw CCubitFile::eFileSeekError; UnsignedInt32 pos; mintBlockEnd = mintBlockStart = pos = NCubitFile::GetLocation(mpFile); return mintBlockStart - xintAbsoluteOffset; }
void CIOWrapper::EndReadBlock | ( | ) | [virtual] |
Definition at line 239 of file CubitFileIOWrapper.cpp.
{ mintBlockStart = mintBlockEnd = 0; }
UnsignedInt32 CIOWrapper::EndWriteBlock | ( | ) | [virtual] |
Definition at line 153 of file CubitFileIOWrapper.cpp.
{ UnsignedInt32 lintBlockEnd = NCubitFile::GetLocation(mpFile); if((UnsignedInt32)lintBlockEnd != mintBlockEnd) throw CCubitFile::eCorruptBlock; UnsignedInt32 lintLength = mintBlockEnd - mintBlockStart; mintBlockEnd = mintBlockStart = 0; return lintLength; }
virtual UnsignedInt32 NCubitFile::CIOWrapper::get_endian | ( | ) | [inline, virtual] |
Definition at line 68 of file CubitFileIOWrapper.hpp.
{ return mintSwapEndian; }
UnsignedInt32 CIOWrapper::GetLocation | ( | ) | [virtual] |
Definition at line 259 of file CubitFileIOWrapper.cpp.
{ return NCubitFile::GetLocation(mpFile); }
void CIOWrapper::Read | ( | UnsignedInt32 * | xpaintData, |
UnsignedInt32 | xintCount | ||
) | [virtual] |
Definition at line 174 of file CubitFileIOWrapper.cpp.
{ if(fread(xpaintData, sizeof(UnsignedInt32), xintCount, mpFile) != xintCount) throw CCubitFile::eFileReadError; if(mintSwapEndian) SwapEndian<UnsignedInt32>(xintCount, xpaintData); }
void CIOWrapper::Read | ( | char * | xpachrData, |
UnsignedInt32 | xintCount, | ||
UnsignedInt32 | xint32bitPadded = 0 |
||
) | [virtual] |
Definition at line 182 of file CubitFileIOWrapper.cpp.
{ if(xintCount) { if(fread(xpachrData, sizeof(char), xintCount, mpFile) != xintCount) throw CCubitFile::eFileReadError; } if(xint32bitPadded) { char lachrPad[8]; // , *lpachrData = NULL; UnsignedInt32 lintMod = (xintCount % sizeof(UnsignedInt32)); if(lintMod) { lintMod = sizeof(UnsignedInt32) - lintMod; if(fread(&lachrPad, sizeof(char), lintMod, mpFile) != lintMod) throw CCubitFile::eFileReadError; } } }
void CIOWrapper::Read | ( | double * | xpadblData, |
UnsignedInt32 | xintCount | ||
) | [virtual] |
Definition at line 200 of file CubitFileIOWrapper.cpp.
{ if(fread(xpadblData, sizeof(double), xintCount, mpFile) != xintCount) throw CCubitFile::eFileReadError; if(mintSwapEndian) SwapEndian<double>(xintCount, xpadblData); }
char * CIOWrapper::Read | ( | ) | [virtual] |
Definition at line 208 of file CubitFileIOWrapper.cpp.
{ UnsignedInt32 lintLength, lintMod; char lachrPad[8], *lpachrData = NULL; if(fread(&lintLength, sizeof(UnsignedInt32), 1, mpFile) != 1) throw CCubitFile::eFileReadError; if(mintSwapEndian) SwapEndian<UnsignedInt32>(1, &lintLength); if(lintLength) { lpachrData = new char[lintLength + 1]; if(!lpachrData) throw CCubitFile::eMemoryError; if(fread(lpachrData, sizeof(char), lintLength, mpFile) != lintLength) { delete[] lpachrData; throw CCubitFile::eFileReadError; } lpachrData[lintLength] = '\0'; lintMod = (lintLength % sizeof(UnsignedInt32)); if(lintMod) { lintMod = sizeof(UnsignedInt32) - lintMod; if(fread(&lachrPad, sizeof(char), lintMod, mpFile) != lintMod) { delete[] lpachrData; throw CCubitFile::eFileReadError; } } } return lpachrData; }
void CIOWrapper::Write | ( | const UnsignedInt32 * | xpaintData, |
UnsignedInt32 | xintCount | ||
) | [virtual] |
Definition at line 98 of file CubitFileIOWrapper.cpp.
{ if(fwrite(xpaintData, sizeof(UnsignedInt32), xintCount, mpFile) != xintCount) throw CCubitFile::eFileWriteError; mintBlockEnd += (sizeof(UnsignedInt32) * xintCount); }
void CIOWrapper::Write | ( | const char * | xpachrData, |
UnsignedInt32 | xintCount, | ||
UnsignedInt32 | xint32bitPadded = 0 |
||
) | [virtual] |
Definition at line 105 of file CubitFileIOWrapper.cpp.
{ if(xintCount) { if(fwrite(xpachrData, sizeof(char), xintCount, mpFile) != xintCount) throw CCubitFile::eFileWriteError; } UnsignedInt32 lintMod = 0; if(xint32bitPadded) { lintMod = (xintCount % sizeof(UnsignedInt32)); if(lintMod) { lintMod = sizeof(UnsignedInt32) - lintMod; if(fwrite("\0\0\0\0", sizeof(char), lintMod, mpFile) != lintMod) throw CCubitFile::eFileWriteError; } } mintBlockEnd += (sizeof(char) * (xintCount + lintMod)); }
void CIOWrapper::Write | ( | const double * | xpadblData, |
UnsignedInt32 | xintCount | ||
) | [virtual] |
Definition at line 124 of file CubitFileIOWrapper.cpp.
{ if(fwrite(xpadblData, sizeof(double), xintCount, mpFile) != xintCount) throw CCubitFile::eFileWriteError; mintBlockEnd += (sizeof(double) * xintCount); }
void CIOWrapper::Write | ( | const char * | xpachrData | ) | [virtual] |
Definition at line 131 of file CubitFileIOWrapper.cpp.
{ UnsignedInt32 lintLength = xpachrData ? std::strlen(xpachrData) : 0; UnsignedInt32 lintMod = (lintLength % sizeof(UnsignedInt32)); if(fwrite(&lintLength, sizeof(UnsignedInt32), 1, mpFile) != 1) throw CCubitFile::eFileWriteError; if(lintLength) { if(fwrite(xpachrData, sizeof(char), lintLength, mpFile) != lintLength) throw CCubitFile::eFileWriteError; if(lintMod) { lintMod = sizeof(UnsignedInt32) - lintMod; if(fwrite("\0\0\0\0", sizeof(char), lintMod, mpFile) != lintMod) throw CCubitFile::eFileWriteError; } } mintBlockEnd += (sizeof(UnsignedInt32) + sizeof(char) * (lintLength + lintMod)); }
Definition at line 76 of file CubitFileIOWrapper.hpp.
Definition at line 75 of file CubitFileIOWrapper.hpp.
Definition at line 74 of file CubitFileIOWrapper.hpp.
FILE* NCubitFile::CIOWrapper::mpFile [private] |
Definition at line 73 of file CubitFileIOWrapper.hpp.