/* Copyright 2019 Equinor ASA. This file is part of the Open Porous Media project (OPM). OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OPM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OPM. If not, see . */ #ifndef OPM_IO_ECLUTIL_HPP #define OPM_IO_ECLUTIL_HPP #include #include #include #include #include namespace Opm { namespace EclIO { int flipEndianInt(int num); int64_t flipEndianLongInt(int64_t num); float flipEndianFloat(float num); double flipEndianDouble(double num); bool isEOF(std::fstream* fileH); bool fileExists(const std::string& filename); bool isFormatted(const std::string& filename); std::tuple block_size_data_binary(eclArrType arrType); std::tuple block_size_data_formatted(eclArrType arrType); std::string trimr(const std::string &str1); uint64_t sizeOnDiskBinary(int64_t num, Opm::EclIO::eclArrType arrType); uint64_t sizeOnDiskFormatted(const int64_t num, Opm::EclIO::eclArrType arrType); void readBinaryHeader(std::fstream& fileH, std::string& tmpStrName, int& tmpSize, std::string& tmpStrType); void readBinaryHeader(std::fstream& fileH, std::string& arrName, int64_t& size, Opm::EclIO::eclArrType &arrType); void readFormattedHeader(std::fstream& fileH, std::string& arrName, int64_t &num, Opm::EclIO::eclArrType &arrType); template std::vector readBinaryArray(std::fstream& fileH, const int64_t size, Opm::EclIO::eclArrType type, std::function& flip); std::vector readBinaryInteArray(std::fstream &fileH, const int64_t size); std::vector readBinaryRealArray(std::fstream& fileH, const int64_t size); std::vector readBinaryDoubArray(std::fstream& fileH, const int64_t size); std::vector readBinaryLogiArray(std::fstream &fileH, const int64_t size); std::vector readBinaryCharArray(std::fstream& fileH, const int64_t size); template std::vector readFormattedArray(const std::string& file_str, const int size, int64_t fromPos, std::function& process); std::vector readFormattedInteArray(const std::string& file_str, const int64_t size, int64_t fromPos); std::vector readFormattedCharArray(const std::string& file_str, const int64_t size, int64_t fromPos); std::vector readFormattedRealArray(const std::string& file_str, const int64_t size, int64_t fromPos); std::vector readFormattedLogiArray(const std::string& file_str, const int64_t size, int64_t fromPos); std::vector readFormattedDoubArray(const std::string& file_str, const int64_t size, int64_t fromPos); }} // namespace Opm::EclIO #endif // OPM_IO_ECLUTIL_HPP