From: ageay Date: Tue, 20 Aug 2013 11:10:50 +0000 (+0000) Subject: Writing binary VTK files in MEDCoupling X-Git-Tag: DBugPolyhIntersector~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=657e78165c0fcc6cb28aa18a8ffd7ae904222015;p=modules%2Fmed.git Writing binary VTK files in MEDCoupling --- diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.cxx b/src/MEDCoupling/MEDCouplingRefCountObject.cxx index 443ae2cd8..7f9f493f6 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.cxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.cxx @@ -46,6 +46,28 @@ int ParaMEDMEM::MEDCouplingSizeOfVoidStar() return 8*sizeof(std::size_t); } +/*! + * If true is returned it is a LittleEndian machine. + * If false it is a BigEndian machine. + * \return the coding mode of integers of the machine. + */ +bool ParaMEDMEM::MEDCouplingByteOrder() +{ + unsigned int x(1); + unsigned char *xc(reinterpret_cast(&x)); + return xc[0]==1; +} + +const char *ParaMEDMEM::MEDCouplingByteOrderStr() +{ + static const char LITTLEENDIAN_STR[]="LittleEndian"; + static const char BIGENDIAN_STR[]="BigEndian"; + if(MEDCouplingByteOrder()) + return LITTLEENDIAN_STR; + else + return BIGENDIAN_STR; +} + RefCountObject::RefCountObject():_cnt(1) { } diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx index c52e0aff0..f5c99be4a 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.hxx @@ -56,6 +56,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int MEDCouplingVersion(); MEDCOUPLING_EXPORT void MEDCouplingVersionMajMinRel(int& maj, int& minor, int& releas); MEDCOUPLING_EXPORT int MEDCouplingSizeOfVoidStar(); + MEDCOUPLING_EXPORT bool MEDCouplingByteOrder(); + MEDCOUPLING_EXPORT const char *MEDCouplingByteOrderStr(); class MEDCOUPLING_EXPORT RefCountObject { diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 0b9e4e4da..1d7434b7c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -555,6 +555,8 @@ namespace ParaMEDMEM const char *MEDCouplingVersionStr(); int MEDCouplingVersion(); int MEDCouplingSizeOfVoidStar(); + bool MEDCouplingByteOrder(); + const char *MEDCouplingByteOrderStr(); class RefCountObject {