0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / Storage / Storage_HeaderData.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
42cf5bc1 15
7ed7467d 16#include <Standard_ErrorHandler.hxx>
42cf5bc1 17#include <Storage_HeaderData.hxx>
7ed7467d 18#include <Storage_BaseDriver.hxx>
19#include <Storage_StreamTypeMismatchError.hxx>
20#include <Storage_StreamExtCharParityError.hxx>
42cf5bc1 21#include <TCollection_AsciiString.hxx>
22#include <TCollection_ExtendedString.hxx>
7fd59977 23
25e59720 24IMPLEMENT_STANDARD_RTTIEXT(Storage_HeaderData,Standard_Transient)
92efcf78 25
7fd59977 26Storage_HeaderData::Storage_HeaderData() : myNBObj(0), myErrorStatus(Storage_VSOk)
27{
28}
29
39c8dc70 30Standard_Boolean Storage_HeaderData::Read (const Handle(Storage_BaseDriver)& theDriver)
7ed7467d 31{
32 // Check driver open mode
39c8dc70 33 if (theDriver->OpenMode() != Storage_VSRead
34 && theDriver->OpenMode() != Storage_VSReadWrite)
7ed7467d 35 {
36 myErrorStatus = Storage_VSModeError;
37 myErrorStatusExt = "OpenMode";
38 return Standard_False;
39 }
40
41 // Read info section
39c8dc70 42 myErrorStatus = theDriver->BeginReadInfoSection();
7ed7467d 43 if (myErrorStatus != Storage_VSOk)
44 {
45 myErrorStatusExt = "BeginReadInfoSection";
46 return Standard_False;
47 }
48
49 {
50 try
51 {
52 OCC_CATCH_SIGNALS
39c8dc70 53 theDriver->ReadInfo (myNBObj, myStorageVersion, myDate, mySchemaName, mySchemaVersion,
54 myApplicationName, myApplicationVersion, myDataType, myUserInfo);
7ed7467d 55 }
a738b534 56 catch (Storage_StreamTypeMismatchError const&)
7ed7467d 57 {
58 myErrorStatus = Storage_VSTypeMismatch;
59 myErrorStatusExt = "ReadInfo";
60 return Standard_False;
61 }
a738b534 62 catch (Storage_StreamExtCharParityError const&)
7ed7467d 63 {
64 myErrorStatus = Storage_VSExtCharParityError;
65 myErrorStatusExt = "ReadInfo";
66 return Standard_False;
67 }
68 }
69
39c8dc70 70 myErrorStatus = theDriver->EndReadInfoSection();
7ed7467d 71 if (myErrorStatus != Storage_VSOk)
72 {
73 myErrorStatusExt = "EndReadInfoSection";
74 return Standard_False;
75 }
76
77 // Read comment section
39c8dc70 78 myErrorStatus = theDriver->BeginReadCommentSection();
7ed7467d 79 if (myErrorStatus != Storage_VSOk)
80 {
81 myErrorStatusExt = "BeginReadCommentSection";
82 return Standard_False;
83 }
84
85 {
86 try
87 {
88 OCC_CATCH_SIGNALS
39c8dc70 89 theDriver->ReadComment (myComments);
7ed7467d 90 }
a738b534 91 catch (Storage_StreamTypeMismatchError const&)
7ed7467d 92 {
93 myErrorStatus = Storage_VSTypeMismatch;
94 myErrorStatusExt = "ReadComment";
95 return Standard_False;
96 }
a738b534 97 catch (Storage_StreamExtCharParityError const&)
7ed7467d 98 {
99 myErrorStatus = Storage_VSExtCharParityError;
100 myErrorStatusExt = "ReadComment";
101 return Standard_False;
102 }
103 }
104
39c8dc70 105 myErrorStatus = theDriver->EndReadCommentSection();
7ed7467d 106 if (myErrorStatus != Storage_VSOk)
107 {
108 myErrorStatusExt = "EndReadCommentSection";
109 return Standard_False;
110 }
111
112 return Standard_True;
113}
114
7fd59977 115TCollection_AsciiString Storage_HeaderData::CreationDate() const
116{
117 return myDate;
118}
119
120void Storage_HeaderData::SetSchemaVersion(const TCollection_AsciiString& aVersion)
121{
122 mySchemaVersion = aVersion;
123}
124
125TCollection_AsciiString Storage_HeaderData::SchemaVersion() const
126{
127 return mySchemaVersion;
128}
129
130void Storage_HeaderData::SetSchemaName(const TCollection_AsciiString& aSchemaName)
131{
132 mySchemaName = aSchemaName;
133}
134
135TCollection_AsciiString Storage_HeaderData::SchemaName() const
136{
137 return mySchemaName;
138}
139
140void Storage_HeaderData::SetApplicationVersion(const TCollection_AsciiString& aVersion)
141{
142 myApplicationVersion = aVersion;
143}
144
145TCollection_AsciiString Storage_HeaderData::ApplicationVersion() const
146{
147 return myApplicationVersion;
148}
149
150void Storage_HeaderData::SetApplicationName(const TCollection_ExtendedString& aName)
151{
152 myApplicationName = aName;
153}
154
155TCollection_ExtendedString Storage_HeaderData::ApplicationName() const
156{
157 return myApplicationName;
158}
159
160void Storage_HeaderData::SetDataType(const TCollection_ExtendedString& aName)
161{
162 myDataType = aName;
163}
164
165TCollection_ExtendedString Storage_HeaderData::DataType() const
166{
167 return myDataType;
168}
169
170void Storage_HeaderData::AddToUserInfo(const TCollection_AsciiString& theUserInfo)
171{
172 myUserInfo.Append(theUserInfo);
173}
174
175const TColStd_SequenceOfAsciiString& Storage_HeaderData::UserInfo() const
176{
177 return myUserInfo;
178}
179
180void Storage_HeaderData::AddToComments(const TCollection_ExtendedString& aComments)
181{
182 myComments.Append(aComments);
183}
184
185const TColStd_SequenceOfExtendedString& Storage_HeaderData::Comments() const
186{
187 return myComments;
188}
189
190Standard_Integer Storage_HeaderData::NumberOfObjects() const
191{
192 return myNBObj;
193}
194
195void Storage_HeaderData::SetNumberOfObjects(const Standard_Integer anObjectNumber)
196{
197 myNBObj = anObjectNumber;
198}
199
200void Storage_HeaderData::SetStorageVersion(const TCollection_AsciiString& v)
201{
202 myStorageVersion = v;
203}
204
205void Storage_HeaderData::SetCreationDate(const TCollection_AsciiString& d)
206{
207 myDate = d;
208}
209
210TCollection_AsciiString Storage_HeaderData::StorageVersion() const
211{
212 return myStorageVersion;
213}
214
215Storage_Error Storage_HeaderData::ErrorStatus() const
216{
217 return myErrorStatus;
218}
219
220void Storage_HeaderData::SetErrorStatus(const Storage_Error anError)
221{
222 myErrorStatus = anError;
223}
224
225TCollection_AsciiString Storage_HeaderData::ErrorStatusExtension() const
226{
227 return myErrorStatusExt;
228}
229
230void Storage_HeaderData::SetErrorStatusExtension(const TCollection_AsciiString& anErrorExt)
231{
232 myErrorStatusExt = anErrorExt;
233}
234
235void Storage_HeaderData::ClearErrorStatus()
236{
237 myErrorStatus = Storage_VSOk;
238 myErrorStatusExt.Clear();
239}
240