Line data Source code
1 : /****************************************************************************** 2 : * $Id$ 3 : * 4 : * Project: R Format Driver 5 : * Purpose: Read/write R stats package object format. 6 : * Author: Frank Warmerdam, warmerdam@pobox.com 7 : * 8 : ****************************************************************************** 9 : * Copyright (c) 2009, Frank Warmerdam <warmerdam@pobox.com> 10 : * Copyright (c) 2009-2010, Even Rouault <even dot rouault at spatialys.com> 11 : * 12 : * Permission is hereby granted, free of charge, to any person obtaining a 13 : * copy of this software and associated documentation files (the "Software"), 14 : * to deal in the Software without restriction, including without limitation 15 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 : * and/or sell copies of the Software, and to permit persons to whom the 17 : * Software is furnished to do so, subject to the following conditions: 18 : * 19 : * The above copyright notice and this permission notice shall be included 20 : * in all copies or substantial portions of the Software. 21 : * 22 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 23 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 25 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 28 : * DEALINGS IN THE SOFTWARE. 29 : ****************************************************************************/ 30 : 31 : #ifndef RDATASET_H_INCLUDED 32 : #define RDATASET_H_INCLUDED 33 : 34 : #include <cstddef> 35 : #include <cstdlib> 36 : #include <cstring> 37 : #include <string> 38 : #if HAVE_FCNTL_H 39 : #include <fcntl.h> 40 : #endif 41 : 42 : #include "cpl_conv.h" 43 : #include "cpl_error.h" 44 : #include "cpl_port.h" 45 : #include "cpl_progress.h" 46 : #include "cpl_string.h" 47 : #include "cpl_vsi.h" 48 : #include "gdal.h" 49 : #include "gdal_frmts.h" 50 : #include "gdal_pam.h" 51 : #include "gdal_priv.h" 52 : #include "rawdataset.h" 53 : 54 : GDALDataset *RCreateCopy(const char *pszFilename, GDALDataset *poSrcDS, 55 : int bStrict, char **papszOptions, 56 : GDALProgressFunc pfnProgress, void *pProgressData); 57 : 58 : /************************************************************************/ 59 : /* ==================================================================== */ 60 : /* RDataset */ 61 : /* ==================================================================== */ 62 : /************************************************************************/ 63 : 64 : class RDataset final : public GDALPamDataset 65 : { 66 : friend class RRasterBand; 67 : VSILFILE *fp; 68 : int bASCII; 69 : CPLString osLastStringRead; 70 : 71 : vsi_l_offset nStartOfData; 72 : 73 : double *padfMatrixValues; 74 : 75 : const char *ASCIIFGets(); 76 : int ReadInteger(); 77 : double ReadFloat(); 78 : const char *ReadString(); 79 : bool ReadPair(CPLString &osItemName, int &nItemType); 80 : 81 : public: 82 : RDataset(); 83 : ~RDataset(); 84 : 85 : static GDALDataset *Open(GDALOpenInfo *); 86 : static int Identify(GDALOpenInfo *); 87 : }; 88 : 89 : /************************************************************************/ 90 : /* ==================================================================== */ 91 : /* RRasterBand */ 92 : /* ==================================================================== */ 93 : /************************************************************************/ 94 : 95 : class RRasterBand final : public GDALPamRasterBand 96 : { 97 : friend class RDataset; 98 : 99 : const double *padfMatrixValues; 100 : 101 : public: 102 : RRasterBand(RDataset *, int, const double *); 103 : 104 14 : virtual ~RRasterBand() 105 7 : { 106 14 : } 107 : 108 : virtual CPLErr IReadBlock(int, int, void *) override; 109 : }; 110 : 111 : #endif /* RDATASET_H_INCLUDED */