0025369: Visualization, Image_AlienPixMap - handle UTF-8 names in image read/save...
[occt.git] / src / XmlLDrivers / XmlLDrivers.cxx
CommitLineData
b311480e 1// Created on: 2001-07-09
2// Created by: Julia DOROVSKIKH
973c2be1 3// Copyright (c) 2001-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#include <XmlLDrivers.ixx>
17
18#include <XmlLDrivers_DocumentStorageDriver.hxx>
19#include <XmlLDrivers_DocumentRetrievalDriver.hxx>
20#include <XmlMDF_ADriverTable.hxx>
21#include <XmlMDF.hxx>
22#include <XmlMDataStd.hxx>
23#include <XmlMDocStd.hxx>
24#include <XmlMFunction.hxx>
25#include <Standard_GUID.hxx>
26
27#include <locale.h>
28#include <time.h>
29#include <Plugin_Macro.hxx>
30
7fd59977 31static Standard_GUID XmlLStorageDriver ("13a56820-8269-11d5-aab2-0050044b1af1");
32static Standard_GUID XmlLRetrievalDriver("13a56822-8269-11d5-aab2-0050044b1af1");
7dcac1df 33#define CURRENT_DOCUMENT_VERSION 7
7fd59977 34
35//=======================================================================
36//function : Factory
37//purpose : PLUGIN FACTORY
38//=======================================================================
39Handle(Standard_Transient) XmlLDrivers::Factory(const Standard_GUID& theGUID)
40{
41 if (theGUID == XmlLStorageDriver)
42 {
43 cout << "XmlLDrivers : Storage Plugin" << endl;
44 static Handle(XmlLDrivers_DocumentStorageDriver) model_sd =
45 new XmlLDrivers_DocumentStorageDriver
46 ("Copyright: Open Cascade, 2001-2002"); // default copyright
47 return model_sd;
48 }
49
50 if (theGUID == XmlLRetrievalDriver)
51 {
52 cout << "XmlLDrivers : Retrieval Plugin" << endl;
53 static Handle (XmlLDrivers_DocumentRetrievalDriver) model_rd =
54 new XmlLDrivers_DocumentRetrievalDriver ();
55 return model_rd;
56 }
57
58 Standard_Failure::Raise ("XmlLDrivers : unknown GUID");
59 return NULL;
60}
61
62#define SLENGTH 80
63//=======================================================================
64//function : CreationDate
65//purpose : mm/dd/yy
66//=======================================================================
67TCollection_AsciiString XmlLDrivers::CreationDate ()
68{
7fd59977 69 Standard_Character nowstr[SLENGTH];
70 time_t nowbin;
71 struct tm *nowstruct;
72
73 if (time(&nowbin) == (time_t) - 1)
74 cerr << "Storage ERROR : Could not get time of day from time()" << endl;
75
76 nowstruct = localtime(&nowbin);
77
78 if (strftime(nowstr, SLENGTH, "%Y-%m-%d", nowstruct) == (size_t) 0)
79 cerr << "Storage ERROR : Could not get string from strftime()" << endl;
80
7fd59977 81 return nowstr;
82}
83
84//=======================================================================
85//function : AttributeDrivers
86//purpose :
87//=======================================================================
88Handle(XmlMDF_ADriverTable) XmlLDrivers::AttributeDrivers
857ffd5e 89 (const Handle(CDM_MessageDriver)& theMessageDriver)
7fd59977 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
498ce76b 112#ifdef _MSC_VER
113#pragma warning(disable:4190) /* disable warning on C++ type returned by C function; should be OK for C++ usage */
114#endif
115
7fd59977 116// Declare entry point PLUGINFACTORY
117PLUGIN(XmlLDrivers)