void FSD_CmpFile::FlushEndOfLine()
{
- TCollection_AsciiString aDummy;
- ReadLine (aDummy); // flush is nothing more than to read till the line-break
+// TCollection_AsciiString aDummy;
+// ReadLine (aDummy); // flush is nothing more than to read till the line-break
/*
static char Buffer[8192];
char c;
{
buffer += '\0';
IsEnd = Standard_True;
+ }
}
}
-}
//=======================================================================
//function : WriteExtendedLine
Storage_BaseDriver& FSD_CmpFile::PutReference(const Standard_Integer aValue)
{
- TCollection_AsciiString aStr = TCollection_AsciiString( aValue ) + " ";
- if ( Device()->Write( (Standard_Address)aStr.ToCString(), aStr.Length() ) != (Standard_Size)aStr.Length() )
- Storage_StreamWriteError::Raise();
- return *this;
+ return PutInteger (aValue);
}
//=======================================================================
Storage_BaseDriver& FSD_CmpFile::PutCharacter(const Standard_Character aValue)
{
- Standard_Integer i = aValue;
- TCollection_AsciiString aStr = TCollection_AsciiString( i ) + " ";
- if ( Device()->Write( (Standard_Address)aStr.ToCString(), aStr.Length() ) != (Standard_Size)aStr.Length() )
- Storage_StreamWriteError::Raise();
-
- return *this;
+ return PutInteger (aValue);
}
//=======================================================================
Storage_BaseDriver& FSD_CmpFile::PutExtCharacter(const Standard_ExtCharacter aValue)
{
- Standard_Integer i = aValue;
- TCollection_AsciiString aStr = TCollection_AsciiString( i ) + " ";
- if ( Device()->Write( (Standard_Address)aStr.ToCString(), aStr.Length() ) != (Standard_Size)aStr.Length() )
- Storage_StreamWriteError::Raise();
-
- return *this;
+ return PutInteger (aValue);
}
//=======================================================================
Storage_BaseDriver& FSD_CmpFile::PutInteger(const Standard_Integer aValue)
{
- TCollection_AsciiString aStr = TCollection_AsciiString( aValue ) + " ";
- if ( Device()->Write( (Standard_Address)aStr.ToCString(), aStr.Length() ) != (Standard_Size)aStr.Length() )
+ char buffer[256];
+ Standard_Size aLen = sprintf (buffer, "%d ", aValue);
+ if ( Device()->Write (buffer, aLen ) != aLen )
Storage_StreamWriteError::Raise();
return *this;
Storage_BaseDriver& FSD_CmpFile::PutBoolean(const Standard_Boolean aValue)
{
- TCollection_AsciiString aStr = TCollection_AsciiString( (Standard_Integer)aValue ) + " ";
- if ( Device()->Write( (Standard_Address)aStr.ToCString(), aStr.Length() ) != (Standard_Size)aStr.Length() )
+ char buffer[3];
+ buffer[0] = (aValue ? '1' : '0');
+ buffer[1] = ' ';
+ buffer[2] = '\0';
+ if ( Device()->Write (buffer, 2) != 2 )
Storage_StreamWriteError::Raise();
return *this;
Storage_BaseDriver& FSD_CmpFile::PutReal(const Standard_Real aValue)
{
- TCollection_AsciiString aStr = TCollection_AsciiString( aValue ) + " ";
- if ( Device()->Write( (Standard_Address)aStr.ToCString(), aStr.Length() ) != (Standard_Size)aStr.Length() )
+ char buffer[256];
+ Standard_Size aLen = sprintf (buffer, "%.17g ", aValue);
+ if ( Device()->Write (buffer, aLen ) != aLen )
Storage_StreamWriteError::Raise();
return *this;
Storage_BaseDriver& FSD_CmpFile::PutShortReal(const Standard_ShortReal aValue)
{
- TCollection_AsciiString aStr = TCollection_AsciiString( aValue ) + " ";
- if ( Device()->Write( (Standard_Address)aStr.ToCString(), aStr.Length() ) != (Standard_Size)aStr.Length() )
+ char buffer[256];
+ Standard_Size aLen = sprintf (buffer, "%.8g ", (double)aValue);
+ if ( Device()->Write (buffer, aLen ) != aLen )
Storage_StreamWriteError::Raise();
return *this;
void FSD_CmpFile::ReadPersistentObjectHeader(Standard_Integer& aRef,
Standard_Integer& aType)
{
- char c;
-
- Device()->Read( (Standard_Address)&c, sizeof( char ) );
-
- while (c != '#') {
- if (IsEnd() || (c != ' ') || (c == '\r')|| (c == '\n')) {
- Storage_StreamFormatError::Raise();
- }
- Device()->Read( (Standard_Address)&c, sizeof( char ) );
- }
-
- GetInteger (aRef);
-
- Device()->Read( (Standard_Address)&c, sizeof( char ) );
-
- while (c != '%') {
- if (IsEnd() || (c != ' ') || (c == '\r')|| (c == '\n')) {
- Storage_StreamFormatError::Raise();
- }
- Device()->Read( (Standard_Address)&c, sizeof( char ) );
- }
-
- GetInteger (aType);
+ TCollection_AsciiString buffer;
+ ReadWord (buffer);
+ if (sscanf (buffer.ToCString(), "#%d%%%d", &aRef, &aType) !=2)
+ Storage_StreamFormatError::Raise();
}
//=======================================================================
return Storage_VSOpenError;
return Device()->Open(aMode);
- /*
- Storage_Error result = Storage_VSOk;
-
- if (OpenMode() == Storage_VSNone) {
-
-#ifdef _WIN32
- TCollection_ExtendedString aWName(aName);
- if (aMode == Storage_VSRead) {
- myStream.open( (const wchar_t*) aWName.ToExtString(),ios::in); // ios::nocreate is not portable
- }
- else if (aMode == Storage_VSWrite) {
- myStream.open( (const wchar_t*) aWName.ToExtString(),ios::out);
- }
- else if (aMode == Storage_VSReadWrite) {
- myStream.open( (const wchar_t*) aWName.ToExtString(),ios::in|ios::out);
-#else
- if (aMode == Storage_VSRead) {
- myStream.open(aName.ToCString(),ios::in); // ios::nocreate is not portable
- }
- else if (aMode == Storage_VSWrite) {
- myStream.open(aName.ToCString(),ios::out);
- }
- else if (aMode == Storage_VSReadWrite) {
- myStream.open(aName.ToCString(),ios::in|ios::out);
-#endif
- }
-
- if (myStream.fail()) {
- result = Storage_VSOpenError;
- }
- else {
- myStream.precision(17);
- myStream.imbue (std::locale::classic()); // use always C locale
- SetOpenMode(aMode);
- }
- }
- else {
- result = Storage_VSAlreadyOpen;
- }
-
- return result;
- */
}
//=======================================================================