0024129: Eliminate remaining compiler warnings in MSVC++ 2008 32 bit with warning...
[occt.git] / src / XmlLDrivers / XmlLDrivers.cxx
1 // Created on: 2001-07-09
2 // Created by: Julia DOROVSKIKH
3 // Copyright (c) 2001-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 #include <XmlLDrivers.ixx>
22
23 #include <XmlLDrivers_DocumentStorageDriver.hxx>
24 #include <XmlLDrivers_DocumentRetrievalDriver.hxx>
25 #include <XmlMDF_ADriverTable.hxx>
26 #include <XmlMDF.hxx>
27 #include <XmlMDataStd.hxx>
28 #include <XmlMDocStd.hxx>
29 #include <XmlMFunction.hxx>
30 #include <Standard_GUID.hxx>
31
32 #include <locale.h>
33 #include <time.h>
34 #include <Plugin_Macro.hxx>
35
36 static Standard_GUID XmlLStorageDriver  ("13a56820-8269-11d5-aab2-0050044b1af1");
37 static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1");
38 #define CURRENT_DOCUMENT_VERSION 7
39
40 //=======================================================================
41 //function : Factory
42 //purpose  : PLUGIN FACTORY
43 //=======================================================================
44 Handle(Standard_Transient) XmlLDrivers::Factory(const Standard_GUID& theGUID)
45 {
46   if (theGUID == XmlLStorageDriver)
47   {
48     cout << "XmlLDrivers : Storage Plugin" << endl;
49     static Handle(XmlLDrivers_DocumentStorageDriver) model_sd =
50       new XmlLDrivers_DocumentStorageDriver
51         ("Copyright: Open Cascade, 2001-2002"); // default copyright
52     return model_sd;
53   }
54
55   if (theGUID == XmlLRetrievalDriver)
56   {
57     cout << "XmlLDrivers : Retrieval Plugin" << endl;
58     static Handle (XmlLDrivers_DocumentRetrievalDriver) model_rd =
59       new XmlLDrivers_DocumentRetrievalDriver ();
60     return model_rd;
61   }
62  
63   Standard_Failure::Raise ("XmlLDrivers : unknown GUID");
64   return NULL;
65 }
66
67 #define SLENGTH 80
68 //=======================================================================
69 //function : CreationDate
70 //purpose  : mm/dd/yy
71 //=======================================================================
72 TCollection_AsciiString XmlLDrivers::CreationDate ()
73 {
74   Standard_Character nowstr[SLENGTH];
75   time_t nowbin;
76   struct tm *nowstruct;
77
78   if (time(&nowbin) == (time_t) - 1)
79     cerr << "Storage ERROR : Could not get time of day from time()" << endl;
80   
81   nowstruct = localtime(&nowbin);
82   
83   if (strftime(nowstr, SLENGTH, "%Y-%m-%d", nowstruct) == (size_t) 0)
84     cerr << "Storage ERROR : Could not get string from strftime()" << endl;
85
86   return nowstr;
87 }
88
89 //=======================================================================
90 //function : AttributeDrivers
91 //purpose  : 
92 //=======================================================================
93 Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
94                 (const Handle_CDM_MessageDriver& theMessageDriver)
95 {
96   Handle(XmlMDF_ADriverTable) aTable = new XmlMDF_ADriverTable();
97   //
98   XmlMDF        ::AddDrivers (aTable, theMessageDriver);
99   XmlMDataStd   ::AddDrivers (aTable, theMessageDriver);
100   XmlMFunction  ::AddDrivers (aTable, theMessageDriver);
101   XmlMDocStd    ::AddDrivers (aTable, theMessageDriver); 
102   //
103   return aTable;
104 }
105
106 //=======================================================================
107 //function : StorageVersion
108 //purpose  : Document storage version
109 //=======================================================================
110
111 TCollection_AsciiString XmlLDrivers::StorageVersion()
112 {
113   TCollection_AsciiString aVersionStr (CURRENT_DOCUMENT_VERSION);
114   return aVersionStr;
115 }
116
117 #ifdef _MSC_VER
118 #pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
119 #endif
120
121 // Declare entry point PLUGINFACTORY
122 PLUGIN(XmlLDrivers)