mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0026961: Recover possibility to read files in old persistence format -- preparation
Added basic support for possibility to read filed in old persistent format. Toolkits TKStd, TKStdL, TKShape added to provide necessary tools (to be done). Obsolete interfaces are removed from classes in PCDM and Storage.
This commit is contained in:
@@ -287,7 +287,6 @@ Storage_Schema::Storage_Schema()
|
||||
Clear();
|
||||
ResetDefaultCallBack();
|
||||
myCallBackState = Standard_False;
|
||||
myNestedState = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -365,11 +364,11 @@ void Storage_Schema::Write
|
||||
}
|
||||
|
||||
for (posto = 1; posto <= plist->Length(); posto++) {
|
||||
AddTypeSelection(plist->Value(posto)->Object());
|
||||
// AddTypeSelection(plist->Value(posto)->Object());
|
||||
}
|
||||
|
||||
for (posfrom = plist->Length() + 1; posfrom <= iData->myPtoA.Length(); posfrom++) {
|
||||
AddTypeSelection(iData->myPtoA.Value(posfrom));
|
||||
// AddTypeSelection(iData->myPtoA.Value(posfrom));
|
||||
}
|
||||
|
||||
// ...and now we write
|
||||
@@ -442,7 +441,7 @@ void Storage_Schema::Write
|
||||
|
||||
errorContext = "WriteRoot";
|
||||
for (i = 1; i <= plist->Length(); i++) {
|
||||
f.WriteRoot(plist->Value(i)->Name(),i,plist->Value(i)->Type());
|
||||
f.WriteRoot(plist->Value(i)->Name(),i,"PDocStd_Document");
|
||||
}
|
||||
|
||||
errorContext = "EndWriteRootSection";
|
||||
@@ -499,378 +498,6 @@ void Storage_Schema::Write
|
||||
Clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : ...and read a Storage file
|
||||
//Arguments:
|
||||
// s: driver to read
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_Data) Storage_Schema::Read(Storage_BaseDriver& f) const
|
||||
{
|
||||
Handle(Storage_Data) dData = new Storage_Data;
|
||||
Storage_Error errorCode;
|
||||
static Standard_Boolean result;
|
||||
static Standard_Integer len;
|
||||
static Standard_Integer i;
|
||||
i = 0 ;
|
||||
Handle(Standard_Persistent) per;
|
||||
Handle(Storage_HArrayOfCallBack) theCallBack;
|
||||
|
||||
Handle(Storage_InternalData) iData = dData->InternalData();
|
||||
Handle(Storage_TypeData) tData = dData->TypeData();
|
||||
Handle(Storage_RootData) rData = dData->RootData();
|
||||
Handle(Storage_HeaderData) hData = dData->HeaderData();
|
||||
|
||||
if ((f.OpenMode() == Storage_VSRead) || (f.OpenMode() == Storage_VSReadWrite)) {
|
||||
|
||||
Storage_Schema::ISetCurrentData(dData);
|
||||
|
||||
// IReadHeaderSection can set an error status
|
||||
//
|
||||
result = IReadHeaderSection(f,hData);
|
||||
|
||||
if (result) {
|
||||
Handle(Storage_CallBack) accallBack;
|
||||
Standard_Integer p;
|
||||
TCollection_AsciiString typeName;
|
||||
|
||||
iData->myReadArray = new Storage_HPArray(1,dData->NumberOfObjects());
|
||||
|
||||
// IReadTypeSection can set an error status
|
||||
//
|
||||
result = IReadTypeSection(f,tData);
|
||||
|
||||
if (result) {
|
||||
len = dData->NumberOfTypes();
|
||||
theCallBack = new Storage_HArrayOfCallBack(1,len);
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
for (i = 1; i <= len; i++) {
|
||||
typeName = tData->Type(i);
|
||||
p = tData->Type(typeName);
|
||||
theCallBack->SetValue(p,CallBackSelection(typeName));
|
||||
}
|
||||
}
|
||||
catch(Storage_StreamUnknownTypeError) {
|
||||
result = Standard_False;
|
||||
dData->SetErrorStatus(Storage_VSUnknownType);
|
||||
dData->SetErrorStatusExtension(typeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dData->SetErrorStatus(tData->ErrorStatus());
|
||||
dData->SetErrorStatusExtension(tData->ErrorStatusExtension());
|
||||
}
|
||||
}
|
||||
else {
|
||||
dData->SetErrorStatus(hData->ErrorStatus());
|
||||
dData->SetErrorStatusExtension(hData->ErrorStatusExtension());
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result = IReadRootSection(f,rData);
|
||||
dData->SetErrorStatus(rData->ErrorStatus());
|
||||
if (!result) dData->SetErrorStatusExtension(rData->ErrorStatusExtension());
|
||||
}
|
||||
|
||||
if (result) {
|
||||
Standard_Integer otype, oref = 0;
|
||||
|
||||
errorCode = f.BeginReadRefSection();
|
||||
|
||||
if (errorCode == Storage_VSOk) {
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
len = f.RefSectionSize();
|
||||
|
||||
for (i = 1; i <= len; i++) {
|
||||
f.ReadReferenceType(oref,otype);
|
||||
iData->myReadArray->ChangeValue(oref) = theCallBack->Value(otype)->New();
|
||||
if (!iData->myReadArray->ChangeValue(oref).IsNull()) iData->myReadArray->ChangeValue(oref)->_typenum = otype;
|
||||
}
|
||||
}
|
||||
catch(Storage_StreamTypeMismatchError) {
|
||||
TCollection_AsciiString aOref = oref;
|
||||
result = Standard_False;
|
||||
dData->SetErrorStatus(Storage_VSTypeMismatch);
|
||||
dData->SetErrorStatusExtension(aOref);
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
errorCode = f.EndReadRefSection();
|
||||
result = (errorCode == Storage_VSOk);
|
||||
dData->SetErrorStatus(errorCode);
|
||||
if (!result) dData->SetErrorStatusExtension("EndReadRefSection");
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = Standard_False;
|
||||
dData->SetErrorStatus(errorCode);
|
||||
dData->SetErrorStatusExtension("BeginReadRefSection");
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
errorCode = f.BeginReadDataSection();
|
||||
result = (errorCode == Storage_VSOk);
|
||||
dData->SetErrorStatus(errorCode);
|
||||
if (!result) dData->SetErrorStatusExtension("BeginReadDataSection");
|
||||
}
|
||||
|
||||
if (result) {
|
||||
Handle(Storage_Schema) me = this;
|
||||
Handle(Storage_CallBack) rcback;
|
||||
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
for (i = 1; i <= dData->NumberOfObjects(); i++) {
|
||||
Handle(Standard_Persistent) pobj = iData->myReadArray->Value(i);
|
||||
if (!pobj.IsNull()) {
|
||||
rcback = theCallBack->Value(pobj->_typenum);
|
||||
rcback->Read(pobj,f,me);
|
||||
pobj->_typenum = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Storage_StreamTypeMismatchError) {
|
||||
result = Standard_False;
|
||||
dData->SetErrorStatus(Storage_VSTypeMismatch);
|
||||
dData->SetErrorStatusExtension(i-1);
|
||||
}
|
||||
catch(Storage_StreamFormatError) {
|
||||
result = Standard_False;
|
||||
dData->SetErrorStatus(Storage_VSFormatError);
|
||||
dData->SetErrorStatusExtension(i-1);
|
||||
}
|
||||
catch(Storage_StreamReadError) {
|
||||
result = Standard_False;
|
||||
dData->SetErrorStatus(Storage_VSFormatError);
|
||||
dData->SetErrorStatusExtension(i-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
Handle(Storage_HSeqOfRoot) rlist = rData->Roots();
|
||||
Handle(Storage_Root) rroot;
|
||||
|
||||
for(i = 1; i <= dData->NumberOfRoots(); i++) {
|
||||
rroot = rlist->Value(i);
|
||||
rData->UpdateRoot(rroot->Name(),iData->myReadArray->Value(rroot->Reference()));
|
||||
}
|
||||
|
||||
errorCode = f.EndReadDataSection();
|
||||
result = (errorCode == Storage_VSOk);
|
||||
dData->SetErrorStatus(errorCode);
|
||||
if (!result) dData->SetErrorStatusExtension("EndReadDataSection");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dData->SetErrorStatus(Storage_VSModeError);
|
||||
dData->SetErrorStatusExtension("OpenMode");
|
||||
}
|
||||
|
||||
iData->Clear();
|
||||
Clear();
|
||||
|
||||
return dData;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadHeaderSection
|
||||
//purpose : read the header part of the stream
|
||||
//Arguments:
|
||||
// s: driver to read
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_HeaderData) Storage_Schema::ReadHeaderSection
|
||||
(Storage_BaseDriver& s) const
|
||||
{
|
||||
Handle(Storage_HeaderData) result = new Storage_HeaderData;
|
||||
|
||||
if ((s.OpenMode() == Storage_VSRead) || (s.OpenMode() == Storage_VSReadWrite)) {
|
||||
IReadHeaderSection(s,result);
|
||||
}
|
||||
else {
|
||||
result->SetErrorStatus(Storage_VSModeError);
|
||||
result->SetErrorStatusExtension("OpenMode");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadTypeSection
|
||||
//purpose : fill the TypeData with the names of the type used
|
||||
// in a stream
|
||||
//Arguments:
|
||||
// s: driver to read
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_TypeData) Storage_Schema::ReadTypeSection
|
||||
(Storage_BaseDriver& f) const
|
||||
{
|
||||
Handle(Storage_TypeData) result = new Storage_TypeData;
|
||||
|
||||
if ((f.OpenMode() == Storage_VSRead) || (f.OpenMode() == Storage_VSReadWrite)) {
|
||||
IReadTypeSection(f,result);
|
||||
}
|
||||
else {
|
||||
result->SetErrorStatus(Storage_VSModeError);
|
||||
result->SetErrorStatusExtension("OpenMode");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadRootSection
|
||||
//purpose : read root part of the file
|
||||
//Arguments:
|
||||
// s: driver to read
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_RootData) Storage_Schema::ReadRootSection
|
||||
(Storage_BaseDriver& f) const
|
||||
{
|
||||
Handle(Storage_RootData) result = new Storage_RootData;
|
||||
|
||||
if ((f.OpenMode() == Storage_VSRead) || (f.OpenMode() == Storage_VSReadWrite)) {
|
||||
IReadRootSection(f,result);
|
||||
}
|
||||
else {
|
||||
result->SetErrorStatus(Storage_VSModeError);
|
||||
result->SetErrorStatusExtension("OpenMode");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SchemaKnownTypes
|
||||
//purpose : returns the known types of a schema
|
||||
//=======================================================================
|
||||
|
||||
const TColStd_SequenceOfAsciiString& Storage_Schema::SchemaKnownTypes() const
|
||||
{
|
||||
static TColStd_SequenceOfAsciiString aSeq;
|
||||
return aSeq;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetAllSchemaKnownTypes
|
||||
//purpose : returns the all known types of a schema and their
|
||||
// nested schemes.
|
||||
//PTV : add get of all known type for inheritance of schemas
|
||||
//=======================================================================
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) Storage_Schema::
|
||||
GetAllSchemaKnownTypes() const
|
||||
{
|
||||
Handle(TColStd_HSequenceOfAsciiString) aSeqOfType = new TColStd_HSequenceOfAsciiString;
|
||||
const TColStd_SequenceOfAsciiString& alocalTypeList = SchemaKnownTypes();
|
||||
|
||||
for (Standard_Integer k = 1; k <= alocalTypeList.Length(); k++)
|
||||
aSeqOfType->Append(alocalTypeList.Value(k));
|
||||
|
||||
// get nested schemas
|
||||
Handle(Storage_HArrayOfSchema) aNestedSchemas = NestedSchemas();
|
||||
if (!aNestedSchemas.IsNull())
|
||||
{
|
||||
for (Standard_Integer i = aNestedSchemas->Lower(); i <= aNestedSchemas->Upper(); i++)
|
||||
{
|
||||
Handle(Storage_Schema) aSchema = aNestedSchemas->Value(i);
|
||||
if (aSchema.IsNull())
|
||||
continue;
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) typeList = aSchema->GetAllSchemaKnownTypes();
|
||||
for (Standard_Integer j = 1; j <= typeList->Length(); j++)
|
||||
aSeqOfType->Append(typeList->Value(j));
|
||||
}
|
||||
}
|
||||
|
||||
return aSeqOfType;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasUnknownType
|
||||
//purpose : indicates whether the are types in the driver
|
||||
// which are not known from the schema and for which
|
||||
// no callbacks have been set. The unknown types can
|
||||
// be read in <theUnknownTypes>.
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Storage_Schema::HasUnknownType
|
||||
(Storage_BaseDriver& f,
|
||||
TColStd_SequenceOfAsciiString& theUnknownTypes) const
|
||||
{
|
||||
Standard_Boolean result = Standard_False;
|
||||
Handle(TColStd_HSequenceOfAsciiString) typeList = GetAllSchemaKnownTypes();
|
||||
|
||||
Handle(Storage_TypeData) tData;
|
||||
|
||||
tData = ReadTypeSection(f);
|
||||
|
||||
result = (tData->ErrorStatus() != Storage_VSOk);
|
||||
|
||||
if (!result) {
|
||||
Standard_Integer i;
|
||||
TColStd_MapOfAsciiString names;
|
||||
|
||||
for (i = 1; i <= typeList->Length(); i++) {
|
||||
names.Add(typeList->Value(i));
|
||||
}
|
||||
|
||||
Handle(TColStd_HSequenceOfAsciiString) flist = tData->Types();
|
||||
|
||||
for (i = 1; i <= flist->Length(); i++) {
|
||||
if (!names.Contains(flist->Value(i))) {
|
||||
theUnknownTypes.Append(flist->Value(i));
|
||||
result = Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNestedSchemas
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Storage_Schema::SetNestedSchemas
|
||||
(const Handle(Storage_HArrayOfSchema)& theSchemas)
|
||||
{
|
||||
myArrayOfSchema = theSchemas;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ClearNestedSchemas
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Storage_Schema::ClearNestedSchemas()
|
||||
{
|
||||
myArrayOfSchema.Nullify();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NestedSchemas
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_HArrayOfSchema) Storage_Schema::NestedSchemas() const
|
||||
{
|
||||
return myArrayOfSchema;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddReadUnknownTypeCallBack
|
||||
//purpose : add two functions to the callback list
|
||||
@@ -995,92 +622,6 @@ Handle(Storage_CallBack) Storage_Schema::DefaultCallBack() const
|
||||
return myDefaultCallBack;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ResolveUnknownType
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_CallBack) Storage_Schema::ResolveUnknownType
|
||||
(const TCollection_AsciiString& aTypeName,
|
||||
const Handle(Standard_Persistent)& p,
|
||||
const Storage_SolveMode aMode) const
|
||||
{
|
||||
Handle(Storage_CallBack) theCallBack;
|
||||
|
||||
if (!myArrayOfSchema.IsNull()) {
|
||||
Standard_Integer i;
|
||||
Standard_Boolean IsNotFound = Standard_True;
|
||||
Standard_Boolean AlreadyMatched;
|
||||
|
||||
for(i = myArrayOfSchema->Lower(); i <= myArrayOfSchema->Upper() && IsNotFound; i++) {
|
||||
Handle(Storage_Schema) aSchema = myArrayOfSchema->Value(i);
|
||||
|
||||
if (!aSchema.IsNull()) {
|
||||
AlreadyMatched = aSchema->SetNested();
|
||||
if (!AlreadyMatched) {
|
||||
if (aMode == Storage_WriteSolve || aMode == Storage_ReadSolve) {
|
||||
theCallBack = aSchema->CallBackSelection(aTypeName);
|
||||
}
|
||||
else if (aMode == Storage_AddSolve) {
|
||||
theCallBack = aSchema->AddTypeSelection(p);
|
||||
}
|
||||
aSchema->UnsetNested();
|
||||
IsNotFound = theCallBack.IsNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!myNestedState && theCallBack.IsNull()) {
|
||||
if (myCallBack.IsBound(aTypeName)) {
|
||||
theCallBack = myCallBack.Find(aTypeName)->CallBack();
|
||||
}
|
||||
else if (myCallBackState == Standard_True) {
|
||||
theCallBack = myDefaultCallBack;
|
||||
}
|
||||
else {
|
||||
Clear();
|
||||
Standard_SStream aMsg;
|
||||
|
||||
aMsg << "Unknown type " << aTypeName << " in schema ";
|
||||
|
||||
if (!myName.IsEmpty()) {
|
||||
aMsg << myName;
|
||||
}
|
||||
|
||||
Storage_StreamUnknownTypeError::Raise(aMsg);
|
||||
}
|
||||
}
|
||||
|
||||
return theCallBack;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CallBackSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_CallBack) Storage_Schema::CallBackSelection
|
||||
(const TCollection_AsciiString&) const
|
||||
{
|
||||
Handle(Storage_CallBack) theCallBack;
|
||||
|
||||
return theCallBack;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddTypeSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Storage_CallBack) Storage_Schema::AddTypeSelection
|
||||
(const Handle(Standard_Persistent)&) const
|
||||
{
|
||||
Handle(Storage_CallBack) theCallBack;
|
||||
|
||||
return theCallBack;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BindType
|
||||
//purpose :
|
||||
@@ -1120,29 +661,6 @@ Handle(Storage_CallBack) Storage_Schema::TypeBinding
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadPersistentReference
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Storage_Schema::ReadPersistentReference
|
||||
(Handle(Standard_Persistent)& sp,
|
||||
Storage_BaseDriver& f)
|
||||
{
|
||||
Standard_Integer ref;
|
||||
|
||||
f.GetReference(ref);
|
||||
|
||||
if (ref != 0) {
|
||||
Handle(Storage_InternalData) iData = Storage_Schema::ICurrentData()->InternalData();
|
||||
|
||||
sp = iData->myReadArray->Value(ref);
|
||||
}
|
||||
else {
|
||||
sp.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddPersistent
|
||||
//purpose :
|
||||
@@ -1208,126 +726,6 @@ void Storage_Schema::Clear() const
|
||||
Storage_Schema::ICurrentData().Nullify();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IReadHeaderSection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Storage_Schema::IReadHeaderSection
|
||||
(Storage_BaseDriver& f,
|
||||
const Handle(Storage_HeaderData)& iData) const
|
||||
{
|
||||
Standard_Boolean result = Standard_False;
|
||||
Storage_Error errorCode;
|
||||
TCollection_AsciiString uinfo,mStorageVersion,mDate,mSchemaName,mSchemaVersion,mApplicationVersion;
|
||||
TCollection_ExtendedString mApplicationName,mDataType;
|
||||
TColStd_SequenceOfAsciiString mUserInfo;
|
||||
TColStd_SequenceOfExtendedString mComment;
|
||||
Standard_Integer mNBObj;
|
||||
|
||||
errorCode = f.BeginReadInfoSection();
|
||||
|
||||
if (errorCode == Storage_VSOk) {
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
f.ReadInfo(mNBObj,
|
||||
mStorageVersion,
|
||||
mDate,
|
||||
mSchemaName,
|
||||
mSchemaVersion,
|
||||
mApplicationName,
|
||||
mApplicationVersion,
|
||||
mDataType,
|
||||
mUserInfo);
|
||||
}
|
||||
catch(Storage_StreamTypeMismatchError) {
|
||||
iData->SetErrorStatus(Storage_VSTypeMismatch);
|
||||
iData->SetErrorStatusExtension("ReadInfo");
|
||||
return Standard_False;
|
||||
}
|
||||
catch(Storage_StreamExtCharParityError) {
|
||||
iData->SetErrorStatus(Storage_VSExtCharParityError);
|
||||
iData->SetErrorStatusExtension("ReadInfo");
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
errorCode = f.EndReadInfoSection();
|
||||
|
||||
iData->SetErrorStatus(errorCode);
|
||||
|
||||
result = (errorCode == Storage_VSOk);
|
||||
|
||||
if (result) {
|
||||
Standard_Integer i;
|
||||
|
||||
iData->SetNumberOfObjects(mNBObj);
|
||||
iData->SetStorageVersion(mStorageVersion);
|
||||
iData->SetCreationDate(mDate);
|
||||
iData->SetSchemaName(mSchemaName);
|
||||
iData->SetSchemaVersion(mSchemaVersion);
|
||||
iData->SetApplicationName(mApplicationName);
|
||||
iData->SetApplicationVersion(mApplicationVersion);
|
||||
iData->SetDataType(mDataType);
|
||||
|
||||
for (i = 1; i <= mUserInfo.Length(); i++) {
|
||||
iData->AddToUserInfo(mUserInfo.Value(i));
|
||||
}
|
||||
|
||||
errorCode = f.BeginReadCommentSection();
|
||||
|
||||
if (errorCode == Storage_VSOk) {
|
||||
{
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
f.ReadComment(mComment);
|
||||
}
|
||||
catch(Storage_StreamTypeMismatchError) {
|
||||
iData->SetErrorStatus(Storage_VSTypeMismatch);
|
||||
iData->SetErrorStatusExtension("ReadComment");
|
||||
return Standard_False;
|
||||
}
|
||||
catch(Storage_StreamExtCharParityError) {
|
||||
iData->SetErrorStatus(Storage_VSExtCharParityError);
|
||||
iData->SetErrorStatusExtension("ReadComment");
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
errorCode = f.EndReadCommentSection();
|
||||
iData->SetErrorStatus(errorCode);
|
||||
iData->SetErrorStatusExtension("EndReadCommentSection");
|
||||
result = (errorCode == Storage_VSOk);
|
||||
|
||||
if (result) {
|
||||
for (i = 1; i <= mComment.Length(); i++) {
|
||||
iData->AddToComments(mComment.Value(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = Standard_False;
|
||||
iData->SetErrorStatus(errorCode);
|
||||
iData->SetErrorStatusExtension("BeginReadCommentSection");
|
||||
}
|
||||
}
|
||||
else {
|
||||
iData->SetErrorStatusExtension("EndReadInfoSection");
|
||||
}
|
||||
}
|
||||
else {
|
||||
iData->SetErrorStatus(errorCode);
|
||||
iData->SetErrorStatusExtension("BeginReadInfoSection");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DATATYPE_MIGRATION
|
||||
//=======================================================================
|
||||
// environment variable CSF_MIGRATION_TYPES should define full path of a file
|
||||
@@ -1392,124 +790,6 @@ Standard_Boolean Storage_Schema::CheckTypeMigration(
|
||||
}
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : IReadTypeSection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Storage_Schema::IReadTypeSection
|
||||
(Storage_BaseDriver& f,
|
||||
const Handle(Storage_TypeData)& tData) const
|
||||
{
|
||||
static Standard_Boolean result;
|
||||
TCollection_AsciiString typeName;
|
||||
Standard_Integer typeNum;
|
||||
|
||||
Storage_Error errorCode;
|
||||
Standard_Integer len,i;
|
||||
|
||||
result = Standard_False;
|
||||
errorCode = f.BeginReadTypeSection();
|
||||
|
||||
if (errorCode == Storage_VSOk) {
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
len = f.TypeSectionSize();
|
||||
|
||||
for (i = 1; i <= len; i++) {
|
||||
f.ReadTypeInformations(typeNum,typeName);
|
||||
#ifdef DATATYPE_MIGRATION
|
||||
TCollection_AsciiString newName;
|
||||
if(CheckTypeMigration(typeName, newName)) {
|
||||
#ifdef OCCT_DEBUG
|
||||
cout << "CheckTypeMigration:OldType = " <<typeName << " Len = "<<typeName.Length()<<endl;
|
||||
cout << "CheckTypeMigration:NewType = " <<newName << " Len = "<< newName.Length()<<endl;
|
||||
#endif
|
||||
typeName = newName;
|
||||
}
|
||||
#endif
|
||||
tData->AddType(typeName,typeNum);
|
||||
}
|
||||
result = Standard_True;
|
||||
}
|
||||
catch(Storage_StreamTypeMismatchError) {
|
||||
tData->SetErrorStatus(Storage_VSTypeMismatch);
|
||||
tData->SetErrorStatusExtension("ReadTypeInformations");
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
errorCode = f.EndReadTypeSection();
|
||||
result = (errorCode == Storage_VSOk);
|
||||
|
||||
tData->SetErrorStatus(errorCode);
|
||||
if (!result) tData->SetErrorStatusExtension("EndReadTypeSection");
|
||||
}
|
||||
}
|
||||
else {
|
||||
tData->SetErrorStatus(errorCode);
|
||||
tData->SetErrorStatusExtension("BeginReadTypeSection");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IReadRootSection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Storage_Schema::IReadRootSection
|
||||
(Storage_BaseDriver& f,
|
||||
const Handle(Storage_RootData)& rData) const
|
||||
{
|
||||
static Standard_Boolean result;
|
||||
Standard_Integer len,i,ref;
|
||||
Storage_Error errorCode;
|
||||
Handle(Standard_Persistent) p;
|
||||
Handle(Storage_Root) aRoot;
|
||||
|
||||
result = Standard_False;
|
||||
errorCode = f.BeginReadRootSection();
|
||||
|
||||
if (errorCode == Storage_VSOk) {
|
||||
TCollection_AsciiString rootName,typeName;
|
||||
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
len = f.RootSectionSize();
|
||||
|
||||
for (i = 1; i <= len; i++) {
|
||||
f.ReadRoot(rootName,ref,typeName);
|
||||
aRoot = new Storage_Root(rootName,p);
|
||||
aRoot->SetReference(ref);
|
||||
aRoot->SetType(typeName);
|
||||
rData->AddRoot(aRoot);
|
||||
}
|
||||
result = Standard_True;
|
||||
}
|
||||
catch(Storage_StreamTypeMismatchError) {
|
||||
result = Standard_False;
|
||||
rData->SetErrorStatus(Storage_VSTypeMismatch);
|
||||
rData->SetErrorStatusExtension("ReadRoot");
|
||||
}
|
||||
|
||||
if (result) {
|
||||
errorCode = f.EndReadRootSection();
|
||||
result = (errorCode == Storage_VSOk);
|
||||
|
||||
rData->SetErrorStatus(errorCode);
|
||||
if (!result) rData->SetErrorStatusExtension("EndReadRootSection");
|
||||
}
|
||||
}
|
||||
else {
|
||||
rData->SetErrorStatus(errorCode);
|
||||
rData->SetErrorStatusExtension("BeginReadRootSection");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ISetCurrentData
|
||||
//purpose :
|
||||
@@ -1562,41 +842,3 @@ TCollection_AsciiString Storage_Schema::ICreationDate()
|
||||
TCollection_AsciiString t(nowstr);
|
||||
return t;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNested
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Storage_Schema::SetNested()
|
||||
{
|
||||
Standard_Boolean result = myNestedState;
|
||||
|
||||
myNestedState = Standard_True;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsNested
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Storage_Schema::IsNested() const
|
||||
{
|
||||
return myNestedState;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnsetNested
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Storage_Schema::UnsetNested()
|
||||
{
|
||||
Standard_Boolean result = myNestedState;
|
||||
|
||||
myNestedState = Standard_False;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user