#include "ThirdPartyHeadersBegin.h"
#include <boost/assign.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/unordered_map.hpp>
#include <cstdio>
#include <mpi.h>
#include <string>
#include "ThirdPartyHeadersEnd.h"
#include "MPIFileReader.h"
namespace tecplot { namespace teciompi { MPIFileReader::MPIFileReader(std::string const& ___1394, MPI_Comm comm) : m_ioStream(___1394, comm) {} MPIFileReader::~MPIFileReader() {} ___372 MPIFileReader::___2041() const { return m_ioStream.fileHandle() != NULL; } ___372 MPIFileReader::close(bool ___3361) { ___372 ___3358 = ___4226; if (___2041()) ___3358 = m_ioStream.close(___3361); ENSURE(!___2041()); ENSURE(VALID_BOOLEAN(___3358)); return ___3358; } ___3933::___1393 MPIFileReader::fileLoc() { REQUIRE(___2041()); return static_cast<___3933::___1393>(m_ioStream.fileLoc()); } ___372 MPIFileReader::___3460() { REQUIRE(___2041()); return m_ioStream.___3460(); } ___372 MPIFileReader::___3459(___3933::___1393 fileLoc) { REQUIRE(___2041()); return m_ioStream.___3459(fileLoc); } ___372 MPIFileReader::seekToFileEnd() { REQUIRE(___2041()); return m_ioStream.seekToFileEnd(); } std::string const& MPIFileReader::___1394() const { return m_ioStream.___1394(); } void MPIFileReader::___3494(___372 ___2002) { REQUIRE(VALID_BOOLEAN(___2002)); m_ioStream.___3494(___2002); } ___372 MPIFileReader::___2002() const { return m_ioStream.___2002(); } void MPIFileReader::setDataFileType(DataFileType_e ___844) { REQUIRE(VALID_ENUM(___844, DataFileType_e)); m_ioStream.setDataFileType(___844); } DataFileType_e MPIFileReader::___844() const { return m_ioStream.___844(); } ___3933::FileIOStatistics& MPIFileReader::statistics() { return m_ioStream.statistics(); } ___372 MPIFileReader::open() { REQUIRE(!___2041()); return m_ioStream.open(MPI_MODE_RDONLY); } namespace { MPI_Datatype mpiDatatypeForSize(size_t size) { static boost::unordered_map<size_t, MPI_Datatype> typeForSize = boost::assign::map_list_of (1, static_cast<MPI_Datatype>(MPI_CHAR)) (2, static_cast<MPI_Datatype>(MPI_SHORT)) (4, static_cast<MPI_Datatype>(MPI_INT)) (8, static_cast<MPI_Datatype>(MPI_DOUBLE)); REQUIRE(typeForSize.find(size) != typeForSize.end()); return typeForSize[size]; } } size_t MPIFileReader::fread(void* ___416, size_t size, size_t count) { REQUIRE(___2041()); int countRead = 0; MPI_Datatype ___906 = mpiDatatypeForSize(size); MPI_Status status; if (MPI_File_read(m_ioStream.fileHandle(), ___416, static_cast<int>(count), ___906, &status) == MPI_SUCCESS) MPI_Get_count(&status, ___906, &countRead); return static_cast<size_t>(countRead); } char* MPIFileReader::fgets(char* s, int size) { REQUIRE(___2041()); REQUIRE(size > 1); MPI_Status status; for (int n = 0; n < size - 1; ++n) { if (MPI_File_read(m_ioStream.fileHandle(), &s[n], 1, MPI_CHAR, &status) != MPI_SUCCESS) { s[n] = '\0'; break; } else if (s[n] == '\n') { s[n + 1] = '\0'; break; } } s[size - 1] = '\0'; return s; } int MPIFileReader::feof() { REQUIRE(___2041()); ___3933::___1393 fileLoc = m_ioStream.fileLoc(); MPI_Offset fileSize; if (MPI_File_get_size(m_ioStream.fileHandle(), &fileSize) == MPI_SUCCESS) return fileLoc < static_cast<___3933::___1393>(fileSize) ? 0 : -1; return -1; } int MPIFileReader::getc() { unsigned char c; MPI_Status status; if (MPI_File_read(m_ioStream.fileHandle(), &c, 1, MPI_CHAR, &status) == MPI_SUCCESS) return c; return EOF; } int MPIFileReader::ungetc(int c) { ___478(___1305); return EOF; } int MPIFileReader::fscanf(char const* format, void* ___3251) { ___478(___1305); return EOF; } int MPIFileReader::fscanf(char const* format, void* ptr1, void* ptr2) { ___478(___1305); return EOF; } int MPIFileReader::fscanf(char const* format, void* ptr1, void* ptr2, void* ptr3) { ___478(___1305); return EOF; } }}
