1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2013 - Scilab Enterprises - Calixte DENIZET 4 * 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * 7 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * This file was originally licensed under the terms of the CeCILL v2.1, 10 * and continues to be available under such terms. 11 * For more information, see the COPYING file which you should have received 12 * along with this program. 13 * 14 */ 15 16 #ifndef __H5OPTIONS_HXX__ 17 #define __H5OPTIONS_HXX__ 18 19 #include <algorithm> 20 #include <string> 21 22 #include "H5Exception.hxx" 23 24 extern "C" 25 { 26 #include "localization.h" 27 } 28 29 namespace org_modules_hdf5 30 { 31 32 class H5Options 33 { 34 enum RowOrder 35 { 36 C, 37 FORTRAN 38 }; 39 40 static RowOrder writeStyle; 41 static RowOrder readStyle; 42 43 public: 44 setOption(const std::string op,const std::string & style)45 static void setOption(const std::string op, const std::string & style) 46 { 47 std::string upperStyle(style); 48 std::transform(style.begin(), style.end(), upperStyle.begin(), toupper); 49 std::string upperOp(op); 50 std::transform(op.begin(), op.end(), upperOp.begin(), toupper); 51 RowOrder order; 52 53 if (upperStyle == "C") 54 { 55 order = C; 56 } 57 else if (upperStyle == "FORTRAN") 58 { 59 order = FORTRAN; 60 } 61 else 62 { 63 throw H5Exception(__LINE__, __FILE__, _("Invalid option: must be C or FORTRAN.")); 64 } 65 66 if (upperOp == "READ") 67 { 68 setWriteStyle(order); 69 } 70 else if (upperOp == "WRITE") 71 { 72 setReadStyle(order); 73 } 74 else 75 { 76 throw H5Exception(__LINE__, __FILE__, _("Invalid option: must be C or FORTRAN.")); 77 } 78 } 79 isWriteFlip()80 static bool isWriteFlip() 81 { 82 return writeStyle == FORTRAN; 83 } 84 isReadFlip()85 static bool isReadFlip() 86 { 87 return readStyle == FORTRAN; 88 } 89 90 private: 91 setWriteStyle(const RowOrder order)92 static void setWriteStyle(const RowOrder order) 93 { 94 writeStyle = order; 95 } 96 setReadStyle(const RowOrder order)97 static void setReadStyle(const RowOrder order) 98 { 99 readStyle = order; 100 } 101 }; 102 } 103 104 #endif // __H5OPTIONS_HXX__ 105