Integration of OCCT 6.5.0 from SVN
[occt.git] / src / XmlLDrivers / XmlLDrivers.cxx
CommitLineData
7fd59977 1// File: XmlLDrivers.cxx
2// Created: Mon Jul 9 12:29:49 MSK DST 2001
3// Author: Julia DOROVSKIKH
4// Copyright: Matra Datavision 2001
5
6#include <XmlLDrivers.ixx>
7
8#include <XmlLDrivers_DocumentStorageDriver.hxx>
9#include <XmlLDrivers_DocumentRetrievalDriver.hxx>
10#include <XmlMDF_ADriverTable.hxx>
11#include <XmlMDF.hxx>
12#include <XmlMDataStd.hxx>
13#include <XmlMDocStd.hxx>
14#include <XmlMFunction.hxx>
15#include <Standard_GUID.hxx>
16
17#include <locale.h>
18#include <time.h>
19#include <Plugin_Macro.hxx>
20
21// avoid warnings on 'extern "C"' functions returning C++ classes
22#ifdef WNT
23#pragma warning(4:4190)
24#endif
25
26static Standard_GUID XmlLStorageDriver ("13a56820-8269-11d5-aab2-0050044b1af1");
27static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1");
28#define CURRENT_DOCUMENT_VERSION 6
29
30//=======================================================================
31//function : Factory
32//purpose : PLUGIN FACTORY
33//=======================================================================
34Handle(Standard_Transient) XmlLDrivers::Factory(const Standard_GUID& theGUID)
35{
36 if (theGUID == XmlLStorageDriver)
37 {
38 cout << "XmlLDrivers : Storage Plugin" << endl;
39 static Handle(XmlLDrivers_DocumentStorageDriver) model_sd =
40 new XmlLDrivers_DocumentStorageDriver
41 ("Copyright: Open Cascade, 2001-2002"); // default copyright
42 return model_sd;
43 }
44
45 if (theGUID == XmlLRetrievalDriver)
46 {
47 cout << "XmlLDrivers : Retrieval Plugin" << endl;
48 static Handle (XmlLDrivers_DocumentRetrievalDriver) model_rd =
49 new XmlLDrivers_DocumentRetrievalDriver ();
50 return model_rd;
51 }
52
53 Standard_Failure::Raise ("XmlLDrivers : unknown GUID");
54 return NULL;
55}
56
57#define SLENGTH 80
58//=======================================================================
59//function : CreationDate
60//purpose : mm/dd/yy
61//=======================================================================
62TCollection_AsciiString XmlLDrivers::CreationDate ()
63{
64 const TCollection_AsciiString anOldNumLocale =
65 (Standard_CString) setlocale (LC_NUMERIC, NULL);
66 setlocale(LC_NUMERIC, "C");
67
68 Standard_Character nowstr[SLENGTH];
69 time_t nowbin;
70 struct tm *nowstruct;
71
72 if (time(&nowbin) == (time_t) - 1)
73 cerr << "Storage ERROR : Could not get time of day from time()" << endl;
74
75 nowstruct = localtime(&nowbin);
76
77 if (strftime(nowstr, SLENGTH, "%Y-%m-%d", nowstruct) == (size_t) 0)
78 cerr << "Storage ERROR : Could not get string from strftime()" << endl;
79
80 setlocale(LC_NUMERIC, (char *) anOldNumLocale.ToCString()) ;
81 return nowstr;
82}
83
84//=======================================================================
85//function : AttributeDrivers
86//purpose :
87//=======================================================================
88Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
89 (const Handle_CDM_MessageDriver& theMessageDriver)
90{
91 Handle(XmlMDF_ADriverTable) aTable = new XmlMDF_ADriverTable();
92 //
93 XmlMDF ::AddDrivers (aTable, theMessageDriver);
94 XmlMDataStd ::AddDrivers (aTable, theMessageDriver);
95 XmlMFunction ::AddDrivers (aTable, theMessageDriver);
96 XmlMDocStd ::AddDrivers (aTable, theMessageDriver);
97 //
98 return aTable;
99}
100
101//=======================================================================
102//function : StorageVersion
103//purpose : Document storage version
104//=======================================================================
105
106TCollection_AsciiString XmlLDrivers::StorageVersion()
107{
108 TCollection_AsciiString aVersionStr (CURRENT_DOCUMENT_VERSION);
109 return aVersionStr;
110}
111
112// Declare entry point PLUGINFACTORY
113PLUGIN(XmlLDrivers)