1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __MEDFILEUTILITIES_HXX__
22 #define __MEDFILEUTILITIES_HXX__
24 #include "InterpKernelException.hxx"
25 #include "MEDLoaderDefines.hxx"
28 #include "MEDCouplingMemArray.hxx"
32 namespace MEDFileUtilities
34 med_access_mode TraduceWriteMode(int medloaderwritemode);
35 const char *GetReadableMEDFieldType(med_field_type ft);
36 void CheckMEDCode(int code, med_idt fid, const std::string& msg);
37 void CheckFileForRead(const std::string& fileName);
43 operator med_idt() const { return _fid; }
52 class MEDLOADER_EXPORT MEDFileWritable
56 virtual ~MEDFileWritable() {}
57 void copyOptionsFrom(const MEDFileWritable& other) const;
58 int getTooLongStrPolicy() const;
59 void setTooLongStrPolicy(int newVal);
60 int getZipConnPolicy();
61 void setZipConnPolicy(int newVal);
62 static std::string FileNameFromFID(med_idt fid);
63 protected://policies on write
64 mutable int _too_long_str;
65 mutable int _zipconn_pol;
68 class MEDFileWritableStandAlone : public MEDFileWritable
71 MEDLOADER_EXPORT virtual void writeLL(med_idt fid) const = 0;
72 MEDLOADER_EXPORT virtual void write(const std::string& fileName, int mode) const;
73 MEDLOADER_EXPORT virtual void write30(const std::string& fileName, int mode) const;
74 MEDLOADER_EXPORT MCAuto<DataArrayByte> serialize() const;
75 MEDLOADER_EXPORT static std::string GenerateUniqueDftFileNameInMem();
77 MEDLOADER_EXPORT static const char DFT_FILENAME_IN_MEM[];
79 static T *BuildFromMemoryChunk(DataArrayByte *db);
82 MEDFileUtilities::AutoFid OpenMEDFileForRead(const std::string& fileName);